javascript - Botkit 4 + SlackAdapter:无法触发基本对话的回调
问题描述
我无法让基本的对话回调被解雇。谁能指出我使用 botkit 4 从 Slack 中的对话中获取响应的工作示例?我设置了 SlackAdapter 并使用了 SlackEventMiddleware 和 SlackMessageTypeMiddleware,但我的回调没有被调用。
我从 botkit 文档中获取了这个基本代码,并在 /slash 命令之后调用它。问题已写,但无论我写什么,都不会触发任何回调。我看到事件来到我的服务器,但没有看到这些回调。
这是我正在测试的代码:
let convo = new BotkitConversation('cheese', controller)
await bot.startPrivateConversation(message.user)
// create a path for when a user says YES
convo.addMessage('You said yes! How wonderful.', 'yes_thread')
// create a path for when a user says NO
convo.addMessage('You said no, that is too bad.', 'no_thread')
// create a path where neither option was matched
// this message has an action field, which directs botkit to go back to the `default` thread after sending this message.
convo.addMessage('Sorry I did not understand.', 'bad_response')
// Create a yes/no question in the default thread...
convo.addQuestion(
'Do you like cheese?',
[
{
pattern: 'yes',
handler: async (response, convo, bot) => {
await convo.gotoThread('yes_thread')
}
},
{
pattern: 'no',
handler: async (response, convo, bot) => {
await convo.gotoThread('no_thread')
}
},
{
default: true,
handler: async (response, convo, bot) => {
await convo.gotoThread('bad_response')
}
}
],
'likes_cheese',
'default'
)
controller.addDialog(convo)
await bot.beginDialog(`cheese`)
非常感谢任何帮助!
解决方案
结果发现我的自定义存储提供程序中的某些东西正在干扰。我还没有深入了解它,但是当我注释掉我的存储提供程序时,我能够得到对话回调。
例如
const controller: Botkit = new Botkit({
adapter: getSlackAdapter()
// TODO: This is causing conversation call backs to NOT fire, let's revisit this later. We may not actually need this.
//storage: services.storageService
})
推荐阅读
- swift - 通过 `var` 从继承的对象中获取不同的类类型
- android - 如何通过 adb 或终端强制音频到蓝牙
- coq - ssreflect:初等代数化简
- node.js - 使用 Node.js 和 Busboy 将多个文件上传到 S3
- wordpress - 从 woocommerce 折扣中排除类别
- php - oci_execute():ORA-06550:第 1 行,第 7 列:PLS-00306:错误的参数数量或类型
- javascript - 通过将数组添加到另一个数组中来创建多维数组
- mysql - MySQL 不允许访问 - “ERROR 1045 (28000)” - 在我的 Macbook 上新安装了免费社区版
- python - 证书验证失败,使用 MechanicalSoup
- django - 文件:在 Django Rest Framework 中使用 Postman “上传有效图像”