Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple channel support for Slack apps #368

Closed
wants to merge 2 commits into from

Conversation

jeromecornet
Copy link

With the way slack apps work now, one of the limitations of the slack integration is that the webhook is specific to a single channel, so you need to configure slack apps with one webhook per channel you can post on.

Right now, specifying one or more channels in a check configuration does nothing with such an integration, because slack will post to the channel that's associated with the webhook, not the channel specified in the payload.

This PR tweaks the configuration so the slack_webhook_url config can either take a string (for the current behavior) or a mapping of slack channel -> webhook URL in form of a hash.

When sending the webhook, the new code will check whether a url is configured for this channel before sending it.

@ankane
Copy link
Owner

ankane commented Dec 9, 2021

Hey @jeromecornet, thanks for the PR! If you use the legacy webhook integration (linked in the readme), it should be possible to post to any channel.

This approach looks pretty straightforward, but I'm hoping there's a way to set things up where channels don't need to be configured individually (still need to look into it).

@jeromecornet
Copy link
Author

Thanks @ankane . I haven't been able to configure an old-style integration with a recently created slack workspace, so this pr the best I could come up with to work around that.

That said, if there is a simpler way I'm all for it 😊

ankane added a commit that referenced this pull request Dec 10, 2021
@ankane
Copy link
Owner

ankane commented Dec 10, 2021

Hey @jeromecornet, just tried the legacy webhook integration with a new workspace and it still seems to work.

I also added a slack_oauth_token option that takes a bot token. It requires the chat:write and chat:write.public scopes, and for private channels, you need to invite the app with /invite @blazer. If you have some time, please try it out.

@jeromecornet
Copy link
Author

Thanks @ankane your approach is much cleaner especially because it avoids per-channel configuration which is much better.

For some reason I could not attach the legacy webhooks integration to my workspace or didn't understand the instructions as the webhook url I got was channel-specific and not workspace-specific.

That said, I tested your unreleased version on a an app with the oauth token by granting it the 2 permissions and it works well.

Thanks for looking into it and implementing it, I'll just close this PR as it's not the right approach

@ankane
Copy link
Owner

ankane commented Dec 11, 2021

Great, thanks for checking! Will probably make this the recommended approach in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants