Whats91
Developers

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

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
ParameterTypeRequiredDescription
AuthorizationheaderRequiredBearer w91_public_token_here.
Content-TypeheaderRequiredapplication/json.
senderIdstringOptionalWhatsApp sender number for global tokens.
chatbot.namestringRequiredName for the text chatbot.
chatbot.triggerobjectRequiredTrigger object with trigger.keyword or trigger.keywords.
chatbot.response.textstringRequiredText 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

ExampleTriggerresponse.text
Invoice Helpinvoice, billPlease share your invoice number.
Order Trackingtrack, order statusShare your order ID and we will check the latest status.
Support Hourshours, timingOur support team is available Monday to Saturday, 10 AM to 7 PM.
Lead Capturepricing, demoPlease share your name and business email so our team can call you.
Appointment Reminderappointment, bookingReply with your appointment ID to confirm or reschedule.
Return Policyreturn, refundReturns 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