Netflix / dispatch

All of the ad-hoc things you're doing to manage incidents today, done for you, and much more!
Apache License 2.0
5k stars 494 forks source link

slack plugin integration #2539

Closed csetarun2 closed 1 year ago

csetarun2 commented 2 years ago

I have configured all mentioned details still getting errors while creating issues.

when I try to create incident its throwing this error in docker log File "/usr/local/lib/python3.9/site-packages/slack_sdk/web/base_client.py", line 309, in _urllib_api_call return SlackResponse( File "/usr/local/lib/python3.9/site-packages/slack_sdk/web/slack_response.py", line 189, in validate raise e.SlackApiError(message=msg, response=self) slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: https://www.slack.com/api/users.lookupByEmail) The server responded with: {'ok': False, 'error': 'invalid_auth'} image

other one is this dispatch server slack default dispatch slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: https://www.slack.com/api/apps.connections.open) The server responded with: {'ok': False, 'error': 'not_allowed_token_type'} ERROR:asyncio:Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7ff2fd5bd8e0>

can anyone check and help me to configure slack to dispatch, please share any ref video/docs (apart from regular one)

kevgliss commented 2 years ago

I would double-check that your token strings don't have any whitespace or are malformed as that is generally the issue when an 'invalid_auth' error is raised.

csetarun2 commented 2 years ago

Thanks @kevgliss for your reply, The same token is working fine when I generally check online slack api, I have followed these steps, Please correct me if Im wrong

can you check the below image mapping , Am I correctly mapping bot creds to dispatch, is socker mode api-token is same as oauth-token, image

(can you please check the image, I feel I was doing some wrong there, please suggest if I did mistake)

kevgliss commented 2 years ago

Two things I would check:

Make sure you have users:read.email oauth scope: https://api.slack.com/methods/users.lookupByEmail#email-addresses

Make sure you do not have any other controls (maybe IP whitelisting enabled) as suggested by: https://api.slack.com/methods/users.lookupByEmail#errors

csetarun2 commented 2 years ago

Thanks @kevgliss , now I m getting below error

_message incident.conversation.channel_id, AttributeError: 'NoneType' object has no attribute 'channel_id'

image image in the project settings -> notifications -> slacknotification->targetI have given dispatch group is that fine

kevgliss commented 2 years ago

Hmm, I'm not entirely sure. But make sure that the dispatch ticket plugin is enabled (if you're not using jira). I see a message that it's not created and I wonder if that's why that conversation is not being associated.

csetarun2 commented 2 years ago

Thank you so much @kevgliss as per your suggestion added, finally I'm getting messages into the slack , these steps are not there any doc to refer and conf easily :)

  1. is there anywhere do I need to mention some common group name, Its creating new group for every incident, how should I avoid this

image image

  1. If I configure gsuite, will this error will get resolve ? currently I have not configured any gmail plugin, is this related to google-gmail-email plugin error WARNING:dispatch.incident.messaging:Participant welcome email not sent, not email plugin configured. ERROR:dispatch.plugins.dispatch_slack.service:SlackError. Response: {'ok': False, 'error': 'not_in_channel'} Endpoint: chat.postMessage kwargs: {'channel': 'general', 'text': 'Incident Notification', 'blocks': [{'type': 'divider'}, {'type': 'section', 'text': {'type': 'mrkdwn', 'text': '<http://localhost:8000/default/incidents/dispatch-default-dispatch-39?project=dispatch|dispatch-default-dispatch-39 Incident Notification>\nThis message is for notification purposes only.'}}, {'type': 'actions', 'elements': [{'action_id': 'subscribe-user', 'type': 'button', 'text': {'type': 'plain_text', 'text': 'Subscribe'}, 'value': 'default-39'}, {'action_id': 'invite-user', 'type': 'button', 'text': {'type': 'plain_text', 'text': 'Join'}, 'value': 'default-39'}]}, {'type': 'section', 'text': {'type': 'mrkdwn', 'text': 'Title\ndispatch1'}}, {'type': 'section', 'text': {'type': 'mrkdwn', 'text': 'Description\ndispatch1'}}, {'type': 'section', 'text': {'type': 'mrkdwn', 'text': 'Status - Active\nThis incident is under active investigation.'}}, {'type': 'section', 'text': {'type': 'mrkdwn', 'text': 'Type - incident\nincident'}}, {'type': 'section', 'text': {'type': 'mrkdwn', 'text': 'Priority - Critical\nCritical'}}]} ERROR:dispatch.decorators:The request to the Slack API failed. (url: https://www.slack.com/api/chat.postMessage) The server responded with: {'ok': False, 'error': 'not_in_channel'}
kevgliss commented 2 years ago

Thank you so much @kevgliss as per your suggestion added, finally I'm getting messages into the slack , these steps are not there any doc to refer and conf easily :)

I will create a ticket to either have a reasonable default here (e.g. dispatch ticket) or add more information to the documentation.

  1. is there anywhere do I need to mention some common group name, Its creating new group for every incident, how should I avoid this

By default, incidents always create new channels, and we don't plan on making this optional. If you're interested in something more lightweight cases could be an option. But this relativity new feature does not yet support slack notifications (will likely be supported Q42022 or Q12023). Cases will not create a channel for every case and will rely on a central channel with communication done under the notification as a thread.

If I configure gsuite, will this error will get resolve ? currently I have not configured any gmail plugin, is this related to google-gmail-email plugin error

Are you referring to the warning? Or the slack error beneath? The warning will not go away until configured but the error not_in_channel means that the dispatch app was not invited to whatever channel you have configured which is general in this case.

csetarun2 commented 1 year ago

Thanks @kevgliss for your support to integrate slack into dispatch application :)