Whats91
Developers

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

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
ParameterTypeRequiredDescription
AuthorizationheaderRequiredBearer w91_public_token_here.
Content-TypeheaderRequiredapplication/json.
senderIdstringOptionalWhatsApp sender number for global tokens.
chatbot.namestringRequiredName for the media chatbot.
chatbot.triggerobjectRequiredTrigger object with trigger.keyword or trigger.keywords.
chatbot.response.textstringOptionalOptional caption or intro text.
chatbot.response.media.typestringRequiredIMAGE, VIDEO, AUDIO, or DOCUMENT.
chatbot.response.media.urlstringRequiredPublic HTTPS URL for the media asset.
chatbot.response.media.fileNamestringOptionalRecommended 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 typeCommon use caseNotes
IMAGEProduct photo, offer banner, ticket QR imageUse a public HTTPS image URL.
VIDEOProduct demo, onboarding walkthroughUse a public HTTPS video URL that Meta can fetch.
AUDIOVoice note, recorded instructionsUse a public HTTPS audio URL.
DOCUMENTCatalog, invoice, policy PDFInclude 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

ExampleMedia typeTriggerResponse pattern
Catalog PDFDOCUMENTcatalogSend a current product catalog PDF.
Product ImageIMAGEphoto, imageSend a product image with a short caption.
Demo VideoVIDEOdemo, walkthroughSend a public demo video link as the reply media.
Audio GuideAUDIOaudio helpSend recorded setup instructions.
Invoice AttachmentDOCUMENTinvoice copySend a generated invoice PDF URL.
Warranty DocumentDOCUMENTwarrantySend 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());

Related APIs