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

Add support for Slack apps instead of (or in addition to) "Incoming Webhooks" #25

Open
bclarkejr opened this issue Sep 9, 2021 · 0 comments

Comments

@bclarkejr
Copy link
Contributor

bclarkejr commented Sep 9, 2021

Slack has deprecated the "Incoming Webhooks" feature and is now encouraging everyone to switch to using Slack apps instead. Details are mentioned in the description here: https://slack.com/apps/A0F7XDUAZ-incoming-webhooks

Here is a simple example I wrote to post messages using a Slack app and the Slack Rest API:

import os
import urllib3
 
http = urllib3.PoolManager()
# Note you will need to grab this and set it as a system environment variable
# Or, presumably, the payload coming from Splunk
token = os.environ['SLACK_BOT_TOKEN']
 
r = http.request(
    'POST',
    'https://slack.com/api/chat.postMessage',
    headers = { 'Content-Type': 'application/json', 'Authorization': f'Bearer {token}' },
    body = '{ "channel":"#general", "text":":slack: Web API test." }'
)
 
print(str(r.read()))

Here are the steps that I think will be needed to support this:

  1. Add a new configuration option to the alert action called SLACK_APP_OAUTH_TOKEN or something similar.
  2. Update the code to branch on whether a webhook or oauth token is provided. Or potentially release a new major version that breaks the incoming webhook configuration.
  3. Update logic related to using a Slack app.
  4. Update documentation to point to Slack app documentation.

If this isn't completed in the next few months (which is our timeline for switching to Slack apps), then I will come back and update myself. However, I'm filing this request early to see if anyone else wants to pick it up before I can.

Let me know if you need any more information.

Thanks!

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

No branches or pull requests

1 participant