Slack
Send Slack messages with Courier by creating a Slack app, configuring it in Courier, designing a notification template, and delivering messages via the Send API. This guide covers setup, message targeting, advanced features, and troubleshooting.
Prerequisites
To get started, you’ll need:
What you’ll do:
- Add the Slack integration in Courier
- Create and configure a Slack app
- Design a notification template
- Send a test message
Helpful Resources:
Step-by-Step: Send Your First Slack Message
Add Slack Integration in Courier
Once logged in to Courier, go to the Integrations page and select Slack. Click “Install” to add the integration.
Courier Slack Integration
Create and Configure a Slack App
- Go to the Slack Apps page and click “Create an App”.
- Choose “From scratch”, give your app a name, and select your development workspace.
- Under “OAuth & Permissions”, add these Bot Token Scopes:
chat:write
,im:write
,users:read
,users:read.email
. - Click “Install App to Workspace” and authorize.
- Copy the Bot User OAuth Access Token (starts with
xoxb-
).
Slack OAuth Scopes
Design a Slack Notification Template
Go to the Courier Assets page and click + New > Message Template. Select Slack from your list of integrations. In the sidebar, click the newly added Slack block to open the Slack template editor. Add your desired message content to the template.
Send a Test Message
Click Preview, then select Create Test Event. Enter your bot token in the Access Token field. Click Send—your message should appear in Slack!
Message Targeting Reference
Courier supports sending Slack messages to users and channels in several ways. Here are the most common targeting methods:
Order of Precedence: If you provide more than one of channel
, user_id
, or email
, Courier will use them in this order: channel > user_id > email.
Advanced Features & Customization
Courier supports a variety of advanced Slack features for more control and interactivity. Here are the most useful options:
Provider Overrides
You can override the payload sent to Slack’s chat.postMessage using the providers.slack.override.body
field. This is useful for advanced formatting, interactivity, and threading.
Unfurl Links
Slack Blocks (Block Kit)
Send rich, interactive layouts using Slack blocks:
Design and preview your blocks visually with the Slack Block Kit Builder.
Replying in a Thread
To reply to a thread, set the thread_ts
value:
Mentioning Users
Mention a user in your message using <@USER_ID>
syntax in your template:
You can also use variables for dynamic mentions.
Slash Command Responses
If responding to a Slash Command, use the response_url
as an incoming webhook:
Set override.slack.body.response_type
to in_channel
or ephemeral
as needed.
Incoming Webhooks
You can send messages to a channel using a Slack Incoming Webhook:
Updating Notifications
To update a previously sent Slack message, set a “replacement key” (usually ts
) in your notification template’s Slack channel settings. Courier will use this key to update the message instead of posting a new one.
Troubleshooting & Resources
Common Issues & Solutions
-
Missing or incorrect Slack scopes:
- Double-check your app has all required scopes (
chat:write
,im:write
,users:read
,users:read.email
, andchat:write.public
for channels). - Reinstall your Slack app after updating scopes.
- Double-check your app has all required scopes (
-
Bot not invited to channel:
- Make sure your Slack app/bot is a member of the channel you want to message.
-
Invalid or missing tokens:
- Ensure you are using the correct Bot User OAuth Access Token (starts with
xoxb-
). - Never use a user token or an expired token.
- Ensure you are using the correct Bot User OAuth Access Token (starts with
-
Permission errors or message not delivered:
- Check the Courier Message Logs for error details and troubleshooting tips.
-
User or channel not found:
- Double-check the email, user_id, or channel ID. For channels, copy the ID from the Slack URL.
Helpful Links
- Courier API Reference
- Courier Message Logs
- Slack API Documentation
- Slack Block Kit Builder
- Slack Scopes & Permissions
If you’re still stuck, reach out to Courier support or visit the Slack API community forums for more help.