Skip to content

Chatbot

Overview

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

Chatbot Settings

Get Settings

Retrieve current chatbot settings.

Terminal window
GET /api/chatbot/settings

Response

{
"status": "success",
"data": {
"id": "uuid",
"account_id": "uuid",
"chatbot_enabled": true,
"ai_enabled": true,
"ai_provider": "openai",
"ai_model": "gpt-4o-mini",
"ai_temperature": 0.7,
"ai_max_tokens": 500,
"system_prompt": "You are a helpful customer service assistant...",
"greeting_message": "Hello! Welcome to our support. How can I help you?",
"greeting_buttons": [
{"title": "Track Order"},
{"title": "Product Info"},
{"title": "Speak to Agent"}
],
"fallback_message": "Sorry, I didn't understand that. Please try again.",
"fallback_buttons": [
{"title": "Main Menu"},
{"title": "Speak to Agent"}
],
"transfer_keywords": ["agent", "human", "help"],
"business_hours_enabled": false
}
}

Button Configuration

Both greeting_buttons and fallback_buttons support WhatsApp interactive buttons:

Button CountDisplay Type
1-3 buttonsQuick reply buttons
4-10 buttonsList menu

Each button requires only:

  • title: Display text (max 20 characters)

The id is auto-generated by the system.

Update Settings

Update chatbot settings.

Terminal window
PUT /api/chatbot/settings

Request Body

{
"chatbot_enabled": true,
"ai_enabled": true,
"ai_provider": "anthropic",
"ai_model": "claude-3-5-sonnet-latest",
"ai_temperature": 0.7,
"system_prompt": "You are a helpful assistant for our e-commerce store...",
"greeting_message": "Welcome! How can I assist you today?",
"greeting_buttons": [
{"title": "My Orders"},
{"title": "Get Support"}
],
"fallback_message": "I'm not sure I understand. Please choose an option:",
"fallback_buttons": [
{"title": "Main Menu"}
]
}

Keyword Rules

List Rules

Terminal window
GET /api/chatbot/keywords

Response

{
"status": "success",
"data": {
"items": [
{
"id": "uuid",
"name": "Greeting Response",
"keywords": ["hello", "hi", "hey"],
"match_type": "contains",
"response_type": "text",
"response": "Hello! How can I help you today?",
"priority": 10,
"enabled": true
}
]
}
}

Create Rule

Terminal window
POST /api/chatbot/keywords

Request Body

{
"name": "Business Hours",
"keywords": ["hours", "open", "when"],
"match_type": "contains",
"response_type": "text",
"response": "We're open Monday-Friday, 9 AM to 6 PM EST.",
"priority": 5,
"enabled": true
}

Match Types

TypeDescription
exactMessage must match keyword exactly
containsMessage contains the keyword
starts_withMessage starts with the keyword
regexRegular expression pattern match

Update Rule

Terminal window
PUT /api/chatbot/keywords/{id}

Delete Rule

Terminal window
DELETE /api/chatbot/keywords/{id}

AI Contexts

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

List Contexts

Terminal window
GET /api/chatbot/ai-contexts

Response

{
"status": "success",
"data": {
"items": [
{
"id": "uuid",
"name": "Product Catalog",
"trigger_keywords": ["product", "price", "buy"],
"context_type": "static",
"content": "Our products include...",
"priority": 10,
"enabled": true
}
]
}
}

Create Context

Terminal window
POST /api/chatbot/ai-contexts

Request Body

{
"name": "Shipping Policy",
"trigger_keywords": ["shipping", "delivery", "track"],
"context_type": "static",
"content": "We offer free shipping on orders over $50. Standard delivery takes 3-5 business days...",
"priority": 5,
"enabled": true
}

Context Types

TypeDescription
staticFixed text content
apiFetched from external API

Update Context

Terminal window
PUT /api/chatbot/ai-contexts/{id}

Delete Context

Terminal window
DELETE /api/chatbot/ai-contexts/{id}

Conversation Flows

List Flows

Terminal window
GET /api/chatbot/flows

Create Flow

Terminal window
POST /api/chatbot/flows

Request Body

{
"name": "Feedback Collection",
"trigger_keywords": ["feedback", "review"],
"initial_message": "Hi! I'd like to collect your feedback.",
"completion_message": "Thank you for your feedback!",
"enabled": true,
"panel_config": {
"sections": [
{
"id": "customer",
"label": "Customer Info",
"columns": 1,
"collapsible": true,
"default_collapsed": false,
"order": 1,
"fields": [
{"key": "rating", "label": "Rating", "order": 1},
{"key": "comment", "label": "Comment", "order": 2}
]
}
]
},
"steps": [
{
"step_name": "rating",
"step_order": 1,
"message": "How would you rate your experience?",
"message_type": "buttons",
"input_type": "select",
"buttons": [
{"id": "excellent", "title": "Excellent"},
{"id": "good", "title": "Good"},
{"id": "poor", "title": "Poor"}
],
"store_as": "rating"
},
{
"step_name": "comment",
"step_order": 2,
"message": "Any additional comments?",
"message_type": "text",
"input_type": "text",
"store_as": "comment"
},
{
"step_name": "transfer",
"step_order": 3,
"message": "Connecting you with our team...",
"message_type": "transfer",
"transfer_config": {
"team_id": "uuid",
"notes": "Rating: {{rating}}"
}
}
]
}

Step Message Types

TypeDescription
textSend a static text message
buttonsSend message with interactive buttons
api_fetchFetch message content from external API
whatsapp_flowTrigger a native WhatsApp Flow
transferTransfer conversation to agent/team and end flow

Transfer Step Configuration

The transfer message type ends the flow and creates an agent transfer:

{
"message_type": "transfer",
"message": "Connecting you with our support team...",
"transfer_config": {
"team_id": "uuid",
"notes": "From flow: {{variable_name}}"
}
}
FieldDescription
team_idTarget team UUID (omit for general queue)
notesInternal notes for agents (supports {{variable}} placeholders)

Panel Configuration

Configure which session variables are displayed in the Contact Info Panel:

{
"panel_config": {
"sections": [
{
"id": "section-1",
"label": "Customer Info",
"columns": 1,
"collapsible": true,
"default_collapsed": false,
"order": 1,
"fields": [
{"key": "customer_name", "label": "Name", "order": 1, "display_type": "text"},
{"key": "status", "label": "Status", "order": 2, "display_type": "badge", "color": "success"}
]
}
]
}
}

Section Properties

FieldTypeDescription
idstringUnique section identifier
labelstringDisplay label for the section
columnsnumberLayout columns (1 or 2)
collapsiblebooleanAllow section to be collapsed
default_collapsedbooleanStart section in collapsed state
ordernumberSection display order
fieldsarrayFields to display in this section

Field Properties

FieldTypeDescription
keystringSession variable name (from store_as or response mapping)
labelstringDisplay label for the field
ordernumberField display order within section
display_typestringHow to render the value: text (default), badge, or tag
colorstringColor for badge/tag: default, success, warning, error, or info

Agent Transfers

List Transfers

Get agent transfer requests.

Terminal window
GET /api/chatbot/transfers

Query Parameters

ParameterTypeDescription
statusstringFilter by status: active or resumed
team_idstringFilter by team ID, or general for general queue

Response

{
"status": "success",
"data": {
"transfers": [
{
"id": "uuid",
"contact_id": "uuid",
"contact_name": "John Doe",
"phone_number": "1234567890",
"status": "active",
"source": "flow",
"agent_id": null,
"agent_name": null,
"team_id": "uuid",
"team_name": "Sales Team",
"notes": "Interested in enterprise plan",
"transferred_at": "2024-01-01T12:00:00Z"
}
],
"general_queue_count": 3,
"team_queue_counts": {
"team-uuid-1": 5,
"team-uuid-2": 2
}
}
}

Create Transfer

Manually transfer a conversation to a human agent or team.

Terminal window
POST /api/chatbot/transfers

Request Body

{
"contact_id": "uuid",
"team_id": "uuid",
"notes": "Customer requested human support"
}
FieldTypeRequiredDescription
contact_iduuidYesThe contact to transfer
team_iduuidNoTarget team (omit for general queue)
notesstringNoInternal notes for agents

Pick Next Transfer

Pick the next unassigned transfer from the queue.

Terminal window
POST /api/chatbot/transfers/pickup

Query Parameters

ParameterTypeDescription
team_idstringPick from specific team, or general for general queue only

Assign Transfer

Assign a transfer to a specific agent.

Terminal window
PUT /api/chatbot/transfers/{id}/assign

Request Body

{
"agent_id": "uuid"
}

Resume from Transfer

Resume chatbot after human agent completes interaction.

Terminal window
PUT /api/chatbot/transfers/{id}/resume

Sessions

List Sessions

View active chatbot sessions (for debugging).

Terminal window
GET /api/chatbot/sessions

Get Session

Get details of a specific session.

Terminal window
GET /api/chatbot/sessions/{id}

Response

{
"status": "success",
"data": {
"id": "uuid",
"contact_id": "uuid",
"current_flow_id": "uuid",
"current_step": "rating",
"variables": {
"name": "John"
},
"started_at": "2024-01-01T12:00:00Z",
"last_activity": "2024-01-01T12:05:00Z"
}
}