Skip to content
Whats91

Create a chatbot with the generic public v2 endpoint by providing response.type.

Create Chatbot

Summary

Create a chatbot with the generic public v2 endpoint by providing response.type.

Prerequisites

  • Authorization: Bearer w91_live_xxx
  • Content-Type: application/json for JSON requests

Endpoint: POST /api/v2/chatbots. This generic create API accepts the common chatbot fields and creates the response kind specified by response.type. Use the specialized text, media, and interactive routes when you want stronger shape-specific validation.

simple

Text response

Use response.type=text with response.text for plain message replies.

media

Media response

Use response.type=media with a public HTTPS media URL.

advanced

Interactive response

Use response.type=buttons, cta, or list for structured WhatsApp replies.

config

No message send

Public v2 chatbot creation creates a bot configuration and never sends a WhatsApp message directly.

POST/api/v2/chatbots
ParameterTypeRequiredDescription
AuthorizationheaderRequiredBearer w91_public_token_here.
Content-TypeheaderRequiredMust be application/json for POST requests.
authTokenstringOptionalCompatibility body token. auth_token and token are also accepted.
senderIdstringOptionalWhatsApp sender number. Required for global tokens and optional for sender-bound tokens.
chatbot.namestringRequiredHuman-readable chatbot name.
chatbot.trigger.typestringOptionalcontains, exact, starts_with, ends_with, contains_whole_word, regex, or welcome.
chatbot.trigger.keywordsstring[]OptionalKeyword list. Required unless trigger.keyword is supplied.
chatbot.trigger.keywordstringOptionalSingle keyword shortcut. Required unless trigger.keywords is supplied.
chatbot.prioritynumberOptionalOptional priority clamped between 0 and 255.
chatbot.statusstringOptionalACTIVE or INACTIVE. Omitted status defaults to ACTIVE.
chatbot.response.typestringRequiredresponse.type decides whether the rule is text, media, buttons, cta, or list.
Generic create
curl -X POST "https://graph.whats91.com/api/v2/chatbots" \
  -H "Authorization: Bearer w91_public_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "senderId": "916268662275",
    "chatbot": {
      "name": "General Help",
      "trigger": {
        "type": "contains",
        "keywords": ["help", "support"]
      },
      "priority": 5,
      "status": "ACTIVE",
      "response": {
        "type": "text",
        "text": "How can we help you today?"
      }
    }
  }'
Create response
{
  "success": true,
  "message": "Chatbot created",
  "data": {
    "senderId": "916268662275",
    "phoneNumberId": "1043189608869917",
    "wabaId": "1605386820498470",
    "chatbot": {
      "chatbotUid": "bot_uid",
      "uid": "bot_uid",
      "name": "General Help",
      "botType": "simple",
      "triggerType": "contains",
      "replyTrigger": "help, support",
      "replyText": "How can we help you today?",
      "status": 1
    }
  },
  "metadata": {
    "apiVersion": "v2",
    "requestId": "request-uuid"
  }
}

Common Fields

FieldRequiredNotes
nameYesRequired display name for the chatbot rule.
trigger.keywordsConditionalArray of trigger words. Required unless trigger.keyword is present.
trigger.keywordConditionalSingle trigger word. Required unless trigger.keywords is present.
trigger.typeNocontains, exact, starts_with, ends_with, contains_whole_word, regex, or welcome.
priorityNoOptional number clamped between 0 and 255.
statusNoACTIVE or INACTIVE. Defaults to ACTIVE.
response.typeYestext, media, buttons, cta, or list.

Validation Errors

HTTPError codeScenario
401MISSING_AUTH_TOKENNo public API token supplied.
401INVALID_AUTH_TOKENToken is invalid, expired, revoked, or not tied to an active customer.
403SENDER_NOT_ALLOWEDNumber-scoped token attempted another sender.
403FEATURE_NOT_AVAILABLECustomer subscription does not include chatbots.
400MISSING_CHATBOTRequest body does not include chatbot.
400VALIDATION_FAILEDMissing name, trigger, response text, button labels, list rows, invalid status, or invalid CTA URL.
400WHATSAPP_SETUP_INCOMPLETESender setup could not be resolved.
415UNSUPPORTED_CONTENT_TYPEPOST request is not JSON.

Warning

Store public API tokens server-side only. Do not place customer-specific secrets inside chatbot text, button labels, ctaUrl values, sections, or rows.

SDK Examples

Use these examples as starting points for server-side implementations.

cURL
curl -X POST "https://graph.whats91.com/api/v2/chatbots" \
  -H "Authorization: Bearer w91_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
  "senderId": "916268662275",
  "chatbot": {
    "name": "General Help",
    "trigger": {
      "type": "contains",
      "keywords": [
        "help",
        "support"
      ]
    },
    "priority": 5,
    "status": "ACTIVE",
    "response": {
      "type": "text",
      "text": "How can we help you today?"
    }
  }
}'
Node.js
const response = await fetch("https://graph.whats91.com/api/v2/chatbots", {
  method: "POST",
  headers: {
    "Authorization": "Bearer w91_live_xxx",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "senderId": "916268662275",
    "chatbot": {
      "name": "General Help",
      "trigger": {
        "type": "contains",
        "keywords": [
          "help",
          "support"
        ]
      },
      "priority": 5,
      "status": "ACTIVE",
      "response": {
        "type": "text",
        "text": "How can we help you today?"
      }
    }
  })
});

const data = await response.json();
console.log(data);
PHP
$ch = curl_init("https://graph.whats91.com/api/v2/chatbots");
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([
    "senderId" => "916268662275",
    "chatbot" => [
      "name" => "General Help",
      "trigger" => [
        "type" => "contains",
        "keywords" => [
          "help",
          "support"
        ]
      ],
      "priority" => 5,
      "status" => "ACTIVE",
      "response" => [
        "type" => "text",
        "text" => "How can we help you today?"
      ]
    ]
  ])
]);

$response = curl_exec($ch);
curl_close($ch);
echo $response;
Python
import requests

response = requests.request(
    "POST",
    "https://graph.whats91.com/api/v2/chatbots",
    headers={
        "Authorization": "Bearer w91_live_xxx",
        "Content-Type": "application/json",
    },
    json={
        "senderId": "916268662275",
        "chatbot": {
            "name": "General Help",
            "trigger": {
                "type": "contains",
                "keywords": [
                    "help",
                    "support"
                ]
            },
            "priority": 5,
            "status": "ACTIVE",
            "response": {
                "type": "text",
                "text": "How can we help you today?"
            }
        }
    }
)

print(response.json())
C#
using System.Text;

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");
request.Content = new StringContent(
  """
  {
    "senderId": "916268662275",
    "chatbot": {
      "name": "General Help",
      "trigger": {
        "type": "contains",
        "keywords": [
          "help",
          "support"
        ]
      },
      "priority": 5,
      "status": "ACTIVE",
      "response": {
        "type": "text",
        "text": "How can we help you today?"
      }
    }
  }
  """,
  Encoding.UTF8,
  "application/json"
);

var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());

Related APIs