botkit-sms:集成中间件插件

时间:2017-04-21 05:30:33

标签: node.js botkit

我正在尝试使用botkit-sms api.ai中间件插件,我正在尝试调试源代码,为什么这不起作用,但如果你能提供一些帮助,将会有所帮助输入

图书馆https://github.com/krismuniz/botkit-sms/

的源代码
var apiai = require('botkit-middleware-apiai')({
  token: '...',
  skip_bot: true // or false. If true, the middleware don't send the bot reply/says to api.ai
})

controller.middleware.receive.use(apiai.receive)

controller.hears('.*', 'message_received', apiai.hears, function (bot, message) {
  console.log('received :: ' + message)
  bot.reply(message, 'got the message')
})

1 个答案:

答案 0 :(得分:1)

apiai.hears传递给听觉功能可以改变模式匹配和听觉的工作方式。您现在使用正则表达式在用户输入上匹配意图而不是用户。

但问题是匹配时API.ai middleware uses an === operator,而不是正则表达式。所以模式.*不会匹配任何东西,除非你有一个名为它的意图。

相关问题