Guide to integrate Slack App for sending notification to user DM or channels in any workspace.
Sign in to Slack.
Select Create an App "From scratch"
Give your App a suitable name
Assign OAuth Scopes to App
Give scoped access using OAuth V2 method
scope | obligation | description | |
---|---|---|---|
chat:write | mandatory | Post messages in approved channels & conversations. At a minimum your app needs this scope to send notifications to a Slack workspace. | |
im:write | mandatory | Send direct messages to users in Slack | |
chat:write.public | mandatory | Send messages to public channels your Slack app isn’t a member of. If your app doesn’t have this scope, you’ll need to use the conversations.joins method to join a public channel before sending it messages. | |
users:read | optional | To send DM to user’s DM | |
users:read.email | optional | To send DM to user using their email id |
Give access to a particular channel / user using incoming webhook
incoming_webhook
scope, your user can connect to a particular channel (public, private, or even the direct message channel for that individual user) they have access to in their Slack workspace.#announcement
channel.
Sending a direct message
user_id
or email
along with bot access token in user profile. You can pass this information in a json format using user.add_slack
method as below:Sending to a channel
distinct_id
as channel_<channel_name>
so it’s easy for you to remember and pass in your workflow calls whenever you want to send message on a slack channel.Refer below example to add slack channel shown in above screenshotSending message using incoming webhook
user.add_slack
method as below:incoming_webhook->url
, or the access_token
with one of these keys: channel_id
, user_id
, or email
. If there are multiple keys in user.add_slack()
call, the order of precedence is as follows:
incoming_webhook->url
> channel_id
> user_id
> email
. e.g., if your add_slack argument is as follows:
{"incoming_webhook": { "url": "https://hooks.slack.com/services/TXXXX/BXXXX/XXXXXXX" } }