Skip to content

Chatbot

The Chatbot API allows you to configure automated responses, keyword rules, conversation flows, and AI-powered responses.

Retrieve current chatbot settings and usage statistics.

Terminal window
GET /api/chatbot/settings
{
"status": "success",
"data": {
"settings": {
"enabled": true,
"greeting_message": "Hello! Welcome to our support. How can I help you?",
"greeting_buttons": [
{"id": "track_order", "title": "Track Order"},
{"id": "speak_agent", "title": "Speak to Agent"}
],
"fallback_message": "Sorry, I didn't understand that. Please try again.",
"fallback_buttons": [
{"id": "main_menu", "title": "Main Menu"}
],
"session_timeout_minutes": 30,
"business_hours_enabled": false,
"business_hours": [],
"out_of_hours_message": "We are currently closed.",
"allow_automated_outside_hours": true,
"allow_agent_queue_pickup": true,
"assign_to_same_agent": true,
"agent_current_conversation_only": false,
"ai_enabled": true,
"ai_provider": "openai",
"ai_model": "gpt-4o-mini",
"ai_max_tokens": 500,
"ai_system_prompt": "You are a helpful customer service assistant...",
"sla_enabled": false,
"sla_response_minutes": 15,
"sla_resolution_minutes": 60,
"sla_escalation_minutes": 30,
"sla_auto_close_hours": 24,
"sla_auto_close_message": "Ticket closed automatically.",
"sla_warning_message": "Are you still there?",
"sla_escalation_notify_ids": [],
"client_reminder_enabled": false,
"client_reminder_minutes": 5,
"client_reminder_message": "Reminder: please reply.",
"client_auto_close_minutes": 10,
"client_auto_close_message": "Session closed due to inactivity."
},
"stats": {
"total_sessions": 120,
"active_sessions": 5,
"messages_handled": 1450,
"ai_responses": 950,
"agent_transfers": 15,
"keywords_count": 8,
"flows_count": 3,
"ai_contexts_count": 2
}
}
}

Update chatbot settings.

Terminal window
PUT /api/chatbot/settings

Supports updating any of the settings fields shown above.

{
"enabled": true,
"ai_enabled": true,
"ai_provider": "openai",
"ai_model": "gpt-4o-mini",
"ai_system_prompt": "You are a helpful assistant for our e-commerce store...",
"greeting_message": "Welcome! How can I assist you today?"
}
Terminal window
GET /api/chatbot/keywords
ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20)
searchstringSearch rule name or keywords
{
"status": "success",
"data": {
"rules": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Greeting Response",
"keywords": ["hello", "hi", "hey"],
"match_type": "contains",
"response_type": "text",
"response_content": "Hello! How can I help you today?",
"priority": 10,
"enabled": true,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
],
"total": 1,
"page": 1,
"limit": 20
}
}
Terminal window
POST /api/chatbot/keywords
{
"name": "Business Hours",
"keywords": ["hours", "open", "when"],
"match_type": "contains",
"response_type": "text",
"response_content": "We're open Monday-Friday, 9 AM to 6 PM EST.",
"priority": 5,
"enabled": true
}
TypeDescription
exactMessage must match keyword exactly
containsMessage contains the keyword
starts_withMessage starts with the keyword
regexRegular expression pattern match
Terminal window
PUT /api/chatbot/keywords/{id}
Terminal window
DELETE /api/chatbot/keywords/{id}

AI Contexts provide additional knowledge to the AI for specific topics.

Terminal window
GET /api/chatbot/ai-contexts
ParameterTypeDescription
pageintegerPage number
limitintegerItems per page
searchstringSearch name, content, or keywords
{
"status": "success",
"data": {
"contexts": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Product Catalog",
"context_type": "static",
"trigger_keywords": ["product", "price", "buy"],
"static_content": "Our products include...",
"enabled": true,
"priority": 10,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
],
"total": 1,
"page": 1,
"limit": 20
}
}
Terminal window
POST /api/chatbot/ai-contexts
{
"name": "Shipping Policy",
"trigger_keywords": ["shipping", "delivery", "track"],
"context_type": "static",
"static_content": "We offer free shipping on orders over $50. Standard delivery takes 3-5 business days...",
"priority": 5,
"enabled": true
}
TypeDescription
staticFixed text content
apiFetched from external API
Terminal window
PUT /api/chatbot/ai-contexts/{id}
Terminal window
DELETE /api/chatbot/ai-contexts/{id}
Terminal window
GET /api/chatbot/flows
ParameterTypeDescription
pageintegerPage number
limitintegerItems per page
searchstringSearch name, description, or keywords
{
"status": "success",
"data": {
"flows": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Feedback Collection",
"description": "Flow to collect customer feedback",
"trigger_keywords": ["feedback", "review"],
"enabled": true,
"created_at": "2024-01-01T00:00:00Z"
}
],
"total": 1,
"page": 1,
"limit": 20
}
}
Terminal window
POST /api/chatbot/flows

Flows are stored as a graph: nodes (each with an id, type, and type-specific config) connected by edges labelled with the outcome they handle.

{
"name": "Feedback Collection",
"description": "Flow to collect customer feedback",
"trigger_keywords": ["feedback", "review"],
"enabled": true,
"graph": {
"version": 2,
"entry_node": "rating",
"nodes": [
{
"id": "rating",
"type": "buttons",
"label": "Ask for rating",
"position": {"x": 0, "y": 0},
"config": {
"body": "How would you rate your experience?",
"buttons": [
{"id": "excellent", "title": "Excellent"},
{"id": "good", "title": "Good"},
{"id": "poor", "title": "Poor"}
]
}
},
{
"id": "comment",
"type": "prompt",
"label": "Collect comment",
"position": {"x": 250, "y": 0},
"config": {
"body": "Any additional comments?",
"store_as": "comment"
}
},
{
"id": "handoff",
"type": "transfer",
"label": "Transfer to team",
"position": {"x": 500, "y": 0},
"config": {
"body": "Connecting you with our team…",
"team_id": "880e8400-e29b-41d4-a716-446655440000",
"notes": "Rating: {{rating}}"
}
}
],
"edges": [
{"from": "rating", "to": "comment", "condition": "button:excellent"},
{"from": "rating", "to": "comment", "condition": "button:good"},
{"from": "rating", "to": "handoff", "condition": "button:poor"},
{"from": "comment", "to": "handoff", "condition": "default"}
]
}
}
TypePurposeKey config fieldsOutgoing edge conditions
messageSend a templated text message.messagedefault
promptSend a question; wait for and validate a reply.body, store_as, validation_regex, validation_error, max_retriesdefault, max_retries
buttonsInteractive reply buttons.body, buttons: [{id,title}]button:<id> per button
api_callHTTP request with response capture + optional templated reply.url, method, headers, body, response_mapping, message_templatehttp:2xx, http:non2xx
conditionBoolean expression branch over session data.expressiontrue, false
timingBusiness-hours routing.schedule: [{day,enabled,start_time,end_time}]in_hours, out_of_hours
whatsapp_flowSend a native WhatsApp Flow form.flow_id, header, body, ctadefault
transferHand off to a team / queue and end the session.body, team_id, notes(terminal)
goto_flowJump to another flow in the same org/account.flow_id(handled internally)
webhookFire-and-forget HTTP call; result ignored.url, method, headers, bodydefault
endOptionally send a final message and terminate.message(terminal)
Terminal window
PUT /api/chatbot/flows/{id}
Terminal window
DELETE /api/chatbot/flows/{id}

Agent transfers manage the transition from the automated chatbot to human support agents.

Get agent transfer requests.

Terminal window
GET /api/chatbot/transfers
ParameterTypeDescription
statusstringFilter by status: active or resumed
team_idstringFilter by team ID, or general for general queue
limitintegerPagination limit
offsetintegerPagination offset
includestringRelations to load (e.g. contact,agent,team or all)
{
"status": "success",
"data": {
"transfers": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "660e8400-e29b-41d4-a716-446655440000",
"contact_name": "John Doe",
"phone_number": "+1234567890",
"whatsapp_account": "default_account",
"status": "active",
"source": "flow",
"agent_id": null,
"agent_name": null,
"team_id": "880e8400-e29b-41d4-a716-446655440000",
"team_name": "Sales Team",
"notes": "Interested in enterprise plan",
"transferred_at": "2024-01-01T12:00:00Z"
}
],
"general_queue_count": 3,
"team_queue_counts": {
"880e8400-e29b-41d4-a716-446655440000": 5
},
"total_count": 8,
"limit": 100,
"offset": 0
}
}

Manually transfer a conversation to a human agent or team.

Terminal window
POST /api/chatbot/transfers
{
"contact_id": "660e8400-e29b-41d4-a716-446655440000",
"whatsapp_account": "default_account",
"team_id": "880e8400-e29b-41d4-a716-446655440000",
"notes": "Customer requested human support",
"source": "manual"
}

Pick the next unassigned transfer from the queue (self-assignment).

Terminal window
POST /api/chatbot/transfers/pick
ParameterTypeDescription
team_idstringPick from specific team queue, or general for general queue only
{
"status": "success",
"data": {
"message": "Transfer picked successfully",
"transfer": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "660e8400-e29b-41d4-a716-446655440000",
"phone_number": "+1234567890",
"whatsapp_account": "default_account",
"status": "active",
"source": "flow",
"notes": "Interested in enterprise plan",
"transferred_at": "2024-01-01T12:00:00Z",
"agent_id": "770e8400-e29b-41d4-a716-446655440000",
"agent_name": "Jane Smith"
}
}
}

Assign a transfer to a specific agent, or unassign (returning it to the queue).

Terminal window
PUT /api/chatbot/transfers/{id}/assign
{
"agent_id": "770e8400-e29b-41d4-a716-446655440000",
"team_id": "880e8400-e29b-41d4-a716-446655440000"
}
{
"status": "success",
"data": {
"message": "Transfer assigned successfully",
"agent_id": "770e8400-e29b-41d4-a716-446655440000"
}
}

End human agent interaction and resume chatbot processing.

Terminal window
PUT /api/chatbot/transfers/{id}/resume
{
"status": "success",
"data": {
"message": "Transfer resumed, chatbot is now active for this contact"
}
}

View active chatbot sessions (primarily for debugging).

Terminal window
GET /api/chatbot/sessions
ParameterTypeDescription
statusstringFilter sessions by status: active, completed, cancelled, timeout

Get details of a specific session.

Terminal window
GET /api/chatbot/sessions/{id}
{
"status": "success",
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact_id": "660e8400-e29b-41d4-a716-446655440000",
"current_flow_id": "770e8400-e29b-41d4-a716-446655440000",
"current_step": "rating",
"variables": {
"name": "John"
},
"started_at": "2024-01-01T12:00:00Z",
"last_activity": "2024-01-01T12:05:00Z"
}
}