【发布时间】:2017-09-23 19:42:34
【问题描述】:
我目前正在使用 SlackConnector Repo https://github.com/noobot/SlackConnector。我创建了一个机器人,它会向我的聊天室发送交互式消息。我想为我的交互式按钮添加功能,但是点击它们后我得到了这个响应。 Darn – that didn’t work. Only Slack Apps can add interactive elements to messages. Manage your apps here: https://api.slack.com/apps/ 所以看起来我需要一个请求 URL 来克服我当前的障碍。有没有办法在本地测试交互式消息按钮?
List<SlackAttachment> attachments = new List<SlackAttachment>();
List<SlackAttachmentAction> actions = new List<SlackAttachmentAction>();
actions.Add(new SlackAttachmentAction
{
Name = "game",
Text = "chess",
Type = "button",
Value = "Chess"
});
actions.Add(new SlackAttachmentAction
{
Name = "game",
Text = "Falken's Maze",
Type = "button",
Value = "Maze"
});
actions.Add( new SlackAttachmentAction
{
Name = "game",
Text = "Thermonuclear War",
Type = "danger",
Value = "war"
});
attachments.Add(new SlackAttachment
{
Text = "Choose a game to play",
Fallback = "You are unable to choose a game",
CallbackId = "wopr_game",
ColorHex = "#3AA3E3",
Actions = actions
});
connection.Say(new BotMessage
{
ChatHub = chatHub,
Text = "Usage: !talk <user>",
Attachments = attachments
});
return Task.CompletedTask;
我尝试过的一件事是我将请求 URL 设置为使用从 https://webhook.site/#/ 生成的 url,点击后我仍然得到相同的响应
【问题讨论】:
-
查看本地开发Slack Docs:slack.dev/node-slack-sdk/tutorials/…