Actions
Post Message Response

Post a message to slack when you receive a blockActionInteraction event with a response_url. For example, if you publish a message with a button and the user clicks the button, you can use this action to post a message in response to the user’s click.

There are three different types of responses you can send:

  • Ephemeral: A message that only the user who clicked the button will see and do not persist in the channel or across apps. This is the default.
  • In Channel: A message that will be published to the channel and will persist across apps. Everyone in the channel will see the message.
  • Update: Update the original message with new text or blocks.

Here’s a table with the different message params you can use for each type of response (text and blocks are supported for all three types of responses)

ParamEphemeralIn ChannelUpdate
replace_originalfalsefalsetrue
response_typeundefined"in_channel"undefined

Params

keyrequired
string

A unique string. Please see the Keys and Resumability doc for more info.

messagerequired
object
textrequired
string

The formatted text of the message to be published, formatted as mrkdwn.

blocks
object

You can use blocks to create a rich message with images, buttons, and more.

You can either pass in a JavaScript object or use JSX Slack to create blocks. We highly recommend using JSX Slack as it’s much easier to read and write. See the block example to see it in action.

For full details on Slack blocks, see the Slack API docs.

response_type
'in_channel' | undefined

Set the 'in_channel' response type to publish the message to the channel. If not specified, the message will be ephemeral.

replace_originalDefault: "false"
boolean

Set to true to update the original message with new text or blocks. If not specified, the message will be ephemeral or published to the channel.

delete_originalDefault: "false"
boolean

Set to true to delete the original message.

thread_ts
string

The “timestamp ID” of the message to reply to. If not specified, the message will be published as a new thread.

Response

okDefault: "true"
boolean

Always true; non-ok responses will halt the workflow run and throw an error.

Example Workflows

import { Trigger } from "@trigger.dev/sdk";
import * as slack from "@trigger.dev/slack";
import { z } from "zod";

new Trigger({
  id: "slack-block-interaction",
  name: "Slack Block Interaction",
  on: slack.events.blockActionInteraction({
    blockId: "issue.action.block",
    actionId: ["status-blocked", "status-help", "rating"],
  }),
  run: async (event, ctx) => {
    if (!event.response_url) {
      return;
    }

    // Post an ephemeral message
    return slack.postMessageResponse(
      "Added a comment to the issue",
      event.response_url,
      {
        text: `You rated your day ${action.selected_option?.value} stars`,
        replace_original: false,
      }
    );

    // Post an a message to the channel
    return slack.postMessageResponse(
      "Added a comment to the issue",
      event.response_url,
      {
        text: `Another rating of ${action.selected_option?.value} stars!`,
        response_type: "in_channel",
      }
    );
  },
}).listen();