Telegram Bot API
🌐 Tiếng Việt

answerCallbackQuery

Danh mục: Callback · Bot API 10.3 · Tài liệu chính thức

Trả lời truy vấn callback.

Giá trị trả về: Nếu thành công, trả về True.

Tham số

Tham sốKiểuBắt buộcMô tả
callback_query_idStringCóID truy vấn callback
textStringTùy chọnNội dung thông báo (0-200)
show_alertBooleanTùy chọnHiển thị hộp thoại cảnh báo thay vì thông báo ngắn
urlStringTùy chọnURL cần mở (URL trò chơi hoặc liên kết t.me)
cache_timeIntegerTùy chọnThời gian cache tính bằng giây

Mô tả tham số chỉ là bản tóm tắt ngắn gọn; xem tài liệu chính thức để đọc toàn văn.

Ví dụ request

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/answerCallbackQuery" \
  -H "Content-Type: application/json" \
  -d '{"callback_query_id":"CALLBACK_QUERY_ID"}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/answerCallbackQuery",
    json={
        "callback_query_id": "CALLBACK_QUERY_ID"
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/answerCallbackQuery`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "callback_query_id": "CALLBACK_QUERY_ID"
  }),
});
console.log(await res.json());

Hướng dẫn từng bước: API gửi tin nhắn Telegram: hướng dẫn sendMessage với curl, Python và JavaScript