Giter VIP home page Giter VIP logo

chatbot's Introduction

nlp with luis sample

Bot Framework v4 natural language processing with LUIS bot sample

This bot has been created using Microsoft Bot Framework, it shows how to use LUIS, a Natural Language Understanding service to implement language understanding in a bot. The bot will use LUIS to extract language intents from a user's message.

Prerequisites

This samples requires prerequisites in order to run.

To try this sample

  • Clone the repository

    git clone https://github.com/Microsoft/botbuilder-samples.git
  • In a console, navigate to samples/javascript_nodejs/12.nlp-with-luis

    cd samples/javascript_nodejs/12.nlp-with-luis
  • Install modules

    npm install
  • Setup LUIS

    Assuming prerequisites have been installed:

    # log into Azure
    az login
    # set you Azure subscription
    az account set --subscription "<azure-subscription>"
    # Create the LUIS service application
    msbot clone services --name "<your_bot_name>" --luisAuthoringKey <LUIS-authoring-key> --code-dir "." --location westus --sdkLanguage "Node" --folder deploymentScripts/msbotClone --verbose
  • Important: Ensure that LUIS_CONFIGURATION in index.js matches the name property of your LUIS endpoint in your nlp-with-luis.bot file.

  • Start the bot

    npm start

Testing the bot using Bot Framework Emulator v4

Microsoft Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.

  • Install the Bot Framework Emulator version 4.2.0 or greater from here

Connect to the bot using Bot Framework Emulator v4

  • Launch Bot Framework Emulator
  • File -> Open Bot Configuration
  • Navigate to samples/javascript_nodejs/12.nlp-with-luis folder
  • Select nlp-with-luis.bot file

LUIS

Language Understanding service (LUIS) allows your application to understand what a person wants in their own words. LUIS uses machine learning to allow developers to build applications that can receive user input in natural language and extract meaning from it.

Optional Command-line Tools for LUIS

  • Install the ludown CLI tool here to help describe language understanding components for your bot.
  • Install the luis CLI tool here to create and manage your LUIS applications.

Deploy the bot to Azure

After creating the bot and testing it locally, you can deploy it to Azure to make it accessible from anywhere. To deploy your bot to Azure:

# login to Azure
az login

Publishing Changes to Azure Bot Service

As you make changes to your locally running bot, you can deploy those changes to Azure Bot Service using a publish helper. See publish.cmd if you are on Windows or ./publish if you are on a non-Windows platform. The following is an example of publishing local changes to Azure:

# build the TypeScript bot before you publish
npm run build
# run the publish helper (non-Windows) to update Azure Bot Service.  Use publish.cmd if running on Windows
./publish

Getting Additional Help with Deploying to Azure

To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.

How to modify a language model

This sample uses a language model to train LUIS. The source for the language model can be found in the cognitiveModels\reminders.lu. The .lu (language understanding) file describes language understanding components for your bot. .lu files are text files and can be modified to change what language your bot will understand. The ludown CLI tool takes as input a .lu file and produces a .json file. This .json file is then used as input to the luis CLI tool to train your LUIS application's language understanding model.

Train and publish the LUIS models

If you modify reminders.lu you need to train and publish the LUIS model. You can do so using the ludown and luis CLI tools.

Install ludown and luis CLI tools

```bash
# install the ludown CLI tool
npm install -g ludown
```
```bash
# install the LUIS CLI tool
npm install -g luis-apis
```

To learn more about the ludown CLI tool, refer to the documentation found here.

To learn more about the luis CLI tool, refer to the documentation found here.

Example running ludown and luis

The following examples will train and publish a LUIS model:

msbot get "Reminders" | luis train version --wait --stdin
msbot get "Reminders" | luis publish version --stdin

Further reading

chatbot's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.