Botkit是一个用于构建聊天机器人、应用和定制集成的工具,旨在简化设计和运行在消息传递平台中底层交互的细节,为开发者提供构建任意类型的机器人的必要工具,也被称为“搭建积木”。
一些机器人像人一样说话,其他人则默默地在后台工作,还有另外一些机器人的界面很像现代的移动应用。Botkit提供了一个易于理解的接口,用于发送和接收消息,以便开发者可以专注于构建新颖的应用程序和体验,而不是处理API端点。
BotkitCodeBasicsvar Botkit = require('botkit');var cotroller = Botkit.slackbot({ clietId: process.ev.clietId, clietSecret: process.ev.clietSecret, studio_toke: process.ev.studio_toke,});cotroller.setupWebserver(process.ev.port,fuctio(err,webserver) { cotroller.createWebhookEdpoits(cotroller.webserver); cotroller.createOauthEdpoits(cotroller.webserver);});cotroller.hears('hello','direct_metio,direct_message', fuctio(bot, message) { bot.reply(message,'Howdy!');});cotroller.hears('tacos','direct_metio,direct_message', fuctio(bot, message) { bot.startCoversatio(message, fuctio(err, covo) { covo.say('Oh boy, taco time!'); covo.ask('What type of taco do you wat?', fuctio(aswer, covo) { var taco_type = aswer.text; // do somethig with this aswer! // storeTacoType(covo.cotext.user, taco_type); covo.say('YUMMMM!!!'); // add aother reply covo.ext(); // cotiue with coversatio }); });});









评论