answerCallbackQuery
콜백 쿼리에 응답합니다.
반환값: 성공 시 반환값: True.
매개변수
| 매개변수 | 타입 | 필수 | 설명 |
|---|---|---|---|
callback_query_id | String | 예 | 콜백 쿼리 ID |
text | String | 선택 | 알림 텍스트 (0-200) |
show_alert | Boolean | 선택 | 토스트 대신 알림창 표시 |
url | String | 선택 | 열 URL (게임 URL 또는 t.me 링크) |
cache_time | Integer | 선택 | 캐시 시간(초) |
요청 예제
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());
단계별 가이드: 텔레그램 봇 API로 메시지 보내기: sendMessage 사용법과 예제
관련 메서드
answerInlineQuery인라인 쿼리에 응답합니다.answerGuestQuery게스트 모드에서 게스트 쿼리에 응답합니다 (Bot API 10.0).answerWebAppQueryWeb App 상호작용 결과를 전송합니다.answerChatJoinRequestQuery채팅 가입 요청 쿼리에 응답합니다 (Bot API 10.1).sendChatJoinRequestWebApp채팅 가입 요청 쿼리에 대해 Mini App을 표시합니다 (Bot API 10.1).