### getUpdates API Request Examples Source: https://bot.zaloplatforms.com/docs/apis/getUpdates Examples for invoking the getUpdates endpoint using Node.js with axios or cURL. Ensure the Webhook is deleted before using this method. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/getUpdates`; const response = await axios.post(entrypoint, { timeout: 30 }); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/getUpdates" \ -H "Content-Type: application/json" \ -d '{ "timeout": 30 }' ``` -------------------------------- ### Retrieve Webhook Information Source: https://bot.zaloplatforms.com/docs/apis/getWebhookInfo Examples for fetching webhook configuration status using Node.js and cURL. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/getWebhookInfo`; const response = await axios.post(entrypoint, {}); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/getWebhookInfo" \ -H "Content-Type: application/json" ``` -------------------------------- ### Retrieve Bot Information Source: https://bot.zaloplatforms.com/docs/apis/getMe Use these examples to validate your Bot Token and fetch account details. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/getMe`; const response = await axios.post(entrypoint, {}); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/getMe" \ -H "Content-Type: application/json" ``` -------------------------------- ### Webhook Test Response Examples Source: https://bot.zaloplatforms.com/docs/apis/testWebhook Examples of JSON responses returned by the testWebhook API for successful and failed connectivity scenarios. ```json { "ok": true, "result": { "ok": true, "url": "https://your-webhookurl.com", "status_code": 200, "outcome": "webhook.ok", "latency_ms": 214, "hint": "Your endpoint responded successfully." } } ``` ```json { "ok": true, "result": { "ok": false, "url": "https://your-webhookurl.com", "status_code": 403, "outcome": "webhook.http.403", "latency_ms": 189, "hint": "Your server or CDN rejected the request with 403. Check WAF / Cloudflare rules, any IP allowlist, and that the User-Agent \"Java/\" is permitted." } } ``` -------------------------------- ### Send Voice Message Examples Source: https://bot.zaloplatforms.com/docs/apis/sendVoice Examples for sending a voice message using Node.js with axios or via cURL. Ensure the voice_url points to a valid .aac file. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/sendVoice`; const response = await axios.post(entrypoint, { chat_id: "abc.xyz", voice_url: "https://example.com/audio.aac" }); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/sendVoice" \ -H "Content-Type: application/json" \ -d '{ "chat_id": "abc.xyz", "voice_url": "https://example.com/audio.aac" }' ``` -------------------------------- ### Send Chat Action Request Source: https://bot.zaloplatforms.com/docs/apis/sendChatAction Examples for triggering a typing action using Node.js with axios or cURL. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/sendChatAction`; const response = await axios.post(entrypoint, { chat_id: "abc.xyz", action: "typing" }); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/sendChatAction" \ -H "Content-Type: application/json" \ -d '{ "chat_id": "abc.xyz", "action": "typing" }' ``` -------------------------------- ### Configure Webhook URL Source: https://bot.zaloplatforms.com/docs/apis/setWebhook Examples for setting the webhook URL using Node.js with axios or cURL. Ensure the URL is publicly accessible via HTTPS. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/setWebhook`; const response = await axios.post(entrypoint, { url: "https://your-webhookurl.com", secret_token: "mykey-abcyxz" }); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/setWebhook" \ -H "Content-Type: application/json" \ -d '{ "url": "https://your-webhookurl.com", "secret_token": "mykey-abcyxz" }' ``` -------------------------------- ### Send Photo via API Source: https://bot.zaloplatforms.com/docs/apis/sendPhoto Examples for sending a photo using Node.js with axios or via cURL command line. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/sendPhoto`; const response = await axios.post(entrypoint, { chat_id: "abc.xyz", caption: "My photo", photo: "https://placehold.co/600x400" }); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/sendPhoto" \ -H "Content-Type: application/json" \ -d '{ "chat_id": "abc.xyz", "caption": "My photo", "photo": "https://placehold.co/600x400" }' ``` -------------------------------- ### Test Webhook Connectivity Source: https://bot.zaloplatforms.com/docs/apis/testWebhook Use these examples to trigger a test request to your configured Webhook URL. Call this endpoint after setting your webhook or when troubleshooting delivery issues. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/testWebhook`; const response = await axios.post(entrypoint, {}); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/testWebhook" \ -H "Content-Type: application/json" ``` -------------------------------- ### Delete Webhook Implementation Source: https://bot.zaloplatforms.com/docs/apis/deleteWebhook Examples for removing webhook settings using Node.js with Axios or cURL. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/deleteWebhook`; const response = await axios.post(entrypoint, {}); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/deleteWebhook" \ -H "Content-Type: application/json" ``` -------------------------------- ### Send Sticker via Node.js and cURL Source: https://bot.zaloplatforms.com/docs/apis/sendSticker Examples for sending a sticker message using the axios library in Node.js or a standard cURL command. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/sendSticker`; const response = await axios.post(entrypoint, { chat_id: "abc.xyz", sticker: "0e078a2fb66a5f34067b" }); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/sendPhoto" \ -H "Content-Type: application/json" \ -d '{ "chat_id": "abc.xyz", "sticker": "0e078a2fb66a5f34067b" }' ``` -------------------------------- ### Handle Webhook Request in Express.js Source: https://bot.zaloplatforms.com/docs/webhook Example implementation of a webhook endpoint using Express.js, including secret token validation. ```typescript app.use(express.json()); const WEBHOOK_SECRET_TOKEN = 'your-secret-token'; + .post("/webhooks", async (req, res) => { + const secretToken = req.headers["x-bot-api-secret-token"]; + if (secretToken !== WEBHOOK_SECRET_TOKEN) { + return res.status(403).json({ message: "Unauthorized" }); + } + let body = req.body; + // Handle your logic at here + res.json({ message: "Success" }); + }) .listen(port, () => { console.log(`Server running at http://localhost:${port}`); }); ``` -------------------------------- ### Send a text message via sendMessage API Source: https://bot.zaloplatforms.com/docs/apis/sendMessage Examples for sending a text message using Node.js with axios or via cURL command. ```javascript const axios = require("axios"); const entrypoint = `https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/sendMessage`; const response = await axios.post(entrypoint, { chat_id: "abc.xyz", text: "Hello" }); ``` ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/sendMessage" \ -H "Content-Type: application/json" \ -d '{ "chat_id": "abc.xyz", "text": "Hello" }' ``` -------------------------------- ### Lập trình Zalo Bot với Python và Node.js Source: https://bot.zaloplatforms.com/docs/build-your-bot Các ví dụ triển khai bot cơ bản sử dụng Zalo Bot SDK để xử lý lệnh /start và /echo trong môi trường local. ```python from zalo_bot import Update from zalo_bot.ext import ApplicationBuilder, CommandHandler, ContextTypes # Hàm xử lý cho lệnh /start async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: await update.message.reply_text(f"Chào {update.effective_user.display_name}! Tôi là chatbot!") # Hàm xử lý cho lệnh /echo async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE): message = " ".join(context.args) if message: await update.message.reply_text(f"Bạn vừa nói: {message}") else: await update.message.reply_text("Hãy nhập gì đó sau lệnh /echo") if __name__ == "__main__": app = ApplicationBuilder().token("YOUR TOKEN HERE").build() app.add_handler(CommandHandler("start", start)) app.add_handler(CommandHandler("echo", echo)) print("🤖 Bot đang chạy...") app.run_polling() ``` ```javascript const ZaloBot = require("node-zalo-bot"); const bot = new ZaloBot("YOUR TOKEN HERE", { polling: true }); bot.onText(/\/start/, (msg, match) => { bot.sendMessage( msg.chat.id, `Chào ${msg.from.display_name}! Tôi là chatbot!` ); }); bot.onText(/\/echo (.+)/, (msg, match) => { let message = match[1]; if (message) { bot.sendMessage(msg.chat.id, `Bạn vừa nói: ${message}`); } else { bot.sendMessage(msg.chat.id, "Hãy nhập gì đó sau lệnh /echo"); } }); bot.on("message", (msg) => { console.log("Bạn vừa nhận được tin nhắn mới", msg); }); ``` -------------------------------- ### Sample Response Source: https://bot.zaloplatforms.com/docs/apis/getMe The expected JSON response structure upon a successful request. ```json { "ok": true, "result": { "id": "1459232241454765289", "account_name": "bot.VDKyGxQvc", "account_type": "BASIC", "can_join_groups": false } } ``` -------------------------------- ### POST /bot{BOT_TOKEN}/getMe Source: https://bot.zaloplatforms.com/docs/apis/getMe Verifies the provided Bot Token and returns basic information about the bot. ```APIDOC ## POST https://bot-api.zaloplatforms.com/bot{BOT_TOKEN}/getMe ### Description Use this method to check if a Bot Token is valid. If valid, it returns basic information about your bot. ### Method POST ### Endpoint https://bot-api.zaloplatforms.com/bot{BOT_TOKEN}/getMe ### Parameters No parameters are required for this request. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the request was successful. - **result** (object) - Contains bot details. - **id** (string) - The unique identifier of the bot. - **account_name** (string) - The name of the bot account. - **account_type** (string) - The type of the bot account. - **can_join_groups** (boolean) - Whether the bot can join groups. #### Response Example ```json { "ok": true, "result": { "id": "1459232241454765289", "account_name": "bot.VDKyGxQvc", "account_type": "BASIC", "can_join_groups": false } } ``` ``` -------------------------------- ### Sample Response Source: https://bot.zaloplatforms.com/docs/apis/deleteWebhook The expected JSON response structure upon successful execution of the deleteWebhook method. ```json { "ok": true, "result": { "url": "", "updated_at": 1749538250568 } } ``` -------------------------------- ### Sample API Response Source: https://bot.zaloplatforms.com/docs/apis/getWebhookInfo The expected JSON response structure when successfully calling the getWebhookInfo endpoint. ```json { "ok": true, "result": { "url": "https://your-webhookurl.com", "updated_at": 1749633372026 } } ``` -------------------------------- ### Cài đặt plugin OpenClaw ZaloBot Source: https://bot.zaloplatforms.com/docs/build-personal-assistant-with-open-claw Sử dụng lệnh npx để cài đặt plugin cần thiết cho việc kết nối OpenClaw với Zalo. ```bash npx -y @zalo-platforms/openclaw-zaloclawbot-cli install ``` -------------------------------- ### Sample API Response Source: https://bot.zaloplatforms.com/docs/apis/sendSticker The expected JSON response structure upon a successful sticker delivery. ```json { "ok": true, "result": { "message_id": "82599fa32f56d00e8941", "date": 1749632637199 } } ``` -------------------------------- ### POST https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/getWebhookInfo Source: https://bot.zaloplatforms.com/docs/apis/getWebhookInfo Retrieves the current webhook configuration status for the specified bot. ```APIDOC ## POST https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/getWebhookInfo ### Description Retrieves the current webhook configuration status, including the configured URL and the last update timestamp. ### Method POST ### Endpoint https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/getWebhookInfo ### Parameters - No parameters required. ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the request was successful. - **result** (object) - Contains the webhook configuration details. - **url** (string) - The configured webhook URL. - **updated_at** (number) - The timestamp of the last update. #### Response Example { "ok": true, "result": { "url": "https://your-webhookurl.com", "updated_at": 1749633372026 } } ``` -------------------------------- ### POST /bot${BOT_TOKEN}/setWebhook Source: https://bot.zaloplatforms.com/docs/apis/setWebhook Configures the Webhook URL for a specific bot. ```APIDOC ## POST /bot${BOT_TOKEN}/setWebhook ### Description Configures the Webhook URL for your bot. The provided URL must be publicly accessible via HTTPS. ### Method POST ### Endpoint https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/setWebhook ### Parameters #### Request Body - **url** (String) - Required - The HTTPS URL to receive notifications. - **secret_token** (String) - Required - A secret key (8-256 characters) used to authenticate requests from Zalo. It will be included in the 'X-Bot-Api-Secret-Token' header. ### Request Example { "url": "https://your-webhookurl.com", "secret_token": "mykey-abcyxz" } ### Response #### Success Response (200) - **ok** (Boolean) - Indicates if the request was successful. - **result** (Object) - Contains the updated webhook configuration and verification status. #### Response Example { "ok": true, "result": { "url": "https://your-webhookurl.com", "updated_at": 1749538250568, "verification": { "ok": true, "url": "https://your-webhookurl.com", "status_code": 200, "outcome": "webhook.ok", "latency_ms": 214, "hint": "Your endpoint responded successfully." } } } ``` -------------------------------- ### Gửi tin nhắn định dạng bằng text_styles Source: https://bot.zaloplatforms.com/docs/apis/sendMessage Áp dụng định dạng trực tiếp lên văn bản thô bằng cách chỉ định vị trí bắt đầu, độ dài và mã định dạng. ```bash curl -X POST "https://bot-api.zaloplatforms.com/bot/sendMessage" \ -H "Content-Type: application/json" \ -d '{ "chat_id": "abc.xyz", "text": "Xin chào bạn", "text_styles": [ { "start": 0, "len": 7, "st": ["b", "c_db342e"] } ] }' ``` -------------------------------- ### Xây dựng Zalo Bot với Webhook Source: https://bot.zaloplatforms.com/docs/build-your-bot-with-webhook Các ví dụ triển khai bot sử dụng Webhook để nhận và phản hồi tin nhắn từ người dùng. ```python from flask import Flask, request from zalo_bot import Bot, Update from zalo_bot.ext import Dispatcher, CommandHandler, MessageHandler, filters TOKEN = 'YOUR_ZALO_BOT_TOKEN' bot = Bot(token=TOKEN) app = Flask(__name__) # Cấu hình webhook 1 lần khi chạy lần đầu @app.before_first_request def setup_webhook(): webhook_url = 'https://your-ngrok-or-domain/webhook' bot.set_webhook(url=webhook_url) # Hàm xử lý /start def start(update: Update, context): update.message.reply_text(f"Xin chào {update.effective_user.first_name}!") # Hàm xử lý tin nhắn thường def echo(update: Update, context): update.message.reply_text(f"Bạn vừa nói: {update.message.text}") # Webhook endpoint @app.route('/webhook', methods=['POST']) def webhook(): update = Update.de_json(request.get_json(force=True), bot) dispatcher.process_update(update) return 'ok' # Gắn dispatcher và handler from zalo_bot.ext import CallbackContext dispatcher = Dispatcher(bot, None, workers=0) dispatcher.add_handler(CommandHandler('start', start)) dispatcher.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo)) if __name__ == '__main__': app.run(port=8443) ``` ```javascript const express = require("express"); const bodyParser = require("body-parser"); const ZaloBot = require("node-zalo-bot"); const app = express(); app.use(bodyParser.json()); const TOKEN = "YOUR_ZALO_BOT_TOKEN"; const WEBHOOK_URL = "https://your-ngrok-or-domain/webhook"; const bot = new ZaloBot(TOKEN, { webHook: { port: 3000 } }); bot.setWebHook(`${WEBHOOK_URL}`); // Bot xử lý khi có message gửi đến bot.on("message", (msg) => { const chatId = msg.chat.id; bot.sendMessage( chatId, `Chào bạn ${msg.from.display_name}, bạn vừa gửi: ${msg.text}` ); }); // Endpoint webhook (Zalo sẽ gửi POST request vào đây) app.post("/webhook", (req, res) => { bot.processUpdate(req.body); // cần thiết để bot hoạt động res.sendStatus(200); }); app.listen(3000, () => { console.log("Bot đang chạy trên cổng 3000"); }); ``` -------------------------------- ### API Request Format Source: https://bot.zaloplatforms.com/docs/call-api The base structure for all Zalo Bot API requests using HTTPS. ```APIDOC ## Base URL Structure ### Endpoint https://bot-api.zaloplatforms.com/bot/ ### Method GET, POST ### Parameter Transmission - **Query String**: `...?chat_id=123456&text=Hello` - **application/x-www-form-urlencoded**: Standard form data - **application/json**: JSON-object payload - **multipart/form-data**: Used for file uploads ### Response Format - **ok** (boolean) - true if successful, false if an error occurred - **result** (object) - Data returned upon success - **description** (string) - Brief error description (if applicable) - **error_code** (integer) - System error code ``` -------------------------------- ### Gửi tin nhắn định dạng bằng parse_mode Source: https://bot.zaloplatforms.com/docs/apis/sendMessage Sử dụng Markdown hoặc HTML để định dạng nội dung tin nhắn. Server sẽ tự động phân tích và áp dụng định dạng. ```javascript await axios.post(entrypoint, { chat_id: "abc.xyz", parse_mode: "markdown", text: "**Xin chào** _bạn_, đây là ~~tin nhắn~~ tin nhắn có định dạng" }); ``` ```javascript await axios.post(entrypoint, { chat_id: "abc.xyz", parse_mode: "html", text: "Xin chào bạn, đây là tin nhắn tin nhắn có định dạng" }); ``` -------------------------------- ### Webhook Event Response Structure Source: https://bot.zaloplatforms.com/docs/webhook Sample JSON response structure received from the Zalo server for a text message event. ```json { "ok": true, "result": { "message": { "from": { "id": "6ede9afa66b88fe6d6a9", "display_name": "Ted", "is_bot": false }, "chat": { "id": "6ede9afa66b88fe6d6a9", "chat_type": "PRIVATE" }, "text": "Xin chào", "message_id": "2d758cb5e222177a4e35", "date": 1750316131602 }, "event_name": "message.text.received" } } ``` -------------------------------- ### POST /bot{BOT_TOKEN}/testWebhook Source: https://bot.zaloplatforms.com/docs/apis/testWebhook Triggers a test request to the configured Webhook URL to verify connectivity and response status. ```APIDOC ## POST /bot{BOT_TOKEN}/testWebhook ### Description API allows you to immediately check if the current Webhook URL of the Bot receives requests from Zalo, helping you self-diagnose errors. ### Method POST ### Endpoint https://bot-api.zaloplatforms.com/bot{BOT_TOKEN}/testWebhook ### Parameters No parameters required. ### Response #### Success Response (200) - **ok** (Boolean) - Indicates if the API call was successful. - **result** (Object) - Contains the test outcome details. - **ok** (Boolean) - Indicates if the Webhook URL responded with a 2xx status. - **url** (String) - The Webhook URL being tested. - **status_code** (Number) - The HTTP status code returned by the Webhook URL. - **outcome** (String) - Classification code of the result. - **latency_ms** (Number) - Response time in milliseconds. - **hint** (String) - Suggestion for handling the result. #### Response Example { "ok": true, "result": { "ok": true, "url": "https://your-webhookurl.com", "status_code": 200, "outcome": "webhook.ok", "latency_ms": 214, "hint": "Your endpoint responded successfully." } } ``` -------------------------------- ### POST /bot${BOT_TOKEN}/deleteWebhook Source: https://bot.zaloplatforms.com/docs/apis/deleteWebhook Removes the webhook configuration for the specified bot. ```APIDOC ## POST /bot${BOT_TOKEN}/deleteWebhook ### Description Use this method to remove webhook integration if you decide to switch back to getUpdates. This method returns True on success. ### Method POST ### Endpoint https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/deleteWebhook ### Parameters No parameters are required. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates success status - **result** (object) - Contains webhook details #### Response Example ```json { "ok": true, "result": { "url": "", "updated_at": 1749538250568 } } ``` ``` -------------------------------- ### POST /bot${BOT_TOKEN}/getUpdates Source: https://bot.zaloplatforms.com/docs/apis/getUpdates Retrieves new messages for the bot using long polling. ```APIDOC ## POST /bot${BOT_TOKEN}/getUpdates ### Description Retrieves new messages for the bot using a long polling mechanism. Note that this method will not work if a Webhook is already configured. ### Method POST ### Endpoint https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/getUpdates ### Parameters #### Request Body - **timeout** (String) - Optional - The HTTP request timeout in seconds. Defaults to 30 seconds. ### Request Example { "timeout": 30 } ### Response #### Success Response (200) - **data** (JSON Object) - The received message data, similar in structure to Webhook events. ``` -------------------------------- ### POST https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/sendSticker Source: https://bot.zaloplatforms.com/docs/apis/sendSticker Sends a sticker message to a specific chat or user. ```APIDOC ## POST https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/sendSticker ### Description API allows your Bot to send Sticker messages to users or conversations. ### Method POST ### Endpoint https://bot-api.zaloplatforms.com/bot${BOT_TOKEN}/sendSticker ### Parameters #### Request Body - **chat_id** (String) - Required - ID of the recipient or conversation - **sticker** (String) - Required - Sticker identifier from https://stickers.zaloapp.com/ ### Request Example { "chat_id": "abc.xyz", "sticker": "0e078a2fb66a5f34067b" } ### Response #### Success Response (200) - **ok** (Boolean) - Status of the request - **result** (Object) - Contains message_id and date #### Response Example { "ok": true, "result": { "message_id": "82599fa32f56d00e8941", "date": 1749632637199 } } ``` -------------------------------- ### POST /webhooks Source: https://bot.zaloplatforms.com/docs/webhook Endpoint to receive event notifications from Zalo. The server sends a JSON payload containing event details. ```APIDOC ## POST /webhooks ### Description Receives event notifications from Zalo. The endpoint must validate the 'X-Bot-Api-Secret-Token' header against your configured secret token. ### Method POST ### Endpoint /webhooks ### Headers - **X-Bot-Api-Secret-Token** (string) - Required - The secret token configured for your bot. ### Request Body - **ok** (boolean) - Required - Always true. - **result** (object) - Required - Contains event details. - **event_name** (string) - Required - The type of event (e.g., message.text.received, message.image.received, message.sticker.received, message.voice.received, message.unsupported.received). - **message** (object) - Optional - Details about the message, including 'from', 'chat', and content fields like 'text', 'photo', 'sticker', or 'voice_url'. ### Request Example { "ok": true, "result": { "message": { "from": { "id": "6ede9afa66b88fe6d6a9", "display_name": "Ted", "is_bot": false }, "chat": { "id": "6ede9afa66b88fe6d6a9", "chat_type": "PRIVATE" }, "text": "Xin chào", "message_id": "2d758cb5e222177a4e35", "date": 1750316131602 }, "event_name": "message.text.received" } } ``` -------------------------------- ### API Response Format Source: https://bot.zaloplatforms.com/docs/apis/sendChatAction The standard JSON response returned upon a successful request. ```json { "ok": true } ``` -------------------------------- ### POST https://bot-api.zaloplatforms.com/bot{BOT_TOKEN}/sendPhoto Source: https://bot.zaloplatforms.com/docs/apis/sendPhoto Sends an image message to a specified chat ID. ```APIDOC ## POST https://bot-api.zaloplatforms.com/bot{BOT_TOKEN}/sendPhoto ### Description API allows your Bot to send image messages to users or chats. ### Method POST ### Endpoint https://bot-api.zaloplatforms.com/bot{BOT_TOKEN}/sendPhoto ### Parameters #### Request Body - **chat_id** (String) - Required - ID of the recipient or chat. - **photo** (String) - Required - URL of the image to be sent. - **caption** (String) - Optional - Text content to be sent with the image (1-2000 characters). ### Request Example { "chat_id": "abc.xyz", "caption": "My photo", "photo": "https://placehold.co/600x400" } ### Response #### Success Response (200) - **ok** (Boolean) - Status of the request. - **result** (Object) - Contains message_id and date. #### Response Example { "ok": true, "result": { "message_id": "82599fa32f56d00e8941", "date": 1749632637199 } } ```