7

How can I do the above as I keep getting the following error when I try and interact with the accompanying button.

Darn – that didn't work. Only Slack Apps can add interactive elements to messages
Atlantic0
  • 3,271
  • 5
  • 17
  • 24

1 Answers1

6

Interactive Buttons are some of the features that only work if you use a Slack app. One reason for that is that you need a place to configure the URL of your script for Slack to send the request to when someone is clicking on a button. It will also work with webhooks, but only if the webhook is also part of the Slack app. It will not work with a simple custom webhook.

To make a Slack app for your Slack team you need to follow two steps.

  1. Create a new Slack app (e.g. on this page)
  2. Install the Slack app in your Slack team with oath. (See here)

Note that you do not need to publish your Slack app to the Slack App directory. That is optional.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • How can I create a webhook that is part of the slack app? I know how to create a webhook independently but not as part of slack app. – Atlantic0 Nov 17 '16 at 15:59
  • The requested scope of your Slack app needs to include `incoming-webhook`. Then you will receive a response containing the webhook url after you complete the oath process. see section "Request a token" [here](https://api.slack.com/docs/slack-button) for an example. – Erik Kalkoken Nov 17 '16 at 16:06
  • Thanks Erik, I am still stuck. So my redirect URL is the following https://slack.com/oauth/authorize?client_id=&scope=commands+bot – Atlantic0 Nov 17 '16 at 16:14
  • I use a small website for the oauth process that is a PHP script. It contains the "Add to Slack Button" which links to to `slack.com/oath/authorize?client_id=...` The website needs to be able to run through the oauth process with Slack to obtain the access token which bascially is a negotiation between your website and Slack. For that the redirect URL needs to point to the website (not to slack.com). It might look a bit complicated at first, but the [Slack docu](https://api.slack.com/docs/oauth) explains it all pretty well. – Erik Kalkoken Nov 17 '16 at 16:36
  • The oath process is then initiated by clicking on the "Add to Slack" button on your website. It will open a Slack internal screen where you can see what scopes the app wants and authorize it for your Slack team. – Erik Kalkoken Nov 17 '16 at 16:39
  • Hi Erik , I keep getting the following error when I try and add the slack button. OAuth Error: redirect_uri did not match any configured URIs. Passed URI : Allowed URI : none specified – Atlantic0 Nov 17 '16 at 17:43
  • It seams you forgot to specify a redirect uri in the Slack app. If you use the redirect parameter in your first auth request (the one triggered by clicking the add to Slack button on your website) it must match the one you specified in your Slack app. – Erik Kalkoken Nov 17 '16 at 17:52
  • Note that is not the same as the url for the interactive buttons. – Erik Kalkoken Nov 17 '16 at 17:54
  • This is the redirect URL I have in the slack app.Where can I specify the redirect uri. https://slack.com/oauth/authorize?client_id=&scope=commands+bot appreciate the patience – Atlantic0 Nov 17 '16 at 17:57
  • Ok, that will not work. On the admin pages of you Slack app the redirect Uhl needs to point to your website/script that handlers the oath process. E.g. Www.myserver.net/ – Erik Kalkoken Nov 17 '16 at 18:01
  • The url with the slack.com/oath/... Needs to be called from you website/script. Usually it's a link from the add to slack button on your webpage – Erik Kalkoken Nov 17 '16 at 18:03