0

I’m having trouble getting basic conversation callbacks to be fired. Can anyone point me to a working sample with botkit 4 of getting responses from a conversation in Slack? I set up the SlackAdapter and used the SlackEventMiddleware and SlackMessageTypeMiddleware, but my callbacks aren’t getting called.

I took this basic code from the botkit docs and am calling it after a /slash command. The question is written, but no matter what I write, none of the callbacks are fired. I see the events coming to my server, but not to these call backs.

Here’s the code I’m testing with:

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

Any help much appreciated!

Karim Varela
  • 7,562
  • 10
  • 53
  • 78

1 Answers1

0

So turns out something in my custom storage provider was interfering. I haven't gotten to the bottom of it yet, but when I commented out my storage provider, I was able to get conversation call backs.

e.g.

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
})
Karim Varela
  • 7,562
  • 10
  • 53
  • 78