This tutorial demonstrates how to send a message to Slack using a webhook external target and a rule.
Prerequisite
- You have an Amity user with administrator role
Step 1: Create a Slack App
- Follow the instructions in Incoming Webhooks article to create a Slack app and enable incoming webhooks.
- Create an Incoming Webhook. This will generate a Webhook URL.
- Copy the Webhook URL to your clipboard.
Step 2: Create a webhook external target
What is a webhook? A webhook allows you to send notifications via HTTP to other apps.
- Navigate to Settings and click External Targets under Administration.
- Click on the grey plus button.
- Set the Name field to "Slack Channel".
- Paste the Webhook URL into the URL field.
- Click Save
Step 3: Test the webhook
- Navigate to Settings and click External Targets under Administration.
- Click on the external target you want to test.
- In the Actions panel, select Send Test.
- Enter the following in the JSON body:
{
"text":"Hello world"
} - Click Send.
A notification will appear at the bottom when the test is sent successfully.
Open your Slack channel. The test message should look like the following:
Step 4: Create a rule
What is a rule? Rules allow you to automatically perform actions when certain conditions occur.
- Navigate to Settings and click Rules under Automation.
- Click on the grey plus button.
- Set the Name field to "Send message to Slack"
- In the Conditions panel, set the Trigger to when an account is created.
- In the Recurrence panel, uncheck the checkbox.
- In the Actions panel, set the Type to Send to an external target
- Select the "Slack Webhook" external target.
- Enter the following in the JSON Body editor:
{
"text": "New account created: {{account.name}}"
} - Click the Create button.
Step 5: Test the rule
To see the rule in action, you need to create an account. This will trigger the rule to send a message to Slack.
- Navigate the Accounts app
- Click on the grey plus button.
- Set the name to "Slack Webhook Demo".
- Click Save.
Within 30 seconds, the message will appear in the channel you associated with Slack app.
Want to learn more?
For more detailed information on using external targets in Amity, check out these articles:
Comments
0 comments
Please sign in to leave a comment.