Skip to main content

Gateway API

The gateway module of the @codebolt/plugin-sdk.

import plugin from '@codebolt/plugin-sdk';

Quick Reference

MethodDescription
offMessageToChannelRemove a previously registered messageToChannel callback.
offReplyRemove a previously registered reply callback.
onMessageToChannelRegister a callback for proactive messages from the application.
onReplyRegister a callback for agent replies.
registerChannelRegister this plugin as a channel in the ChannelStore so it appears
routeMessageRoute an incoming platform message to the RoutingGateway.
unregisterChannelUnregister this plugin's channel from the ChannelStore.

Methods


offMessageToChannel

plugin.gateway.offMessageToChannel(callback: Function): void

Remove a previously registered messageToChannel callback.

ParameterTypeRequiredDescription
callbackFunctionYes

Returns: void

Full reference →


offReply

plugin.gateway.offReply(callback: Function): void

Remove a previously registered reply callback.

ParameterTypeRequiredDescription
callbackFunctionYes

Returns: void

Full reference →


onMessageToChannel

plugin.gateway.onMessageToChannel(callback: Function): void

Register a callback for proactive messages from the application. When the server wants to send a notification/message to a platform user, it pushes a gateway.messageToChannel event which triggers this callback.

ParameterTypeRequiredDescription
callbackFunctionYesCalled with targetId, text, and optional metadata

Returns: void

Full reference →


onReply

plugin.gateway.onReply(callback: Function): void

Register a callback for agent replies. When an agent sends a response on a gateway-managed thread, the server pushes a gateway.reply message which triggers this callback.

ParameterTypeRequiredDescription
callbackFunctionYesCalled with the reply text and externalThreadId

Returns: void

Full reference →


registerChannel

plugin.gateway.registerChannel(request: RegisterChannelRequest): Promise<RegisterChannelResponse>

Register this plugin as a channel in the ChannelStore so it appears in the Routing Rules view. Should be called once during plugin startup.

ParameterTypeRequiredDescription
requestRegisterChannelRequestYesChannel registration details

Returns: Promise<RegisterChannelResponse> — Promise resolving to the assigned channelId

Full reference →


routeMessage

plugin.gateway.routeMessage(message: PluginGatewayMessage): Promise<GatewayRouteResponse>

Route an incoming platform message to the RoutingGateway. The server resolves the thread, finds/spawns the agent, and delivers the message.

ParameterTypeRequiredDescription
messagePluginGatewayMessageYesThe gateway message describing the incoming platform message

Returns: Promise<GatewayRouteResponse> — Promise resolving to the routing result (action, threadId, agentId)

Full reference →


unregisterChannel

plugin.gateway.unregisterChannel(): Promise<void>

Unregister this plugin's channel from the ChannelStore. Should be called during plugin shutdown.

No parameters.

Returns: Promise<void>

Full reference →