npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mailbots/luis-ai

v1.1.0

Published

LUIS natural language parsing for your MailBot

Downloads

3

Readme

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");
mbLuis.luisConfig({
  endpoint: "https://<region>.api.cognitive.microsoft.com/etc/etc"
});

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

// someone emails [email protected]
mailbot.onCommand("help", bot => {
  const topIntent = mbLuis.getTopIntent(bot);

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

  bot.webhook.respond();
});

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;
  bot.webhook.respond();
});

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

Reference

This module

luisMiddleware(config)

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

getTopIntent(bot)

Get the most likely intent from the email

getIntents(bot)

Retrieve all intents with their probabilities

getKeyPhrases(bot)

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

luisAnalyze(bot)

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

createLuisAiSettingsPage(bot)

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:

mailbot.onSettingsViewed(mb.createLuisAiSettingsPage(bot));

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.