将 botkit 用于 Slack 机器人,有没有办法在对话中更新消息?
Using botkit for a Slack bot, is there a way to update messages when in a conversation?
这是关于使用 Botkit 开发 Slack 机器人。
Slack 允许您就地更新消息 - 例如,如果您从用户那里获得输入(无论是通过文本还是按钮),您可以基于此更新消息。 (更多相关信息,请参见 "Replacing the original message":https://api.slack.com/docs/message-buttons)。
Botkit 通过 replyInteractive() 支持这一点,如下所示:https://github.com/howdyai/botkit/blob/master/readme-slack.md#message-buttons.
不过,Botkit 的一个关键功能是支持会话线程。虽然这些允许您提出问题并允许按钮作为答案,但我看不到在对话中进行交互式回复(即更新消息)的方法。
知道怎么做吗?目前不支持它的结论性答案也会有所帮助。谢谢!
有可能,但不是很明显。
bot.startConversation(message, function(err, convo) {
convo.ask({
text: "Here's 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();
});
});
请注意 replyInteractive()
如何使用 reply
而不是 message
。
我知道这已经晚了,但我希望它对某人有所帮助。
这是关于使用 Botkit 开发 Slack 机器人。
Slack 允许您就地更新消息 - 例如,如果您从用户那里获得输入(无论是通过文本还是按钮),您可以基于此更新消息。 (更多相关信息,请参见 "Replacing the original message":https://api.slack.com/docs/message-buttons)。
Botkit 通过 replyInteractive() 支持这一点,如下所示:https://github.com/howdyai/botkit/blob/master/readme-slack.md#message-buttons.
不过,Botkit 的一个关键功能是支持会话线程。虽然这些允许您提出问题并允许按钮作为答案,但我看不到在对话中进行交互式回复(即更新消息)的方法。
知道怎么做吗?目前不支持它的结论性答案也会有所帮助。谢谢!
有可能,但不是很明显。
bot.startConversation(message, function(err, convo) {
convo.ask({
text: "Here's 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();
});
});
请注意 replyInteractive()
如何使用 reply
而不是 message
。
我知道这已经晚了,但我希望它对某人有所帮助。