Using botkit for Slack bot, is there a way to update messages in a conversation?

It's about developing a Slack bot using Botkit.

Slack allows you to update messages on the spot - for example, if you get input from the user (through text or buttons), you can update the message based on this. (More on this here in the section "Replacing the original message": https://api.slack.com/docs/message-buttons ).

The botkit supports this through replyInteractive (), as shown here: https://github.com/howdyai/botkit/blob/master/readme-slack.md#message-buttons .

However, a key feature of Botkit is support for conversation threads. Although this allows you to ask a question and enable buttons as answers, I don’t see a way to make an interactive answer (i.e., Update the message) during a conversation.

Any ideas how to do this? A final answer, which he does not currently support, will also be useful. Thank!

+4
source share
1 answer

This is possible, but not in an obvious way.

bot.startConversation(message, function(err, convo) {
  convo.ask({
    text: "Here some pretext",
    attachments: [{
      "text": "More text",
      "fallback": "Fallback text",
      "callback_id": "Test",
      "actions": [
        {
          "name": "yes",
          "text": "Yes",
          "value": "yes",
          "type": "button",
        },
        {
          "name": "no",
          "text": "No",
          "value": "no",
          "type": "button",
        }
      ]
    }]
  }, function(reply, convo) {// convo.ask callback
    bot.replyInteractive(reply, "This text replaces the previous message");
    convo.say("This is a regular message");
    convo.next();
  });
});

Note that replyInteractive()uses replyinstead message.

I know this is late, but I hope this helps someone.

+2
source

Source: https://habr.com/ru/post/1668077/


All Articles