Create simple keyword-triggered text chatbot responses.
Text Chatbot
Summary
Create simple keyword-triggered text chatbot responses.
Prerequisites
- Authorization: Bearer w91_live_xxx
- Content-Type: application/json for JSON requests
Related documentation
Endpoint: POST /api/v2/chatbots/text. Use this route for simple replies where the chatbot response only needs response.text.
POST
/api/v2/chatbots/text| Parameter | Type | Required | Description |
|---|---|---|---|
Authorization | header | Required | Bearer w91_public_token_here. |
Content-Type | header | Required | application/json. |
senderId | string | Optional | WhatsApp sender number for global tokens. |
chatbot.name | string | Required | Name for the text chatbot. |
chatbot.trigger | object | Required | Trigger object with trigger.keyword or trigger.keywords. |
chatbot.response.text | string | Required | Text returned to the WhatsApp user. |
Create text chatbot
curl -X POST "https://graph.whats91.com/api/v2/chatbots/text" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Invoice Help",
"trigger": {
"type": "contains",
"keywords": ["invoice", "bill"]
},
"response": {
"text": "Please share your invoice number."
}
}
}'Text response
{
"success": true,
"message": "Chatbot created",
"data": {
"senderId": "916268662275",
"chatbot": {
"chatbotUid": "bot_uid",
"name": "Invoice Help",
"botType": "simple",
"replyTrigger": "invoice, bill",
"replyText": "Please share your invoice number.",
"status": 1
}
},
"metadata": {
"apiVersion": "v2",
"requestId": "request-uuid"
}
}Practical Text Examples
| Example | Trigger | response.text |
|---|---|---|
| Invoice Help | invoice, bill | Please share your invoice number. |
| Order Tracking | track, order status | Share your order ID and we will check the latest status. |
| Support Hours | hours, timing | Our support team is available Monday to Saturday, 10 AM to 7 PM. |
| Lead Capture | pricing, demo | Please share your name and business email so our team can call you. |
| Appointment Reminder | appointment, booking | Reply with your appointment ID to confirm or reschedule. |
| Return Policy | return, refund | Returns are accepted within the configured policy window. Share your order ID to continue. |
Text chatbots are best for deterministic replies, first-touch support triage, and short operational prompts.
SDK Examples
Use these examples as starting points for server-side implementations.
cURL
curl -X POST "https://graph.whats91.com/api/v2/chatbots/text" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d 'curl -X POST "https://graph.whats91.com/api/v2/chatbots/text" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Invoice Help",
"trigger": {
"type": "contains",
"keywords": ["invoice", "bill"]
},
"response": {
"text": "Please share your invoice number."
}
}
}''Node.js
const response = await fetch("https://graph.whats91.com/api/v2/chatbots/text", {
method: "POST",
headers: {
"Authorization": "Bearer w91_live_xxx",
"Content-Type": "application/json"
},
body: JSON.stringify(curl -X POST "https://graph.whats91.com/api/v2/chatbots/text" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Invoice Help",
"trigger": {
"type": "contains",
"keywords": ["invoice", "bill"]
},
"response": {
"text": "Please share your invoice number."
}
}
}')
});
const data = await response.json();
console.log(data);PHP
$ch = curl_init("https://graph.whats91.com/api/v2/chatbots/text");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer w91_live_xxx",
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => json_encode(curl -X POST "https://graph.whats91.com/api/v2/chatbots/text" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Invoice Help",
"trigger": {
"type": "contains",
"keywords": ["invoice", "bill"]
},
"response": {
"text": "Please share your invoice number."
}
}
}')
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;Python
import requests
response = requests.request(
"POST",
"https://graph.whats91.com/api/v2/chatbots/text",
headers={
"Authorization": "Bearer w91_live_xxx",
"Content-Type": "application/json",
},
json=curl -X POST "https://graph.whats91.com/api/v2/chatbots/text" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Invoice Help",
"trigger": {
"type": "contains",
"keywords": ["invoice", "bill"]
},
"response": {
"text": "Please share your invoice number."
}
}
}'
)
print(response.json())C#
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer w91_live_xxx");
var request = new HttpRequestMessage(HttpMethod.Post, "https://graph.whats91.com/api/v2/chatbots/text");
request.Content = new StringContent(
"""curl -X POST \"https://graph.whats91.com/api/v2/chatbots/text\" \
-H \"Authorization: Bearer w91_public_token_here\" \
-H \"Content-Type: application/json\" \
-d '{
\"senderId\": \"916268662275\",
\"chatbot\": {
\"name\": \"Invoice Help\",
\"trigger\": {
\"type\": \"contains\",
\"keywords\": [\"invoice\", \"bill\"]
},
\"response\": {
\"text\": \"Please share your invoice number.\"
}
}
}'""",
Encoding.UTF8,
"application/json"
);
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());Related APIs
Chatbot
List Whats91 chatbot configurations for the resolved WhatsApp sender.
Get Chatbot
Retrieve one chatbot by its public chatbot UID.
Create Chatbot
Create a chatbot with the generic public v2 endpoint by providing response.type.
Media Chatbot
Create chatbot replies that include public HTTPS media assets.