> For the complete documentation index, see [llms.txt](https://agpt.co/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://agpt.co/docs/integrations/block-integrations/blocks.md).

# Slack Blocks

Blocks for sending messages to Slack channels, direct messages, and threads using a Slack Bot Token.

## Send Slack Message

### What it is

Send a text message to any Slack channel, DM, or thread. Required bot token scope: chat:write.

### How it works

Calls the Slack `chat.postMessage` API with your bot token. The token must have the `chat:write` scope. Optionally uses `chat:write.customize` to set a custom username or icon emoji. Returns the message timestamp (`ts`), which can be passed back as `thread_ts` to reply in the same thread.

If the Slack API returns a non-`ok` response (e.g. `invalid_auth`, `channel_not_found`, `not_in_channel`, or missing scopes), the block raises a user-facing error with the Slack error code so you can diagnose and fix the issue. Network failures and unexpected exceptions are also surfaced as errors through the block's `error` output.

### Inputs

| Input         | Description                                                                                                         | Type | Required |
| ------------- | ------------------------------------------------------------------------------------------------------------------- | ---- | -------- |
| channel       | Channel ID (e.g. C1234567890) or name (e.g. #general). For DMs use the user's member ID (e.g. U1234567890).         | str  | Yes      |
| text          | Message text. Supports Slack mrkdwn: *bold*, *italic*, `code`, <https://example.com\\|link>.                        | str  | Yes      |
| thread\_ts    | Timestamp of the parent message to reply in a thread. Use the 'ts' output from a previous Send Slack Message block. | str  | No       |
| username      | Custom display name for the bot in this message. Requires chat:write.customize scope.                               | str  | No       |
| icon\_emoji   | Emoji to use as the bot's icon (e.g. :robot:). Requires chat:write.customize scope.                                 | str  | No       |
| unfurl\_links | Automatically expand URLs into rich previews.                                                                       | bool | No       |
| mrkdwn        | Enable Slack markdown formatting in the message text.                                                               | bool | No       |

### Outputs

| Output  | Description                                                                              | Type |
| ------- | ---------------------------------------------------------------------------------------- | ---- |
| error   | Error message if the operation failed                                                    | str  |
| ts      | Message timestamp — Slack's unique message ID. Use as 'thread\_ts' to reply in a thread. | str  |
| channel | The channel ID where the message was posted.                                             | str  |

### Possible use case

**Daily Summaries**: Post a recap of completed tasks or pipeline results to a `#updates` channel at the end of each run.

**Anomaly Alerts**: Send an immediate notification to a `#alerts` channel when a monitoring workflow detects an error or threshold breach.

**Threaded Follow-ups**: Chain two Send Slack Message blocks — pass the `ts` output of the first into the `thread_ts` input of the second to keep responses organized in a single thread.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://agpt.co/docs/integrations/block-integrations/blocks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
