Skip to content

Messaging

The messaging provider sends and updates messages in chat platforms. This is used by the interactive agent to post responses in threads — it’s different from the notification provider, which sends one-shot webhook payloads.

The key difference: messaging supports two-way threads (send a message, then update it in-place), while notification is fire-and-forget.

import { slack } from "@swenyai/providers/messaging";
interface MessagingProvider {
sendMessage(msg: ChatMessage): Promise<{ messageId: string }>;
updateMessage(channelId: string, messageId: string, text: string): Promise<void>;
}
interface ChatMessage {
channelId: string;
threadId?: string;
text: string;
format?: "markdown" | "text";
}
const messenger = slack({
token: process.env.SLACK_BOT_TOKEN!,
logger: myLogger,
});

Requires @slack/web-api as a peer dependency (lazy-loaded at runtime).

const { messageId } = await messenger.sendMessage({
channelId: "C0123ABCDEF",
text: "Looking into this...",
});

The agent uses this pattern to replace a “thinking…” message with the actual response:

// Send placeholder
const { messageId } = await messenger.sendMessage({
channelId: "C0123ABCDEF",
threadId: "1234567890.123456",
text: "Looking into this...",
});
// Replace with actual response
await messenger.updateMessage(
"C0123ABCDEF",
messageId,
"Here's what I found: ...",
);
ScopePurpose
chat:writeSend messages
im:historyRead DM history for context
im:readAccess DM channels
im:writeOpen DM channels
app_mentions:readRespond to @mentions