Create chatbot replies that include public HTTPS media assets.
Media Chatbot
Summary
Create chatbot replies that include public HTTPS media assets.
Prerequisites
- Authorization: Bearer w91_live_xxx
- Content-Type: application/json for JSON requests
Related documentation
Endpoint: POST /api/v2/chatbots/media. Media chatbots support IMAGE, VIDEO, AUDIO, and DOCUMENT. The media URL must be public HTTPS so Whats91 and Meta can fetch it when the chatbot replies.
POST
/api/v2/chatbots/media| 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 media chatbot. |
chatbot.trigger | object | Required | Trigger object with trigger.keyword or trigger.keywords. |
chatbot.response.text | string | Optional | Optional caption or intro text. |
chatbot.response.media.type | string | Required | IMAGE, VIDEO, AUDIO, or DOCUMENT. |
chatbot.response.media.url | string | Required | Public HTTPS URL for the media asset. |
chatbot.response.media.fileName | string | Optional | Recommended for DOCUMENT responses. |
Create media chatbot
curl -X POST "https://graph.whats91.com/api/v2/chatbots/media" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Catalog PDF",
"trigger": { "keyword": "catalog" },
"response": {
"text": "Here is our latest catalog.",
"media": {
"type": "DOCUMENT",
"url": "https://cdn.example.com/catalog.pdf",
"fileName": "catalog.pdf"
}
}
}
}'Media response
{
"success": true,
"message": "Chatbot created",
"data": {
"senderId": "916268662275",
"chatbot": {
"chatbotUid": "bot_catalog_pdf",
"name": "Catalog PDF",
"botType": "media",
"replyTrigger": "catalog",
"replyText": "Here is our latest catalog.",
"media": {
"type": "DOCUMENT",
"url": "https://cdn.example.com/catalog.pdf",
"fileName": "catalog.pdf"
},
"status": 1
}
},
"metadata": {
"apiVersion": "v2",
"requestId": "request-uuid"
}
}Supported Media
| Media type | Common use case | Notes |
|---|---|---|
| IMAGE | Product photo, offer banner, ticket QR image | Use a public HTTPS image URL. |
| VIDEO | Product demo, onboarding walkthrough | Use a public HTTPS video URL that Meta can fetch. |
| AUDIO | Voice note, recorded instructions | Use a public HTTPS audio URL. |
| DOCUMENT | Catalog, invoice, policy PDF | Include fileName for a clearer WhatsApp document attachment. |
Rejected Media Inputs
- http:// URLs are rejected because media must use public HTTPS.
- localhost, private IP, and .local URLs are rejected because Meta cannot fetch them.
- metaMediaId, mediaId, or other pre-uploaded Meta media references are rejected.
- base64 strings, file paths, multipart upload fields, and direct uploads are rejected.
- Missing media returns MISSING_CHATBOT_MEDIA; invalid media URL or type returns INVALID_CHATBOT_MEDIA.
Practical Media Examples
| Example | Media type | Trigger | Response pattern |
|---|---|---|---|
| Catalog PDF | DOCUMENT | catalog | Send a current product catalog PDF. |
| Product Image | IMAGE | photo, image | Send a product image with a short caption. |
| Demo Video | VIDEO | demo, walkthrough | Send a public demo video link as the reply media. |
| Audio Guide | AUDIO | audio help | Send recorded setup instructions. |
| Invoice Attachment | DOCUMENT | invoice copy | Send a generated invoice PDF URL. |
| Warranty Document | DOCUMENT | warranty | Send policy terms with fileName warranty.pdf. |
SDK Examples
Use these examples as starting points for server-side implementations.
cURL
curl -X POST "https://graph.whats91.com/api/v2/chatbots/media" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d 'curl -X POST "https://graph.whats91.com/api/v2/chatbots/media" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Catalog PDF",
"trigger": { "keyword": "catalog" },
"response": {
"text": "Here is our latest catalog.",
"media": {
"type": "DOCUMENT",
"url": "https://cdn.example.com/catalog.pdf",
"fileName": "catalog.pdf"
}
}
}
}''Node.js
const response = await fetch("https://graph.whats91.com/api/v2/chatbots/media", {
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/media" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Catalog PDF",
"trigger": { "keyword": "catalog" },
"response": {
"text": "Here is our latest catalog.",
"media": {
"type": "DOCUMENT",
"url": "https://cdn.example.com/catalog.pdf",
"fileName": "catalog.pdf"
}
}
}
}')
});
const data = await response.json();
console.log(data);PHP
$ch = curl_init("https://graph.whats91.com/api/v2/chatbots/media");
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/media" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Catalog PDF",
"trigger": { "keyword": "catalog" },
"response": {
"text": "Here is our latest catalog.",
"media": {
"type": "DOCUMENT",
"url": "https://cdn.example.com/catalog.pdf",
"fileName": "catalog.pdf"
}
}
}
}')
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;Python
import requests
response = requests.request(
"POST",
"https://graph.whats91.com/api/v2/chatbots/media",
headers={
"Authorization": "Bearer w91_live_xxx",
"Content-Type": "application/json",
},
json=curl -X POST "https://graph.whats91.com/api/v2/chatbots/media" \
-H "Authorization: Bearer w91_public_token_here" \
-H "Content-Type: application/json" \
-d '{
"senderId": "916268662275",
"chatbot": {
"name": "Catalog PDF",
"trigger": { "keyword": "catalog" },
"response": {
"text": "Here is our latest catalog.",
"media": {
"type": "DOCUMENT",
"url": "https://cdn.example.com/catalog.pdf",
"fileName": "catalog.pdf"
}
}
}
}'
)
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/media");
request.Content = new StringContent(
"""curl -X POST \"https://graph.whats91.com/api/v2/chatbots/media\" \
-H \"Authorization: Bearer w91_public_token_here\" \
-H \"Content-Type: application/json\" \
-d '{
\"senderId\": \"916268662275\",
\"chatbot\": {
\"name\": \"Catalog PDF\",
\"trigger\": { \"keyword\": \"catalog\" },
\"response\": {
\"text\": \"Here is our latest catalog.\",
\"media\": {
\"type\": \"DOCUMENT\",
\"url\": \"https://cdn.example.com/catalog.pdf\",
\"fileName\": \"catalog.pdf\"
}
}
}
}'""",
Encoding.UTF8,
"application/json"
);
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());