ApiAiRecognizer – 使用api.ai代替 Microsoft Bot 框架中的luis.ai

网友投稿 513 2022-10-26

ApiAiRecognizer – 使用api.ai代替 Microsoft Bot 框架中的luis.ai

ApiAiRecognizer – 使用api.ai代替 Microsoft Bot 框架中的luis.ai

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(); 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

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:spring cloud中Feign导入jar失败的问题及解决方案
下一篇:TensorFlow Lite- 谷歌移动端深度学习框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~