Send a direct message in Slack
Learn how to design an action that sends a direct message in Slack.
In this tutorial, we'll take a closer look designing an action that sends a direct message to the selected user in Slack. We'll start creating an app and then proceed to creating an action from scratch.
You can use such an action to run your workflows. For example, when a new deal is assigned to your account executives or a new ticket is escalated in your support system, you can set your workflows to execute this action automatically.
If you are looking to add the capability to send a direct message to your action, you can proceed to adding components step.
Step 1. Create a new app
- Go to My apps page and add a new app. Select Start from scratch option.
- Enter a name for your app. You can optionally enter a description and upload an icon.
Step 2. Add Slack connection
- Go to App settings tab of your app and create a new connection.
- Select Slack as connection type and select your Slack workspace.
If you do not see any Slack workspace, it means that your Actioner account is not connected with any Slack workspace. Visit connect to Slack page to learn how you can connect your Slack workspace.
Step 3. Create a new action
- Go to Actions tab and add a new action.
- Give a name to your action, such as Send a direct message. You can optionally add a description, tags or aliases.
Step 4. Add components to your action
- Add a new input:
message
. It is a text input. Enable Mandatory option.
- Add another input:
user
. It is a single select component. Enable Mandatory option.
- Add a new Slack request. Select List users method and give
ListSlackUsers
name to your request. Then, select your Slack connection.
- Go to
user
input and add below values to display and identifier fields:
Display: {{request.ListSlackUsers.response.users.map(c=>c.name)}}
Identifier: {{request.ListSlackUsers.response.users.map(c=>c.id)}}
- Add a new Slack request. Select Send a direct message method and give
SendDirectMessage
name to your request. Then, select your Slack connection.
- Enter below to Message field on Markdown block:
{{input.message}}
- Go to Channel field, select Dynamic option from the gear button and enter below:
{{input.user}}
- Add
SendDirectMessage
Slack request to Run steps on Inputs tab.
- Apply changes to your action. Make sure to mark it as Enabled while applying changes.