Skip to main content
All CollectionsIntegrate EverythingSlack
Slack Steps Integration (Bot)
Slack Steps Integration (Bot)

Integrate Slack with Torq's bot to trigger workflows, message channels, run commands, and customize branding—all inside Slack.

Updated over a month ago

The Slack steps integration adds the Torq bot (Torq app) to your workspace, which enables you to perform common Slack actions as part of your workflows and trigger Torq workflows directly from the Slack CLI by mentioning (@) the Torq bot or sending a message directly in the Torq app channel.

Messages sent from Torq to Slack are done via the bot. By default, the bot is named Torq and uses the Torq logo. You can easily replace the name and logo to match your company's branding.

Slack steps can be used for posting textual or image updates inside Slack conversations and channels, providing multiple-choice questions to specific users or channels, and later referring to the chosen responses in the workflow run.

To use Slack steps in a workflow, you'll need to create a Slack steps integration, customize your Torq bot, and add the steps to a workflow. We'll show you how to use the most common Slack steps.

Reauthorize the Integration

You should reauthorize the integration when you need to authorize new scopes or re-install an existing integration.

  1. Go to Build > Integrations > Steps > Slack.

  2. Click Edit for the integration you want to reauthorize.

  3. Click the Reauthorize button and when prompted, then click Allow.

Screenshot of reauthorizing the Torq Bot integration in Torq.

Create a Slack Integration

Perform these steps in Torq.

  1. Go to Build > Integrations > Steps > Slack, and click Add.

  2. Enter a meaningful name for the integration and click Add.

  3. By default, mentions of the Torq bot and direct messages in the bot channel create Torq events that can be used to trigger workflows. Unselect the Receive events from Slack app mentions checkbox if you don't want to trigger Torq workflows from Slack.

  4. Select the Slack workspace to which you want to add the Torq bot (Torq app) and click Allow to grant Torq permission to your workspace.

Customize the Torq Bot

Screenshot of adding the Torq to a Slack workspace.

You can change the Torq bot's name and logo. The bot's name and logo appear in Slack when a message is sent to a user or channel.

Change the Bot's Name

By default, the name of the bot user is Torq.

  1. Select the Torq app from the Apps section and then select Configuration from the menu that appears when you click the bot name at the top of the screen.

    Screenshot of changing the name of the bot.
  2. Click Edit in the Bot User section and enter the name you want to appear when messages are sent from Torq to Slack, for example, Security Team.

    Screenshot of changing the name of the bot.

Change the Bot's Logo

You can also change the bot logo, which can only be done on an individual step level by adding the logo image file as an input parameter.

If you want to change the app logo, it's recommended that you configure each Slack message/question step with the logo file and save them as custom steps. This way, you won't have to add the image file each time you use one of those steps.

You cannot change the logo for the Slack steps listed below. If you use these steps, the Torq logo will be displayed in the message.

  • Send snippet

  • Send Slack attachment message

Screenshot of changing the bot logo.

Add the Torq App to a Channel

To communicate with the bot in a channel, you need to add the Torq app to the channel. In most cases, if you mention the bot and it is not part of the channel you'll be prompted to add the bot. You can add the bot thusly:

  • Use the Add apps to this channel Slack slash command.

  • Click + Add this app to a channel in the app menu.

Screenshot of adding the app to a channel in Slack.

Run a Torq Workflow from Slack

When you have a Slack steps integration set up, you can run a Torq workflow directly from Slack:

  1. Sign in to your Torq workspace: /torq signin.

  2. Run a workflow: /torq run.
    Select the workflow you want to run. You can see the name of the workspace in which the workflow will run.

  3. You can also specify the workflow name in the run command: /torq run

Screenshot of running a Torq workflow from Slack.

Switch to a Different Workspace

If the Slack workspace is associated with integrations in more than one Torq workspace and you want to run the workflow in a different workspace:

  1. In Slack, run: /torq signout.

  2. In Torq, switch to the workspace you want to log in to in Slack.

  3. In Slack, run: /torq signing.

Slack Steps

You can find information about some of the main Slack steps below.

There are several important things to keep in mind when building a workflow that has the Torq bot communicating with users.

  • The RECIPIENT field needs to include the hashtag symbol (#) as a prefix to any channel name, for example, #{{ $.event.channel }}.

  • If you want to mention a user in the message, use the following syntax: <@##{{ $.event.user }}>.

Ask a Question

This step enables you to send a question to a user or a channel with responses that you configure. For example, if you're confirming a suspicious login attempt, you can send the user a message asking if they attempted the login, and the user can click Yes or No. You might want to send a question to a channel, for example to a channel of managers to approve a request, and any member of the channel can respond.

In this example, you send a question to a user that reset their Okta password.

Screenshot of the Slack Ask a Question step in a workflow.

Send Block Form

This step enables you to send a form to a user or a channel. A form can include any of the supported interactive components: datepickers, checkboxes, user text input, multiple option selections, and many more. Use a form to collect all the information you need in one interaction and in the formats that best suit the type of information you’re trying to collect.

A numerical block_id is added automatically to each step, but you may also rename the block_id with a meaningful and unique name so it remains static even if the block order changes.

  1. Use the Slack Block Kit Builder to create the form you want to send.

    Screenshot of building a block in Slack.
  2. Copy the form payload to the BLOCKS field in the Send Block Form step. Click the cogwheel icon to add the optional timeout parameter. In this example, the user is asked to provide information to schedule a retry for a URL scan that didn't finish on time.

    Screenshot of adding the block JSON to the block field in a Slack step.
  3. ​By default, Cancel and Submitbuttons will be automatically added at the bottom of your form. If the user clicks Cancel, none of the information the user may have entered in the form will be included in the step output. 🔔 Important Since the Submit and Cancel buttons are the ones used for the submission of the form, other buttons or dispatch actions won't have this functionality. This means these components won't provide any information if included in the form.

    Screenshot of a Slack message sent by the Torq bot.
  4. You can add the RESPONSES optional parameter to replace the Cancel and Submit buttons with any number (up to 25) of buttons with customizable titles at the bottom of the form. The step output will include the button title the user clicks and any information entered in the form. Clicking any custom buttons at the bottom of the form will essentially submit the form.

    Screenshot of adding the optional parameter Responses to a Slack step.
  5. The workflow is on hold until the user submits or cancels the form or until the form times out.

  6. After the user submits or cancels the form (or the form times out), the form is no longer available, and only a summary of the form is presented.

    Screenshot of the bot message in Slack when there is a form timeout.
  7. You can choose not to display the summary by adding the optional POST_RESPONSE_MESSAGE parameter and setting it to false.

    Screenshot of adding the optional parameter Post Response Message in a Slack step.
  8. The Send Block Form step output contains the user response and the identity of the responding user. This information can be used to direct your workflow and for reference in other workflow steps.

    Screenshot of accessing the output of a Send Block Form step in a subsequent step.
  9. Find the path to the user response by typing $. and selecting Select from tree mode from the autocomplete options. Search for the block_id in the context tree to access the user response easily.

    Screenshot of referencing a JSON path from the tree mode.

Send a Message/Question to a Thread

When you're using a Slack step that sends a message/question to a user or channel, you can add the THREAD_TS input parameter (optional), which will send the message/question in a thread of the parent message. The value for the THREAD_TS parameter should be #{{ $.message_ts }} of the parent message. For example, if you use the step Ask a question, wait for a response, and then want to respond in a thread based on the answer, the value would be #{{ $.ask_a_question.message_ts }}.

Create a channel

This step will create a new Slack channel. A common use case is to create a channel dedicated to investigating an incident as part of a workflow.

Invite users to a channel

This step will invite the specified users to the specified channel.

Create a Workflow in Torq

Create a basic Hello World workflow that will receive an event from a message that mentions the Torq bot and then send a reply message to the channel and mention the user that sent the original message.

  1. Go to the Workflows page and click Create Workflow.

  2. Type a meaningful name for the workflow, such as Slack Events Hello World.

  3. Click the trigger icon and then the Slack integration.

  4. Select the integration you created.

  5. In the Steps Library, search for Slack and add the step Send a message.

  6. Configure the step.

    1. Rename the step to something meaningful, such as, Acknowledge message.

    2. In the RECIPIENT field, enter ###{{ $.event.channel }}.

    3. In the MESSAGE TEXT field, enter a message that mentions the user who sent the original message. In our example, the message mentions the user and quotes the text that they sent to the bot: <@##{{ $.event.user }}>, I got your message: ##{{ $.event.text }}

  7. Go to Slack, and from the command line, mention the Torq bot (@Torq) and type Hello World.

Wait a few seconds, and you should receive the reply message to the channel you mentioned the bot in.

Video tutorial

Did this answer your question?