Coder Social home page Coder Social logo

apiairecognizer's Introduction

Dialogflow(API.ai) Recoginzer for Microsoft Bot Framework

Installation

npm install api-ai-recognizer

Usage

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

var bot = new builder.UniversalBot(connector);  

var apiairecognizer = require('api-ai-recognizer');  
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

Dialogflow(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 Dialogflow(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.

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

Added functionaliy

onEnabled() function has been added.

Contributing

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

License

MIT

apiairecognizer's People

Contributors

amitbend avatar awebdeveloper avatar deksden avatar ganadiniakshay avatar lijiarui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apiairecognizer's Issues

"Using Prompts" example missing

On Using Prompts section, do you say:

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.

do you have a example?

Thank You

just wanted to give you a headsup, i searched for api.ai on botbuilder repo and came across your open issue. I quickly came to your GitHub profile and saw the api.ai module for botframework ๐Ÿ‘ Testing now

sessionId exceeding 36 characters

Line 12 - 16 index.js --- there is no length check on sessionId. Sometimes channel_id+user_id > 36 characters, which causes api.ai to error out. One such scenario is when your client is Cortana. Requests from Cortana are failing for sessionId > 36 characters.

What is the right way to handle default intents?

Hi there,
According to docs, if we need to match an intent and respond acc to that then, we can do something like this

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

But i just want to declare something like a default intent match so it can just push the default response coming from DialogFlow. So can anyone tell me the right procedure to do it? If no intent matches then bot should use that default one. Thanks in advance.

Api.ai actions missing

"Action" is very important feature to work with.
Please add it to the api.ai recognizer version.
For me, if you could pass the all json result from api.ai it could be just fine.
Thanks, you did great job there.

session id static

var request = this.app.textRequest(context.message.text.toLowerCase(),{sessionId: 'kjfgwsjhedfcb281908'})

this needs to dynamic instead of a static hard coded value

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.