Build automated conversation rules with keywords, regex, and quick replies to handle common visitor questions without an operator.
The chatbot rules engine lets you define automated responses that fire when specific conditions are met. Rules are evaluated in priority order: the first matching rule sends its response. Use rules to answer FAQs, collect information, or route conversations automatically.
Each rule has two parts:
Rules can be toggled on/off without deleting them, making it easy to temporarily disable a rule during testing.
Triggers when the visitor's message contains a specific word or phrase. Matching is exact: use multiple keywords with separate rules for broader coverage.
{
"conditions": {
"type": "keyword",
"value": "pricing"
}
}Triggers when the visitor's message matches a regular expression pattern. Use this for flexible patterns like email addresses, order numbers, or phone numbers.
{
"conditions": {
"type": "regex",
"value": "order-[A-Z]{2}-\\d{4}"
}
}Triggers on every message when no other rule matches first. Use for a fallback response when the chatbot cannot answer the question.
{
"conditions": {
"type": "always",
"value": ""
}
}Triggers when no operator is currently online. Useful for collecting information during off-hours.
{
"conditions": {
"type": "no_operator_available",
"value": ""
}
}Present the visitor with clickable button options. Each quick reply sends the button text back as the visitor's message, which can then match downstream rules.
{
"response": {
"type": "quick_replies",
"message": "What would you like help with?",
"quickReplies": [
"Pricing",
"Technical Support",
"Talk to a human"
]
}
}Collect structured information from the visitor with a form-like experience. Each field has a label, internal field name, and required flag.
{
"response": {
"type": "collect_info",
"message": "Please provide your details so we can help faster.",
"collectFields": [
{
"label": "Full Name",
"field": "name",
"required": true
},
{
"label": "Email Address",
"field": "email",
"required": true
},
{
"label": "Order Number",
"field": "orderNumber",
"required": false
}
]
}
}Configure the chatbot to automatically switch behavior based on operating
hours. When operating hours are enabled, the chatbot can use the
no_operator_available condition during off-hours.
GET /api/chatbot/config{
"enabled": true,
"greetingMessage": "Hi! How can we help you today?",
"fallbackMessage": "I couldn't understand that. Let me connect you with an operator.",
"operatingHoursEnabled": true,
"operatingHoursStart": "09:00",
"operatingHoursEnd": "17:00"
}Update the config to set greetings, fallback messages, and operating hours:
PUT /api/chatbot/config{
"greetingMessage": "Welcome to support!",
"operatingHoursStart": "08:00",
"operatingHoursEnd": "20:00"
}Rules are evaluated in ascending priority order. Lower priority numbers are checked first. Use priority to control which rule wins when multiple rules could match the same message.
{
"name": "Order Status Lookup",
"enabled": true,
"priority": 0,
"conditions": {
"type": "regex",
"value": "order-[A-Z]{2}-\\d{4}"
},
"response": {
"type": "text",
"message": "I'll look up that order for you right away."
}
}Tip
Set broad rules (like keyword "pricing") at priority 10 and specific regex rules at priority 0 so specific patterns match first.
| Method | Endpoint | Description |
|---|---|---|
GET | /api/chatbot/rules | List all chatbot rules |
POST | /api/chatbot/rules | Create a new rule |
PUT | /api/chatbot/rules/:id | Update a rule |
DELETE | /api/chatbot/rules/:id | Delete a rule (admin) |
PUT | /api/chatbot/rules/:id/toggle | Enable/disable a rule |
| Method | Endpoint | Description |
|---|---|---|
GET | /api/chatbot/config | Get chatbot configuration |
PUT | /api/chatbot/config | Update chatbot configuration |
All endpoints require authentication. Deleting rules requires admin role.
Last updated: Jul 2, 2026
Was this page helpful?