Skip to main content

Chat Integrations

Connect any chat platform — Discord, Slack, Telegram, or your own — to Codebolt. Users send messages on their platform; Codebolt routes them to the right agent; replies flow back to the same chat automatically.

Architecture

Chat Integration Architecture: platforms → plugin → server gateway → agentExternal PlatformsDiscordSlackTelegramCustomplatform eventssend replyPLUGINChannel Plugindiscord.js · @slack/bolt · grammy · custom SDKgateway.routeMessage()gateway.onReply()WebSocket /plugingateway.replySRVCodebolt ServerSOCKPlugin Socket/plugin WS endpointGWGateway Handlerroute · registerRTRouting Gatewaythread · agentRSResponse Routerintercept · dispatchThreadStrategy: per-user · per-conversation · per-message · singlethread map persisted · response listeners 30 min TTLspawn · routesendMessage()PROCAgent Processcodebolt.onMessage() · processMessage() · sendMessage()REQUEST ↓↑ REPLY

The system has four layers:

LayerWhat it is
External PlatformDiscord, Slack, Telegram, or any platform with a bot API or webhook
Channel PluginA Codebolt plugin that speaks the platform's protocol and bridges to the server
Codebolt ServerRoutes messages to agents, manages threads, routes replies back
Agent ProcessYour agent handler — receives the message, runs the loop, calls sendMessage()

The left arrows (↓) are the request path: a platform event arrives, the plugin calls gateway.routeMessage(), the server spawns or routes to a running agent.

The right arrows (↑) are the reply path: the agent calls sendMessage(), the Response Router intercepts it, pushes it back through the Gateway Handler, over WebSocket to the plugin, and the plugin delivers it to the platform.

Two ways to build an integration

Codebolt ships first-party plugins for the major platforms. Install them from the registry, configure credentials, and they work:

  • Discord — full message, thread, and attachment support
  • Slack — Socket Mode, DMs, @mention routing, file uploads
  • Telegram — polling, media messages, group filtering, auto-reconnect

2. Write a custom plugin

If your platform isn't covered, implement the plugin yourself. See Plugin SDK — gateway API for the full plugin.gateway.* surface.

The core interface every channel plugin implements:

// Incoming: translate platform event → gateway message
plugin.gateway.routeMessage({
source: 'channel',
sourceId: plugin.pluginId,
threadStrategy: 'per-user', // or per-conversation, per-message, single
agentId: config.agentId,
userId: externalUserId,
externalThreadId: externalChatId,
text: messageText,
replyTo: { channelId, externalThreadId, userId },
});

// Outgoing: receive agent reply → send to platform
plugin.gateway.onReply((reply) => {
platformApi.send(reply.replyTo.externalThreadId, reply.text);
});

Key concepts

  • Gateway — how thread resolution, agent routing, and reply dispatch work
  • WebSocket protocol — the /plugin WebSocket that connects plugins to the server

See also