intentkit-slack
v1.0.1
Published
Slack messaging adapter for IntentKit via @slack/web-api
Downloads
199
Maintainers
Readme
intentkit-slack
Slack messaging adapter for IntentKit — channel messaging, reactions, and user lookup via the provider system.
Lets AI agents (like Claude via Dispatch) send messages, read channel history, add reactions, and look up users through MCP.
Install
npm install intentkit-slackSlack App Setup
Before using this adapter, you need a Slack app with a bot token:
- Create a Slack App at api.slack.com/apps > "Create New App" > "From scratch"
- Add Bot Token Scopes under "OAuth & Permissions" > "Scopes" > "Bot Token Scopes":
chat:write— send messageschannels:read— list public channelsgroups:read— list private channels the bot is inchannels:history— read public channel messagesgroups:history— read private channel messagesreactions:write— add emoji reactionsusers:read— look up user infousers:read.email— (optional) access user email addresses
- Install to Workspace — click "Install to Workspace" and authorize
- Copy the Bot Token — starts with
xoxb-. This goes in your config - Invite the bot to channels it needs to access:
/invite @YourBotName
Quick Start
import { defineFunction, IntentRegistry, createContext, serve, z } from 'intentkit';
import { createSlackProvider, type SlackClient } from 'intentkit-slack';
// Register your functions
const registry = new IntentRegistry().register(sendSlackMessage, listChannels, getMessages, addReaction);
// Create context (no database needed for Slack-only projects)
const context = await createContext({ events: true });
// Boot MCP server with Slack provider
await serve({
name: 'my-slack-agent',
registry,
context,
providers: [
createSlackProvider({
token: process.env.SLACK_BOT_TOKEN!,
defaultChannel: '#general',
}),
],
});Configuration
| Option | Default | Description |
|--------|---------|-------------|
| token | -- | Slack Bot Token (xoxb-...) |
| defaultChannel | -- | Default channel ID or name for posting |
| name | 'slack' | Provider name in ctx.providers |
Using in Functions
Access the Slack client via ctx.providers.slack:
import { defineFunction, z } from 'intentkit';
import type { SlackClient } from 'intentkit-slack';
export const notifyChannel = defineFunction({
name: 'notify_channel',
intent: 'Send a notification to a Slack channel',
permissions: ['slack:write'],
requires: ['slack'], // Validates provider exists at startup
input: z.object({
message: z.string(),
channel: z.string().optional(),
}),
output: z.object({
ts: z.string(),
channel: z.string(),
}),
execute: async (input, ctx) => {
const slack = ctx.providers.slack as SlackClient;
const result = await slack.sendMessage({
text: input.message,
channel: input.channel,
});
return { ts: result.ts, channel: result.channel };
},
});Example Functions
The package includes 4 ready-to-use functions in functions/slack.ts:
| Function | Intent | Permission |
|----------|--------|------------|
| send_slack_message | Send a message to a channel or thread | slack:write |
| list_channels | List available channels the bot can access | slack:read |
| get_messages | Get recent messages from a channel or thread | slack:read |
| add_reaction | Add an emoji reaction to a message | slack:write |
Import and register them:
import { sendSlackMessage, listChannels, getMessages, addReaction } from 'intentkit-slack/functions';
const registry = new IntentRegistry()
.register(sendSlackMessage, listChannels, getMessages, addReaction);SlackClient API
The full client interface for custom function implementations:
interface SlackClient {
// Connection
ping(): Promise<boolean>;
// Messaging
sendMessage(options: SendMessageOptions): Promise<SlackMessage>;
getMessages(options: GetMessagesOptions): Promise<SlackMessage[]>;
// Channels
listChannels(limit?: number): Promise<SlackChannel[]>;
// Reactions
addReaction(channel: string, timestamp: string, emoji: string): Promise<void>;
// Users
getUser(userId: string): Promise<SlackUser>;
}Claude Desktop Config
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"slack": {
"command": "node",
"args": ["path/to/your/serve.js"],
"env": {
"SLACK_BOT_TOKEN": "xoxb-your-bot-token"
}
}
}
}Architecture
Claude (Dispatch / Desktop)
| MCP tool call
IntentKit (serve + permissions + hooks)
| ctx.providers.slack
intentkit-slack (SlackClientImpl)
|
@slack/web-api (WebClient)
| HTTPS
Slack APIThe WebClient is HTTP-based and stateless -- no persistent connection is maintained. healthCheck() calls auth.test to verify the token. No cleanup is needed on shutdown since there is no connection to close.
License
MIT
