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
Section titled “Interface”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).
Sending a message
Section titled “Sending a message”const { messageId } = await messenger.sendMessage({ channelId: "C0123ABCDEF", text: "Looking into this...",});Updating in-place
Section titled “Updating in-place”The agent uses this pattern to replace a “thinking…” message with the actual response:
// Send placeholderconst { messageId } = await messenger.sendMessage({ channelId: "C0123ABCDEF", threadId: "1234567890.123456", text: "Looking into this...",});
// Replace with actual responseawait messenger.updateMessage( "C0123ABCDEF", messageId, "Here's what I found: ...",);Required bot token scopes
Section titled “Required bot token scopes”| Scope | Purpose |
|---|---|
chat:write | Send messages |
im:history | Read DM history for context |
im:read | Access DM channels |
im:write | Open DM channels |
app_mentions:read | Respond to @mentions |