Skip to main content

Slack Tools

Category: network · 6 tools

Slack Web API tools — post messages, reply in threads, react to messages, read channel history, read thread replies, and verify bot identity.

Setup

Environment Variable

Set your Slack bot token before using these tools:

export TOOLPACK_SLACK_BOT_TOKEN=xoxb-your-bot-token

All tools read TOOLPACK_SLACK_BOT_TOKEN by default. You can also pass a token parameter directly to any tool call to override the environment variable.

Import

import { slackToolsProject } from 'toolpack-sdk';

Wire up with Toolpack

import Toolpack from 'toolpack-sdk';
import { slackToolsProject } from 'toolpack-sdk';

const toolpack = await Toolpack.init({
provider: 'openai',
tools: true,
toolProjects: [slackToolsProject],
});

Tools

ToolRequired ParametersOptional ParametersDescription
slack.chat.postMessagechannel, textthread_ts, blocks, tokenPost a message to a channel or thread
slack.chat.postEphemeralchannel, user, textthread_ts, tokenPost a temporary message visible only to a specific user
slack.reactions.addchannel, timestamp, nametokenAdd an emoji reaction to a message
slack.conversations.historychannellimit, oldest, latest, tokenFetch recent messages from a channel
slack.conversations.replieschannel, tslimit, oldest, latest, tokenFetch all replies in a thread
slack.auth.testtokenVerify the bot token and retrieve bot identity

Tool Reference

slack.chat.postMessage

Post a message to a Slack channel or thread. Supports plain mrkdwn text and optional Block Kit blocks for rich formatting. Use thread_ts to reply inside an existing thread.

ParameterTypeRequiredDescription
channelstringYesChannel ID or channel name (e.g. #general)
textstringYesMessage text in Slack mrkdwn format. Always required — used as fallback when blocks are provided
thread_tsstringNoTimestamp of the parent message to reply in a thread. Omit to post at top level
blocksstringNoOptional Block Kit layout as a JSON string. When provided, text is used only as the notification fallback
tokenstringNoSlack bot token. Defaults to TOOLPACK_SLACK_BOT_TOKEN env var

slack.chat.postEphemeral

Post a temporary message visible only to a specific user in a Slack channel. Useful for private confirmations, status updates, or error messages that should not be seen by others.

ParameterTypeRequiredDescription
channelstringYesChannel ID where the ephemeral message will appear
userstringYesSlack user ID of the person who will see the message
textstringYesMessage text in Slack mrkdwn format
thread_tsstringNoTimestamp of the parent message to show the ephemeral reply inside a thread
tokenstringNoSlack bot token. Defaults to TOOLPACK_SLACK_BOT_TOKEN env var

slack.reactions.add

Add an emoji reaction to a Slack message. Useful for acknowledging receipt, signalling completion, or flagging issues. Requires the reactions:write OAuth scope on the Slack app.

ParameterTypeRequiredDescription
channelstringYesChannel ID containing the message to react to
timestampstringYesTimestamp of the message to react to
namestringYesEmoji name without colons (e.g. "eyes", "white_check_mark", "warning", "x")
tokenstringNoSlack bot token. Defaults to TOOLPACK_SLACK_BOT_TOKEN env var

slack.conversations.history

Fetch recent messages from a Slack channel. Useful for reading conversation context, checking what was discussed, or finding a specific message timestamp to react to or thread-reply into.

ParameterTypeRequiredDescription
channelstringYesChannel ID to fetch history from
limitintegerNoMaximum number of messages to return. Defaults to 10, max 100
oldeststringNoOnly return messages after this Unix timestamp (inclusive)
lateststringNoOnly return messages before this Unix timestamp (exclusive)
tokenstringNoSlack bot token. Defaults to TOOLPACK_SLACK_BOT_TOKEN env var

slack.conversations.replies

Fetch all replies in a Slack thread. Use this to read the full conversation history of a thread, including who replied and when. Requires the channel ID and the timestamp (ts) of the parent message that started the thread.

ParameterTypeRequiredDescription
channelstringYesChannel ID that contains the thread
tsstringYesTimestamp of the parent message that started the thread
limitintegerNoMaximum number of replies to return. Defaults to 20, max 100
oldeststringNoOnly return replies after this Unix timestamp (inclusive)
lateststringNoOnly return replies before this Unix timestamp (exclusive)
tokenstringNoSlack bot token. Defaults to TOOLPACK_SLACK_BOT_TOKEN env var

slack.auth.test

Verify the bot token and retrieve the identity of the calling app. Returns the bot_id, user_id, team, and workspace URL. Use this when the bot_id is not configured and is needed for self-suppression or other identity checks.

ParameterTypeRequiredDescription
tokenstringNoSlack bot token. Defaults to TOOLPACK_SLACK_BOT_TOKEN env var

Examples

Posting a Message

const stream = toolpack.stream({
messages: [{ role: 'user', content: 'Post "Deploy complete" to the #deployments channel' }],
model: 'gpt-4o',
});
// AI uses slack.chat.postMessage

Reading Channel History

const stream = toolpack.stream({
messages: [{ role: 'user', content: 'What were the last 5 messages in #general?' }],
model: 'gpt-4o',
});
// AI uses slack.conversations.history

Replying in a Thread

const stream = toolpack.stream({
messages: [{ role: 'user', content: 'Reply to the thread at ts 1234567890.123456 in #alerts' }],
model: 'gpt-4o',
});
// AI uses slack.conversations.replies then slack.chat.postMessage with thread_ts

Adding a Reaction

const stream = toolpack.stream({
messages: [{ role: 'user', content: 'Add a white_check_mark reaction to the latest message in #deployments' }],
model: 'gpt-4o',
});
// AI uses slack.conversations.history then slack.reactions.add