1

I'm currently using SlackConnector Repo https://github.com/noobot/SlackConnector. I've created a bot and it sends interactive messages to my chat. I would like to add functionality to my interactive buttons but upon clicking them i get this response. Darn – that didn’t work. Only Slack Apps can add interactive elements to messages. Manage your apps here: https://api.slack.com/apps/ So it looks like I need a request URL to get my past my current roadblock. Is there a way to Test the Interactive Message button locally?

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;

One thing I tried was I set the request URL to use a url generated from https://webhook.site/#/ and I still get the same response upon clicking

Master
  • 2,038
  • 2
  • 27
  • 77
  • See the local development Slack Docs: https://slack.dev/node-slack-sdk/tutorials/local-development#using-a-local-request-url-for-development – Joseph Lust Jan 23 '21 at 22:15

1 Answers1

4

It looks to me like you have two problems.

You don't have a Slack app

Interactive Messages only work if you have a registered Slack app. That is why you got that error message. But you can easily create one. Just go here and click on "Create a new app". One reason you need one is that you need to tell Slack to which URL to send the request, after a user clicks a button.

Slack can't reach your local app

Slack's interactive messages will only work with apps that can be reached from the public Internet. So if you want to develop your app locally you need to open your web server to the Internet. There are many ways to do it, one secure way is to use a VPN tunnel service. One provider for this kind of service is ngrok, which is also recommended in the official Slack tutorials. I use it myself and it works great.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • 1
    Perhaps you could tie this answer back into the original problem? As it stands, it is tough to see how or why this might solve his issue. – theMayer Sep 23 '17 at 20:21
  • Sure I will extend my answer – Erik Kalkoken Sep 23 '17 at 21:17
  • Hi @ErikKalkoken thank you for the great answer. I am trying to use ngrok at the moment but i feel like I am setting it up wrong. I am online with ngrok and i put the Forwaring address to be Interactive Message's request url. So it looks like http://1e9ede37.ngrok.io when I click a button i get the same response and ngrok doesn't get a request as well. Any thoughts? – Master Sep 24 '17 at 04:07
  • I actually don't get the same response. i am presented with `Darn – that didn’t work. Only Slack Apps can add interactive elements to messages. Manage your apps here` – Master Sep 24 '17 at 05:17
  • Did you install your Slack App and got a new access token? You would need to use that new access token to send the message that contains the buttons. – Erik Kalkoken Sep 24 '17 at 11:09
  • I feel like I may be doing this wrong. So I installed the app to my workspace and once installed I get this message - `added an integration to this channel:` so then i follow up by inviting my bot to the channel. Typed my command and clicked a interactive message. Same response. – Master Sep 24 '17 at 14:40
  • To install went to api.slack -> basic information -> install your app to your workspace -> specified which channel. – Master Sep 24 '17 at 15:10
  • so far, so good. did you tell your bot to use the new access token you created when installing your app? you can find it on the app management page. – Erik Kalkoken Sep 24 '17 at 15:12
  • Ahh okay. I'll have to look to see how I can pass that value. At the moment I only pass the bot's api token. – Master Sep 24 '17 at 15:20
  • the bot access token works too, but you need to use the one from that page. it should show under the app access token. – Erik Kalkoken Sep 24 '17 at 15:22
  • I feel like I'm at a deadlock lol. when I pass the bot's api token, the bot will come online and I can interact with it in the chat. When I use the Bot User OAuth Access Token the bot doesn't come online. – Master Sep 24 '17 at 15:26
  • @ErikKalkoken btw ty for all the help thus far. Very new technology to me. – Master Sep 24 '17 at 15:31
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/155199/discussion-between-erik-kalkoken-and-master). – Erik Kalkoken Sep 24 '17 at 15:38