Skip to main content

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

  1. Go to My apps page and add a new app. Select Start from scratch option.

Add a new app

  1. Enter a name for your app. You can optionally enter a description and upload an icon.

Create an app

Step 2. Add Slack connection

  1. Go to App settings tab of your app and create a new connection.

Add connection

  1. Select Slack as connection type and select your Slack workspace.

Add Slack connection

Info

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

  1. Go to Actions tab and add a new action.

Add action

  1. Give a name to your action, such as Send a direct message. You can optionally add a description, tags or aliases.

Create Send a direct message action

Step 4. Add components to your action

  1. Add a new input: message. It is a text input. Enable Mandatory option.

message input

  1. Add another input: user. It is a single select component. Enable Mandatory option.

user input

  1. Add a new Slack request. Select List users method and give ListSlackUsers name to your request. Then, select your Slack connection.

ListSlackUsers request

  1. 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)}}

user input sources

  1. Add a new Slack request. Select Send a direct message method and give SendDirectMessage name to your request. Then, select your Slack connection.

SendDirectMessage request

  1. Enter below to Message field on Markdown block:
{{input.message}}

SendDirectMessage markdown field

  1. Go to Channel field, select Dynamic option from the gear button and enter below:
{{input.user}}

SendDirectMessage User field

  1. Add SendDirectMessage Slack request to Run steps on Inputs tab.

Add SendDirectMessage to Run steps

  1. Apply changes to your action. Make sure to mark it as Enabled while applying changes.

Apply changes to SendDirectMessage