answerWidgetQuery
Answers a query from a widget (Bot API 10.4).
Returns: On success, returns True.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
widget_query_id | String | Yes | Widget query ID (widget_query.id or shared_widget_query.id) |
data | String | Optional | Data for the widget, 0-1024 bytes — returned as result of the request() promise |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/answerWidgetQuery" \
-H "Content-Type: application/json" \
-d '{"widget_query_id":"WIDGET_QUERY_ID"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/answerWidgetQuery",
json={
"widget_query_id": "WIDGET_QUERY_ID"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/answerWidgetQuery`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"widget_query_id": "WIDGET_QUERY_ID"
}),
});
console.log(await res.json());
Step-by-step guide: TelegramWidget JavaScript API: Reference, Events, Error Codes and Limits
Related methods
sendWidgetSends a message with an HTML widget (Bot API 10.4).sendSharedWidgetSends again a shared widget created by the bot (Bot API 10.4).editMessageWidgetDataEdits the data of a widget in a message (Bot API 10.4).editSharedWidgetDataEdits the public data of a shared widget (Bot API 10.4).