@abbott-platform/api-ai-botkit 中文文档教程
api-ai-botkit
用于创建机器人的实用程序库。 到目前为止只测试了 Slack。
有关使用示例代码,请参阅 examples/sample_bot.js
Steps for using lib
从 npm
npm install --save api-ai-botkit
Import Library
const apiaibotkit = require('api-ai-botkit');
安装库使用来自 http://api.ai 网站的令牌创建 apiai
对象
const apiai = apiaibotkit(apiaiToken);
使用 apiai< /code>
controller.hears
中的对象
controller.hears('.*', ['direct_message', 'direct_mention', 'mention'], function (bot, message) {
apiai.process(message, bot);
});
对适当的操作实施不同的反应
apiai
.action('smalltalk.greetings', function (message, resp, bot) {
var responseText = resp.result.fulfillment.speech;
bot.reply(message, responseText);
})
.action('input.unknown', function (message, resp, bot) {
bot.reply(message, "Sorry, I don't understand");
});
License
请参阅 LICENSE。
Terms
您对该示例的使用须遵守 Google API 服务条款。
这不是 Google 的官方产品。
api-ai-botkit
Utility lib for creating bots. So far only tested with Slack.
For usage sample code see examples/sample_bot.js
Steps for using lib
Install library from npm
npm install --save api-ai-botkit
Import Library
const apiaibotkit = require('api-ai-botkit');
Create apiai
object using token from http://api.ai website
const apiai = apiaibotkit(apiaiToken);
Use apiai
object in controller.hears
controller.hears('.*', ['direct_message', 'direct_mention', 'mention'], function (bot, message) {
apiai.process(message, bot);
});
Implement different reactions to appropriate actions
apiai
.action('smalltalk.greetings', function (message, resp, bot) {
var responseText = resp.result.fulfillment.speech;
bot.reply(message, responseText);
})
.action('input.unknown', function (message, resp, bot) {
bot.reply(message, "Sorry, I don't understand");
});
License
See LICENSE.
Terms
Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.
This is not an official Google product.
更多