Slack Incoming Webhooks
Create a Slack webhook, save it as a relay target, and test delivery.
3 min read
Use this guide to send endpoint traffic to Slack.
Purpose#
Use this guide to:
- Create a Slack incoming webhook.
- Save Slack as a relay target.
- Attach the target to an endpoint destination.
- Test delivery.
Before you start#
- Make sure that you have permission in the Slack workspace to create an incoming webhook.
- Select the Slack channel that receives the messages.
- Make sure that you can access
Relay targetsandEndpoints.
Procedure#
1. Create webhook URL in Slack#
- In the Slack app settings, enable
Incoming Webhooks. - Create a webhook for the channel.
- Copy the URL. Use
https://hooks.slack.com/services/...for Slack. GovSlack useshttps://hooks.slack-gov.com/services/....
2. Add Slack relay target#
- Open
Relay targets. - Select
Add target. - Select
Slack webhook. - Paste the Slack URL into
Slack webhook URLand save.
The URL must use the Slack incoming webhook format on hooks.slack.com or hooks.slack-gov.com.
3. Attach Slack target to endpoint#
- Open the endpoint create page or the endpoint edit page.
- In
Outputs, select the Slack target. - If the generated Slack text or the template body sections need Markdown, keep
Enable Markdown formattingselected. It is on by default. - Save the endpoint.
4. Send test delivery#
- On
Relay targets, selectSend testfor the Slack target. - Make sure that the message appears in the Slack channel.
- To see the test result, look for
Test accepted(TEST_ACCEPTED) in Activity.
Mentions and escaping#
- PayloadRelay escapes
&,<, and>in the Slack text that it creates from the payload. So a payload value cannot mention@channel,@here, or a user. - In a message template with
Enable Markdown formattingon, PayloadRelay also escapes these characters in each value that a placeholder inserts. A mention such as<!channel>works only in the literal text that you write in the template. - With
Enable Markdown formattingoff, the template sections are plain text. PayloadRelay escapes the complete fallback text. - The title of a template goes into a plain-text header block. Slack does not apply Markdown to the title.
- PayloadRelay does not change the text of an incoming payload that already has
text,blocks, orattachments. That payload controls its own formatting and its own mentions. If it has nomrkdwnfield, PayloadRelay adds one fromEnable Markdown formatting.
Expected result#
- The Slack target is listed, and you can select it as an endpoint destination.
- The test traffic and the live endpoint traffic go to the selected channel.
- Without a custom message template, PayloadRelay sends the incoming payload as Slack text. With a custom message template, PayloadRelay sends Slack attachment blocks with a top-level text fallback.
Common issues and fixes#
- URL rejected: make sure that the URL uses
hooks.slack.com/services/...orhooks.slack-gov.com/services/.... - No message in Slack: make sure that the target is attached to the endpoint, and that the webhook is active.
- Formatting issues: change
Enable Markdown formattingfor a generated message. Slack-nativeblocksorattachmentsin the incoming payload control their own formatting.