Skip to content

NPM module to use api.ai instead of luis.ai for Microsoft Bot Framework

Notifications You must be signed in to change notification settings

amitbend/ApiAiRecognizer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

API.ai Recoginzer for Microsoft Botframework

Installation

npm install botbuilder-apiai

Usage

    var builder = require('botbuilder');
    var connector = new builder.ConsoleConnector().listen();

    var bot = new builder.UniversalBot(connector);

    var apiairecognizer = require('botbuilder-apiai');
    var recognizer = new apiairecognizer(<api.ai client access token>);

    var intents = new builder.IntentDialog({
         recognizers: [recognizer];
    });

    bot.dialog('/',intents);

    intents.matches('intent.name',function(session,args){
         session.send("your response");
    });

Using Entities

Entities can be found in the args.entities object and can be retrieved using code like below:

    var city = builder.EntityRecognizer.findEntity(args.entities, 'city');

The schema for each entity retrieved with the about method is as below:

     {          entity: 'entity value',
                 type : 'entity name',
                 startIndex: 'start index of entity',
                 endIndex: 'end index of entity',
                 score: 1
     }

Using Fulfillment

api.ai provides fulfillment which can be useful if you are using domains for your chat agent

Fulfillments are available as entitities with the entity name as fulfillment and can be used like below:

     var fulfillment = builder.EntityRecognizer.findEntity(args.entities, 'fulfillment');
     if (fulfillment) {
         var speech = fulfillment.entity;          session.send(speech);
     }

Using Prompts

You can use prompts provided by api.ai for required entities very easily. Just check the actionIncomplete entity from
the entities list and if its true use the fulfillment to send out the prompt.

Added functionaliy

onEnabled() function has been added.

Contributing

All feature requests, bug reprorts and pull requests are welcome!

License

MIT

About

NPM module to use api.ai instead of luis.ai for Microsoft Bot Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%