sendPoll
Sends a poll.
Returns: On success, returns Message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
business_connection_id | String | Optional | Business connection ID |
chat_id | Integer or String | Yes | Chat ID or @username |
message_thread_id | Integer | Optional | Forum topic ID |
question | String | Yes | Question (1-300 characters) |
question_parse_mode | String | Optional | Question parse mode: HTML, Markdown, MarkdownV2 |
question_entities | Array of MessageEntity | Optional | JSON MessageEntity array for question |
options | Array of InputPollOption | Yes | JSON InputPollOption array [{"text":"Option 1"},{"text":"Option 2"}] |
is_anonymous | Boolean | Optional | Anonymous poll (default true) |
type | String | Optional | quiz or regular |
allows_multiple_answers | Boolean | Optional | Allow multiple answers |
allows_revoting | Boolean | Optional | Allow revoting (Bot API 9.6) |
shuffle_options | Boolean | Optional | Shuffle options (Bot API 9.6) |
allow_adding_options | Boolean | Optional | Allow adding options (Bot API 9.6) |
hide_results_until_closes | Boolean | Optional | Hide results until closes (Bot API 9.6) |
members_only | Boolean | Optional | Members only (Bot API 10.0) |
country_codes | Array of String | Optional | JSON array of country codes (Bot API 10.0) |
correct_option_ids | Array of Integer | Optional | JSON array of correct option IDs (for quiz), e.g. [0] |
explanation | String | Optional | Explanation of correct answer (for quiz) |
explanation_parse_mode | String | Optional | Explanation parse mode |
explanation_entities | Array of MessageEntity | Optional | JSON MessageEntity array for explanation |
explanation_media | InputPollMedia | Optional | JSON InputPollMedia object (Bot API 10.0) |
open_period | Integer | Optional | Open poll period in seconds (5-2628000) |
close_date | Integer | Optional | Unix timestamp for poll close |
is_closed | Boolean | Optional | Close poll immediately |
description | String | Optional | Poll description (0-1024 characters, Bot API 9.6) |
description_parse_mode | String | Optional | Description parse mode: HTML, Markdown, MarkdownV2 |
description_entities | Array of MessageEntity | Optional | JSON MessageEntity array for the description |
media | InputPollMedia | Optional | JSON InputPollMedia object — poll media (Bot API 10.0) |
disable_notification | Boolean | Optional | Send silently |
protect_content | Boolean | Optional | Protect content |
allow_paid_broadcast | Boolean | Optional | Allow paid broadcast |
message_effect_id | String | Optional | Message effect ID |
reply_parameters | ReplyParameters | Optional | JSON ReplyParameters object |
reply_markup | InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply | Optional | JSON: InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendPoll" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 123456789,
"question": "Which language do you use?",
"options": [
{
"text": "Python"
},
{
"text": "JavaScript"
}
]
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendPoll",
json={
"chat_id": 123456789,
"question": "Which language do you use?",
"options": [
{
"text": "Python"
},
{
"text": "JavaScript"
}
]
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendPoll`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"question": "Which language do you use?",
"options": [
{
"text": "Python"
},
{
"text": "JavaScript"
}
]
}),
});
console.log(await res.json());
Step-by-step guide: How to Create a Telegram Bot: Step by Step with BotFather and Python
Related methods
stopPollStops a poll.