1---2name: slack3description: Search Slack messages and read channel history across your workspaces. Use this skill when the user asks about Slack conversations, channel messages, or internal communications.4---56# Slack Integration78## Connection910- **Base URL**: `https://slack.com/api/`11- **Auth**: `Authorization: Bearer $SLACK_BOT_TOKEN` (or `$SLACK_BOT_TOKEN_2` for secondary workspace)12- **Credentials**: `SLACK_BOT_TOKEN` (primary), `SLACK_BOT_TOKEN_2` (secondary workspace)13- **Caching**: 2-minute in-memory cache, max 200 entries; separate user/bot caches1415## Server Lib1617- **File**: `server/lib/slack.ts`1819### Exported Functions2021| Function | Description |22| ---------------------------------------------------------- | -------------------------------------------- |23| `getTeamInfo(workspace)` | Get workspace info |24| `listChannels(workspace)` | List channels (paginated, first page cached) |25| `getChannelHistory(workspace, channelId, limit?, cursor?)` | Channel message history |26| `searchMessages(workspace, query, count?)` | Search messages |27| `getUserInfo(workspace, userId)` | Get user info (cached per user) |28| `getBotInfo(workspace, botId)` | Get bot info (cached) |29| `resolveUsers(workspace, userIds, messages?)` | Batch resolve user names |3031## Agent Action3233Use `slack-messages` for agent-facing Slack reads. Do not call34`/api/slack/*` directly from the agent.3536| Mode | Args | Description |37| --------------- | ---------------------------------------------------- | ---------------------- |38| `team` | `workspace` | Get workspace info |39| `channels` | `workspace` | List channels |40| `history` | `workspace`, `channel`, `limit`, `cursor` | Read channel history |41| `multi-history` | `workspace`, `channels`, `names`, `limit`, `cursors` | Read multiple channels |42| `search` | `workspace`, `query` | Search messages |4344## Key Patterns & Gotchas4546- Two workspaces supported via workspace parameter ("primary" / "secondary")47- `getChannelHistory` auto-joins channels on "not_in_channel" error, then retries — requires `channels:join` scope48- If auto-join fails, throws a detailed message explaining how to invite the bot49- `searchMessages` may require user token; bot token tried first50- `listChannels` paginates via cursor; only first page is cached51- `getUserInfo` resolves bots via `getBotInfo` when needed