Router Class
Constructor
string
required
BoostGPT API key
string
required
BoostGPT project ID
Array<BaseAdapter>
default:"[]"
Array of channel adapter instances
string
Default bot ID for all adapters (can be overridden per adapter)
Function
Global error handler function
boolean
default:"true"
Enable console logging
Methods
onMessage()
Set a custom message handler for all channels.Object
Normalized message object:
Object
Context object:
string- Send this as the responsenull/undefined- Let BoostGPT handle it automatically
onError()
Set a custom error handler for all channels.Error
The error that occurred
Object
The message that caused the error
Object
Context object with channel information
string- Error message to send to user
start()
Start all adapters and begin listening for messages.Promise<void>
Example:
stop()
Stop all adapters and disconnect from channels.Promise<void>
Example:
getAdapter()
Get a specific adapter by channel name.string
required
Channel name (‘discord’, ‘telegram’, etc.)
BaseAdapter | null
Example:
sendMessage()
Send a message to a specific user on a specific channel.string
required
Channel name (‘discord’, ‘telegram’, etc.)
string
required
User/channel ID (format varies by channel)
string
required
Message content to send
Promise<any>
Example:
broadcast()
Broadcast a message to all or specific channels.string
required
Message to broadcast
Array<string>
Optional array of channel names. If omitted, broadcasts to all channels.
Promise<Array<Object>>
Returns an array of results indicating success/failure for each channel.
Example:
getStatus()
Get the current status of the router and all adapters.addAdapter()
Add a new adapter at runtime.BaseAdapter
required
Adapter instance to add
Promise<void>
Example:
removeAdapter()
Remove an adapter by channel name.string
required
Channel name to remove
Promise<void>
Example:
BaseAdapter Class
All channel adapters extendBaseAdapter. Use this to create custom adapters.
Constructor
BoostGPT
required
BoostGPT client instance
string
required
Bot ID for this adapter
string
required
Channel identifier (e.g., ‘discord’, ‘custom’)
string
Override model for this channel
Array<string>
Limit knowledge to specific sources
Array<string>
Limit knowledge to specific tags
number
Override top setting for training data
number
Override max tokens for this channel
string
Use custom OpenAI/Anthropic key
string
Default error message
boolean
default:"true"
Enable logging for this adapter
Methods
setMessageHandler()
start()
stop()
sendMessage()
getStatus()
Type Definitions
Message Object
Context Object
Adapter Status
Next Steps
Custom Adapters
Build your own channel adapter
Channel Adapters
Configure specific channels
Deployment
Deploy to production
Examples
Real-world implementations