LUIS natural language parsing for your MailBot
Last updated a year ago by rsweetland .
MIT · Original npm · Tarball · package.json
$ cnpm install @mailbots/luis-ai 
SYNC missed versions from official npm registry.

LUIS Natural Language Processing MailBot Skill

Teach your MailBot to parse natural language using Microsoft LUIS APIs.

How to Use:

Create a MailBot (if you haven't already).

Set up a LUIS account and train a natural language model (See LUIS setup below).

Install the LUIS MailBot Skill

npm install @mailbots/luis-ai

Require the lib and configure your LUIS endpoint (See LUIS setup)

const mbLuis = require("@mailbots/luis-ai");
  endpoint: "https://<region>.api.cognitive.microsoft.com/etc/etc"

Use individual functions within a MailBot handler to parse natural language, for example:

// someone emails help@your-bot.eml.bot
mailbot.onCommand("help", bot => {
  const topIntent = mbLuis.getTopIntent(bot);

  // do different things based on user intent! ????‍♂️


You can also use middleware to populate bot.skills.luis for every handler

// invoke middleware once...
mailbot.app.use(mbLuis.luisMiddleware({ endpoint: process.env.LUIS_ENDPOINT }));

// every handler now has a LUIS analysis
mailbot.onCommand("help", bot => {
  const topIntent = bot.skills.luis.intents[0].intent;

// here too...
mailbot.onCommand("ask", bot => {
  const topIntent = bot.skills.luis.intents[0].intent;


This module


Get LUIS middleware to parse every request. LUIS results available at bot.skills.luis For example:

mailbot.app.use(mbLuis.luisMiddleware({ endpoint: process.env.LUIS_ENDPOINT }));
// every handler after this point will contain LUIS results on bot.skills.luis

luisConfig({ endpoint: LUIS_ENDPOINT_URL })

Configure LUIS endpoint before calling the below functions independently


Get the most likely intent from the email


Retrieve all intents with their probabilities


Extract key phrases (people, places, search phrases, etc)


Get raw output from LUIS's parsing of the email subject and body


Add this to your onSettingsViewed handler to create a settings page where the LUIS.ai endpoint can be placed. (Mainly for development / demonstration purposes) For example:


LUIS Setup

LUIS is a powerful, flexible system by Microsoft to parse natural language. To keep things simple, here is are instructions for setting up a specific example (a shopping assistant) as described in this article. LUIS has dozens of pre-built knowledge areas and can also be trained on custom knowledge areas.

  1. Go to Luis.ai and create an account.
  2. Under `Build > Intents > Add prebuilt domain intent` add the Shopping.FindItem intent
  3. Under `Build > Entities > Add prebuilt entity ` add the keyPhase entity
  4. Click "Train", then "Publish" in the top right (you must do this with each change)
  5. Under `Manage > Application Settings > Keys and Endpoints`. Copy your Endpoint. It should look something like this: https://<region>.api.cognitive.microsoft.com/luis/v2.0/apps/<appID>?subscription-key=<YOUR-KEY>&q=

Add this endpoint either the config option of this object, or to the developer settings panel.

Current Tags

  • 1.1.0                                ...           latest (a year ago)

2 Versions

  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           a year ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (3)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |