How to setup buttons with “imBack” type in Slack c

2019-08-13 01:09发布

I've developed few bots using ms botbuilder, there was no problems with Buttons with "imBack" type on Skype, FB, Telegram and web chat. However trying to make it work on Slack i found (and seems like its not documented) that you need extra configuring of Interactive Messages in APP admin panel. So here's my questions regarding this issue:

  1. is it true that its the only way?
  2. If so what's the real reason for that, everything works just fine in all other channels.
  3. Is there a way to setup it programmatically, cos it will be real bad for distribution of bot?
  4. even when i setup endpoint in admin panel looks like it makes request that is barely compatible with how ms builder works (it sends some GET where we need post with relevant info)

Code sample:

...
var reply = activity.CreateReply("hi, can i ask you few question?");

reply.Attachments = new List<Attachment>(){};
var buttonSelect = new CardAction
{
    Value = $" /startCommand",
    Type = "imBack",
    Title = "ok, ask me"
};

var cardForButton = new ThumbnailCard { Buttons = new List<CardAction> { buttonSelect } };
reply.Attachments.Add(cardForButton.ToAttachment());

await connector.Conversations.CreateDirectConversationAsync(botaccount, userAccount, reply);
...

2条回答
成全新的幸福
2楼-- · 2019-08-13 01:42

2 things you can try that are possible solutions

  1. You probably did, but did you activate interactive messages in your slack api dashboard?
  2. There is a token (Verification Token) that you need to get from the oauth section of the Slack api site for your app. you need to include that with the other information here https://slack.botframework.com/Dev/?botId={yourBotID}
查看更多
孤傲高冷的网名
3楼-- · 2019-08-13 02:01

Actually all needed to be done is put https://slack.botframework.com/api/Actions in Request URL when enabling Interactive Messages in Slack, not sure that it was documented earlier on Ms bot framework panel, but it is now. Issue resolved.

查看更多
登录 后发表回答