Skip to main content

Constructor


Bot Management

createBot()

Create a new AI bot.
string
required
Display name for your bot
string
required
AI model to use: gpt-5.6-luna, gpt-5.1, claude-haiku-4-5, gemini-3.5-flash, etc. See Model Comparison for the full catalogue.
string
required
System instruction guiding the AI’s behavior
number
default:"1000"
Maximum tokens in AI responses
string
Reasoning mode: auto, standard, agent
string
default:"active"
Bot status: active or inactive

fetchBot()

Get a bot’s configuration.
string
required
ID of the bot to fetch

fetchBots()

Get all bots in a project (paginated).
number
default:"1"
Page number
number
default:"10"
Items per page

updateBot()

Update a bot’s configuration.
All parameters same as createBot(), plus:
string
required
ID of the bot to update

resetBot()

Delete all training data from a bot.
This permanently deletes all training sources and cannot be undone.

deleteBot()

Delete a bot permanently.
This permanently deletes the bot, its training data, and chat history.

Chat Operations

chat()

Send a message and get an AI response.
string
required
ID of the bot to chat with
string
required
User’s message
string
Unique ID for conversation continuity
boolean
default:"false"
Enable streaming responses
boolean
default:"true"
Use agent’s training data/memory
string
Override bot’s default model
string
Use your own API key (BYOK)
string
Provider host URL (required for Ollama)
string
Override bot’s default instruction
array
Limit knowledge to specific sources
string
Override reasoning mode: auto, standard, agent
number
Override bot’s default token limit
string
default:"ask"
Chat mode: ask for normal chat, edit for agent-powered code editing, plan for conversational planning before tool execution. Edit mode routes through the agent reasoning pipeline to make targeted file changes. Plan mode proposes a step-by-step plan for review before executing. Both edit and plan require workspace to be enabled — if disabled, requests fall back to ask.
Response:

fetchChat()

Get chat history for a conversation.
string
required
Bot ID
string
required
Chat/conversation ID
number
default:"1"
Page number
number
default:"20"
Messages per page

fetchChats()

Get all chats for a bot.
string
required
Bot ID
number
default:"1"
Page number
number
default:"10"
Chats per page

deleteChat()

Delete a chat history.
string
required
Chat ID to delete
string
required
Bot ID

executeTool()

Run a tool the agent asked for, continuing the turn.
Every field of execution_data comes back on the tool_approval_required response — pass it through rather than assembling it yourself. A continuation resumes the turn that requested the tool, and inherits that turn’s memory, source_ids, tags and the chat’s saved chat_mode. The parameters below are overrides — send one only to change it.
Before 8.0.1 this method sent tool_calls, which the endpoint does not read, so every call returned 400. Upgrade if you are calling it.
string
required
Bot ID
string
required
Chat ID
object
required
Must contain executionId, toolName and parameters; may also carry serverLabel, originalQuery and authenticatedTools
string
Model for the continuation. Defaults to the agent’s own.
string
System instruction for the continuation.
string
ask, edit or plan. Omit to keep the chat’s saved mode.
boolean
Override whether the continuation may search the agent’s knowledge. Omit to keep whatever the turn was running with.
string[]
Override the knowledge search scope. Omit to keep the turn’s scope; send [] to clear it.
string[]
Override the tag scope. Omit to keep the turn’s; send [] to clear it.
boolean
default:"false"
Return an event stream instead of a single response.

voteMessage()

Vote on a message (upvote/downvote).
string
required
Bot ID
string
required
Message ID to vote on
string
required
ID of the user voting
string
required
Type of voter (e.g., ‘member’)
string
required
Vote type: ‘upvote’ or ‘downvote’

fetchVoteStatus()

Get the vote status for a message.
string
required
Bot ID
string
required
Message ID
string
required
Voter ID
string
required
Voter type

deleteMessage()

Delete a specific message.
string
required
Bot ID
string
required
Chat ID
string
required
Message ID to delete

Training & Sources

startTraining()

Add training data to a bot.
string
required
Bot ID
string
default:"text"
Source type: text, website, file, webpage
string | array
required
  • text: String content
  • website: String URL to crawl
  • file: Array of file paths
  • webpage: Array of URLs
Response: Training is queued and returns status:

fetchTraining()

Get a specific training source.

fetchTrainings()

Get all training sources for a bot.

updateTraining()

Update a training source.
Returns same format as startTraining() with status, tokens, and links.

deleteTraining()

Delete a training source.

search()

Search the bot’s knowledge base.
string
required
Bot ID
string
required
Search query
array
Limit search to specific sources

Subscribers

fetchSubscribers()

Get all subscribers for your project.
number
default:"1"
Page number
number
default:"10"
Subscribers per page

Analytics & Statistics

fetchVoteStats()

Get voting statistics for a bot.
string
required
Bot ID

fetchSummaryStats()

Get summary statistics for a bot.
string
required
Bot ID

fetchDashboardStats()

Get dashboard statistics for a bot.
string
required
Bot ID

fetchToolUsageStats()

Get tool usage statistics for a bot.
string
required
Bot ID

fetchWorkflowStats()

Get workflow statistics for a bot.
string
required
Bot ID

fetchPerformanceMetrics()

Get performance metrics for a bot.
string
required
Bot ID

fetchBehaviorStats()

Get user behavior statistics for a bot.
string
required
Bot ID

fetchErrorAnalysis()

Get error analysis for a bot.
string
required
Bot ID

fetchReasoningSummary()

Get reasoning summary statistics for a bot.
string
required
Bot ID

Widget

Both endpoints serve the embeddable chat widget. They are here so a backend can mint a signed session or read the same configuration the widget reads.

fetchWidgetConfig()

createWidgetSso()


Error Handling

Methods never throw. Every one returns { err, response }, and err is set whenever the request came back with a non-2xx status:
On failure response is null, so there is no half-populated object to guard against. Common statuses:
  • 400 - Invalid request. err.message says what was wrong.
  • 401 - Invalid API key
  • 403 - Insufficient permissions, or a plan that does not include the feature
  • 404 - Resource not found
  • 429 - Rate limit exceeded
  • 500 - Server error
Changed in 8.0.0. Earlier versions decided whether a request had failed by reading a field the API only populates in development, so against production err was always null and a failed call returned the error body as though it were data. If you have code inspecting response.message to detect failures, it can now check err instead.
For a streaming call — chat({ stream: true }), subscribeChat, subscribeNotificationsresponse is the raw event stream rather than a parsed object; iterate it with for await.

Complete Example


Next Steps

Router SDK

Deploy bots to multiple channels

REST API

Direct API access

Examples

Real-world implementations

Troubleshooting

Common issues