const result = await client.chat({ bot_id: 'bot_abc123', message: 'Hello! How can you help me?'});if (result.err) { console.error('Error:', result.err);} else { console.log('Bot response:', result.response);}
const result = await client.chat({ bot_id: 'bot_abc123', message: 'Complex question requiring deep thinking', model: 'o1', // Use reasoning model for this request reasoning_mode: 'agent' // Autonomous multi-step with tools (up to 10x credit)});
const result = await client.chat({ bot_id: 'bot_abc123', message: 'What is our refund policy?', source_ids: ['source_123', 'source_456'] // Only use these sources});
Edit mode routes your request through the agent reasoning pipeline, where the agent uses the built-in edit tool to make targeted code changes in your workspace files.
Copy
// Send an edit request — the agent finds and edits the relevant fileconst result = await client.chat({ bot_id: 'bot_abc123', message: 'Add email validation to the login form', chat_id: chatId, chat_mode: 'edit'});console.log(result.response); // Agent's summary of changes made
Edit mode forces agent reasoning — the AI analyzes your request, identifies the target file in the workspace, and applies precise string replacements using the built-in edit tool. The agent can chain multiple edits in a single turn. No reference_message_id is needed.
Edit mode requires the agent’s Workspace setting to be enabled. If workspace is disabled, edit requests are treated as normal ask mode.
Plan mode enables a conversational “plan-then-execute” workflow — the AI proposes a step-by-step plan before executing any tools, giving you the opportunity to review, modify, or approve.
Copy
// Step 1: Request a planconst plan = await client.chat({ bot_id: 'bot_abc123', message: 'Find a professional studio background image and update the page', chat_id: chatId, chat_mode: 'plan'});console.log(plan.response); // AI proposes a step-by-step plan// Step 2: Approve the plan to execute itconst result = await client.chat({ bot_id: 'bot_abc123', message: 'Looks good, go ahead', chat_id: chatId, chat_mode: 'plan'});console.log(result.response); // Executed result// Or modify the plan insteadconst revised = await client.chat({ bot_id: 'bot_abc123', message: 'Actually, search for a darker background instead', chat_id: chatId, chat_mode: 'plan'});console.log(revised.response); // Revised plan
Plan mode classifies each message as one of three intents: approve (execute the proposed plan), modify (revise the plan), or new (generate a fresh plan). The AI is aware of all available tools (built-in and connected integrations) when generating plans. If no tools are needed, it bypasses planning and returns a direct answer. Plan generation costs 2 credits; execution costs are additional based on the tools used.
Plan mode requires the agent’s Workspace setting to be enabled. If workspace is disabled, plan requests are treated as normal ask mode.