# Send Message Using Block Kit — Bot for Slack

> Send a message using Slack's Block Kit UI framework to a channel, group or user (Bot). See postMessage or scheduleMessage docs here

- Key: `slack_bot-send-block-kit-message`
- Type: Action (Write)
- Version: 0.0.2
- App: Bot for Slack (`slack_bot`) — https://pipedream.com/apps/slack-bot.md
- This page (HTML): https://pipedream.com/apps/slack-bot/actions/send-block-kit-message
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/slack_bot/actions/send-block-kit-message/send-block-kit-message.mjs

## Description

Send a message using Slack's Block Kit UI framework to a channel, group or user (Bot). See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `username` | `string` | No | Optionally customize your bot's user name (default is Pipedream). Must be used in conjunction with as_user set to false, otherwise ignored. |
| `icon_emoji` | `string` | No | Optionally provide an emoji to use as the icon for this message. E.g., :fire: Overrides icon_url. Must be used in conjunction with as_user set to false, otherwise ignored. Options are loaded from the connected account. |
| `icon_url` | `string` | No | Optionally provide an image URL to use as the icon for this message. Must be used in conjunction with as_user set to false, otherwise ignored. |
| `post_at` | `integer` | No | Messages can only be scheduled up to 120 days in advance, and cannot be scheduled for the past. The datetime format should be a unix timestamp (e.g., 1650507616, see here for help with this format). |
| `include_sent_via_pipedream_flag` | `boolean` | No | Defaults to true, includes a link to the workflow at the end of your Slack message. |
| `metadata_event_type` | `string` | No | The name of the metadata event |
| `metadata_event_payload` | `string` | No | The payload of the metadata event. Must be a JSON string e.g. {"key": "value"} |
| `conversation` | `string` | Yes | Select a public or private channel, or a user or group Options are loaded from the connected account. |
| `blocks` | `string` | Yes | Enter an array of structured blocks as a URL-encoded string. E.g., [{ "type": "section", "text": { "type": "mrkdwn", "text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://pipedream.com\|this is a link>" }}] Tip: Construct your blocks in a code step, return them as an array, and then pass the return value to this step. |
| `text` | `string` | No | Optionally provide a string for Slack to display as the new message notification (if you do not provide this, notification will be blank). |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "slack_bot",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "slack_bot-send-block-kit-message",
  arguments: {
    username: "Bot Username",
    icon_emoji: "Icon (emoji)",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "slack_bot-send-block-kit-message",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    slack_bot: { authProvisionId: "apn_xxxxxxx" },
    username: "Bot Username",
    icon_emoji: "Icon (emoji)",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "slack_bot-send-block-kit-message",
    "configured_props": {
      "slack_bot": { "authProvisionId": "apn_xxxxxxx" },
      "username": "Bot Username",
      "icon_emoji": "Icon (emoji)"
    }
  }'
```

---

- App: https://pipedream.com/apps/slack-bot.md · All apps: https://pipedream.com/apps
