Botkit 4 + SlackAdapter:无法获取基本对话的触发回调

时间:2019-05-21 16:34:09

标签: javascript express slack botkit

我无法启动基本的会话回调。谁能指出我使用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`)

任何帮助,不胜感激!

1 个答案:

答案 0 :(得分:0)

因此,我的自定义存储提供程序中的某些内容正在干扰。我还没有深入了解它,但是当我注释掉我的存储提供商时,我能够获得对话回电。

例如

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
})