phallstrom / slackistrano

Slack integration for Capistrano deployments.
MIT License
374 stars 74 forks source link

Supporting non-legacy/deprecated Slack API #97

Open jrochkind opened 5 years ago

jrochkind commented 5 years ago

I believe that both of the methods in the README for Slack integration are currently legacy/deprecated. the Legacy incoming webhooks, and... I'm not totally sure what the README is talking about with regard to "Configure your Slack's Slackbot (not Bot)", but I believe it's also legacy, not sure if it's Legacy Bot Users or something else.

It's hard to find docs on the API slackistrano is currently actually using, cause they are legacy/deprecated according to Slack. This makes it hard for someone wanting to use slackistrano to figure out how to follow the instructions "Configure your Slack's Incoming Webhook" or "Configure your Slack's Slackbot (not Bot)" -- even if they are still supported as legacy, which they may stop being supported.

The new way to do it is with Slack Apps, which you can easily create a custom one just for your workspace.

While there are 'incoming webhooks' available for Slack Apps, they are tied to a single channel (unlike the legacy webhooks that allowed runtime specifying of channel/username). In my own slackistrano use, I decide what channel to send to at runtime based on success/failure and/or environment/stage. So that wouldn't be suitable.

But instead, I think you can just use easily use the postMessage call. To auth, you need an OAuth token -- which I think you can get for your workspace when creating a local "slack app", and then you just provide it in an Authorization header

It took me a while to figure out what's going on currently with the Slack API, and what the simplest API usage could be to support what slackistrano needs -- so I figured I'd document what I think I've figured out here.

Note this is somewhat different than #96, which is about message format. With the legacy integration APIs slackistrano is currently using, you can use the legacy message format (which you are now), or the new blocks format. (I tried it). If you are using the new "Slack Apps" API, can you still use the legacy message format? Not sure, but I think so! Although Slack would prefer you use the new 'blocks' formatting.