dispatch icon indicating copy to clipboard operation
dispatch copied to clipboard

slack plugin integration

Open csetarun2 opened this issue 4 years ago • 8 comments

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)

csetarun2 avatar Sep 20 '22 14:09 csetarun2

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.

kevgliss avatar Sep 20 '22 16:09 kevgliss

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

  • I have created slack app, slack bot and have give all the permission which has mentioned in the docs, also the slash commands
  • In the settings -> projects -> plugin , have configured both slack communication, slack alert using the api-bot-token

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

  • Then I have logged into dispatch container and ran, dispatch slack organization project

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

csetarun2 avatar Sep 26 '22 16:09 csetarun2

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

kevgliss avatar Sep 26 '22 17:09 kevgliss

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

csetarun2 avatar Sep 27 '22 17:09 csetarun2

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.

kevgliss avatar Sep 27 '22 17:09 kevgliss

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'}

csetarun2 avatar Sep 28 '22 12:09 csetarun2

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.

kevgliss avatar Sep 28 '22 22:09 kevgliss

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

csetarun2 avatar Oct 22 '22 13:10 csetarun2