2022-02-24 19:51:11 +01:00
<!DOCTYPE html>
< html class = "" >
< head >
< meta charset = "utf-8" >
< title > Poll< / title >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
2022-03-10 21:15:11 +01:00
< meta property = "description" content = "Telegram allows sending polls and quizzes, that can be voted on by thousands, if not millions of users in chats and channels." >
2022-02-24 19:51:11 +01:00
< meta property = "og:title" content = "Poll" >
< meta property = "og:image" content = "" >
2022-03-10 21:15:11 +01:00
< meta property = "og:description" content = "Telegram allows sending polls and quizzes, that can be voted on by thousands, if not millions of users in chats and channels." >
2022-04-21 15:52:36 +02:00
< link rel = "icon" type = "image/svg+xml" href = "/img/website_icon.svg?4" >
< link rel = "apple-touch-icon" sizes = "180x180" href = "/img/apple-touch-icon.png" >
< link rel = "icon" type = "image/png" sizes = "32x32" href = "/img/favicon-32x32.png" >
< link rel = "icon" type = "image/png" sizes = "16x16" href = "/img/favicon-16x16.png" >
< link rel = "alternate icon" href = "/img/favicon.ico" type = "image/x-icon" / >
2022-02-24 19:51:11 +01:00
< link href = "/css/bootstrap.min.css?3" rel = "stylesheet" >
2023-03-20 12:08:32 +01:00
< link href = "/css/telegram.css?236" rel = "stylesheet" media = "screen" >
2022-02-24 19:51:11 +01:00
< style >
< / style >
< / head >
< body class = "preload" >
< div class = "dev_page_wrap" >
< div class = "dev_page_head navbar navbar-static-top navbar-tg" >
< div class = "navbar-inner" >
< div class = "container clearfix" >
< ul class = "nav navbar-nav navbar-right hidden-xs" > < li class = "navbar-twitter" > < a href = "https://twitter.com/telegram" target = "_blank" data-track = "Follow/Twitter" onclick = "trackDlClick(this, event)" > < i class = "icon icon-twitter" > < / i > < span > Twitter< / span > < / a > < / li > < / ul >
< ul class = "nav navbar-nav" >
< li > < a href = "//telegram.org/" > Home< / a > < / li >
< li class = "hidden-xs" > < a href = "//telegram.org/faq" > FAQ< / a > < / li >
< li class = "hidden-xs" > < a href = "//telegram.org/apps" > Apps< / a > < / li >
< li class = "active" > < a href = "/api" > API< / a > < / li >
< li class = "" > < a href = "/mtproto" > Protocol< / a > < / li >
< li class = "" > < a href = "/schema" > Schema< / a > < / li >
< / ul >
< / div >
< / div >
< / div >
< div class = "container clearfix" >
< div class = "dev_page" >
< div id = "dev_page_content_wrap" class = " " >
< div class = "dev_page_bread_crumbs" > < ul class = "breadcrumb clearfix" > < li > < a href = "/api" > API< / a > < / li > < i class = "icon icon-breadcrumb-divider" > < / i > < li > < a href = "/api/poll" > Poll< / a > < / li > < / ul > < / div >
< h1 id = "dev_page_title" > Poll< / h1 >
< div id = "dev_page_content" > <!-- scroll_nav -->
2022-03-10 21:15:11 +01:00
< p > Telegram allows sending polls and quizzes, that can be voted on by thousands, if not millions of users in chats and channels.< / p >
2022-02-24 19:51:11 +01:00
< h3 > < a class = "anchor" href = "#sending-a-poll" id = "sending-a-poll" name = "sending-a-poll" > < i class = "anchor-icon" > < / i > < / a > Sending a poll< / h3 >
< pre > < code > < a href = '/constructor/pollAnswer' > pollAnswer< / a > #6ca9c2e9 text:< a href = '/type/string' > string< / a > option:< a href = '/type/bytes' > bytes< / a > = < a href = '/type/PollAnswer' > PollAnswer< / a > ;
< a href = '/constructor/poll' > poll< / a > #86e18161 id:< a href = '/type/long' > long< / a > flags:< a href = '/type/%23' > #< / a > closed:flags.0?< a href = '/constructor/true' > true< / a > public_voters:flags.1?< a href = '/constructor/true' > true< / a > multiple_choice:flags.2?< a href = '/constructor/true' > true< / a > quiz:flags.3?< a href = '/constructor/true' > true< / a > question:< a href = '/type/string' > string< / a > answers:< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/PollAnswer' > PollAnswer< / a > > close_period:flags.4?< a href = '/type/int' > int< / a > close_date:flags.5?< a href = '/type/int' > int< / a > = < a href = '/type/Poll' > Poll< / a > ;
< a href = '/constructor/inputMediaPoll' > inputMediaPoll< / a > #f94e5f1 flags:< a href = '/type/%23' > #< / a > poll:< a href = '/type/Poll' > Poll< / a > correct_answers:flags.0?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/bytes' > bytes< / a > > solution:flags.1?< a href = '/type/string' > string< / a > solution_entities:flags.1?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/MessageEntity' > MessageEntity< / a > > = < a href = '/type/InputMedia' > InputMedia< / a > ;
---functions---
2024-02-10 15:36:22 +01:00
< a href = '/method/messages.sendMedia' > messages.sendMedia< / a > #72ccc23d flags:< a href = '/type/%23' > #< / a > silent:flags.5?< a href = '/constructor/true' > true< / a > background:flags.6?< a href = '/constructor/true' > true< / a > clear_draft:flags.7?< a href = '/constructor/true' > true< / a > noforwards:flags.14?< a href = '/constructor/true' > true< / a > update_stickersets_order:flags.15?< a href = '/constructor/true' > true< / a > invert_media:flags.16?< a href = '/constructor/true' > true< / a > peer:< a href = '/type/InputPeer' > InputPeer< / a > reply_to:flags.0?< a href = '/type/InputReplyTo' > InputReplyTo< / a > media:< a href = '/type/InputMedia' > InputMedia< / a > message:< a href = '/type/string' > string< / a > random_id:< a href = '/type/long' > long< / a > reply_markup:flags.2?< a href = '/type/ReplyMarkup' > ReplyMarkup< / a > entities:flags.3?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/MessageEntity' > MessageEntity< / a > > schedule_date:flags.10?< a href = '/type/int' > int< / a > send_as:flags.13?< a href = '/type/InputPeer' > InputPeer< / a > = < a href = '/type/Updates' > Updates< / a > ;< / code > < / pre >
2022-02-24 19:51:11 +01:00
< p > To send a poll in a chat, call < a href = "/method/messages.sendMedia" > messages.sendMedia< / a > , providing an < a href = "/constructor/inputMediaPoll" > inputMediaPoll< / a > :< / p >
< ul >
< li >
< p > < code > poll< / code > is the actual < a href = "/constructor/poll" > poll constructor< / a > , containing:< / p >
< ul >
< li > < code > question< / code > - The poll title, aka the poll's title< / li >
< li > < code > answers< / code > - A vector of possible answers (2-10), each with a visible title < code > text< / code > , and a unique < code > option< / code > identifier (1-100 bytes)< / li >
< li > < code > closed< / code > - Whether the poll is closed< / li >
< li > < code > public_voters< / code > - Whether cast votes are publicly visible to all users (non-anonymous poll) < / li >
< li > < code > multiple_choice< / code > - Whether multiple options can be chosen as answer< / li >
< li > < code > quiz< / code > - Whether this is a quiz with correct answer IDs specified in < code > inputMediaPoll.correct_answers< / code > < / li >
< li > < code > close_period< / code > - Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with < code > close_date< / code > .< / li >
< li > < code > close_date< / code > - Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future; can't be used together with < code > close_period< / code > . < br >
These last two parameters are exactly the same, except that one uses absolute, the other relative unixtime.< / li >
< / ul >
< / li >
< li >
2022-03-10 21:15:11 +01:00
< p > < code > correct_answers< / code > - For quizzes, option ID of the only correct answer< / p >
2022-02-24 19:51:11 +01:00
< / li >
< li >
< p > < code > solution< / code > - Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds< / p >
< / li >
< li >
< p > < code > solution_entities< / code > - < a href = "/api/entities" > Styled text message entities< / a > for the < code > solution< / code > explanation< / p >
< / li >
< / ul >
< p > In order to prematurely close the poll, preventing further votes, use < a href = "/method/messages.editMessage" > messages.editMessage< / a > , setting the < code > poll.closed< / code > flag to true. < / p >
< h3 > < a class = "anchor" href = "#voting-in-polls" id = "voting-in-polls" name = "voting-in-polls" > < i class = "anchor-icon" > < / i > < / a > Voting in polls< / h3 >
< pre > < code > < a href = '/constructor/pollAnswerVoters' > pollAnswerVoters< / a > #3b6ddad2 flags:< a href = '/type/%23' > #< / a > chosen:flags.0?< a href = '/constructor/true' > true< / a > correct:flags.1?< a href = '/constructor/true' > true< / a > option:< a href = '/type/bytes' > bytes< / a > voters:< a href = '/type/int' > int< / a > = < a href = '/type/PollAnswerVoters' > PollAnswerVoters< / a > ;
2024-02-10 15:36:22 +01:00
< a href = '/constructor/pollResults' > pollResults< / a > #7adf2420 flags:< a href = '/type/%23' > #< / a > min:flags.0?< a href = '/constructor/true' > true< / a > results:flags.1?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/PollAnswerVoters' > PollAnswerVoters< / a > > total_voters:flags.2?< a href = '/type/int' > int< / a > recent_voters:flags.3?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/Peer' > Peer< / a > > solution:flags.4?< a href = '/type/string' > string< / a > solution_entities:flags.4?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/MessageEntity' > MessageEntity< / a > > = < a href = '/type/PollResults' > PollResults< / a > ;
2022-02-24 19:51:11 +01:00
< a href = '/constructor/poll' > poll< / a > #86e18161 id:< a href = '/type/long' > long< / a > flags:< a href = '/type/%23' > #< / a > closed:flags.0?< a href = '/constructor/true' > true< / a > public_voters:flags.1?< a href = '/constructor/true' > true< / a > multiple_choice:flags.2?< a href = '/constructor/true' > true< / a > quiz:flags.3?< a href = '/constructor/true' > true< / a > question:< a href = '/type/string' > string< / a > answers:< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/PollAnswer' > PollAnswer< / a > > close_period:flags.4?< a href = '/type/int' > int< / a > close_date:flags.5?< a href = '/type/int' > int< / a > = < a href = '/type/Poll' > Poll< / a > ;
< a href = '/constructor/messageMediaPoll' > messageMediaPoll< / a > #4bd6e798 poll:< a href = '/type/Poll' > Poll< / a > results:< a href = '/type/PollResults' > PollResults< / a > = < a href = '/type/MessageMedia' > MessageMedia< / a > ;
< a href = '/constructor/updateMessagePoll' > updateMessagePoll< / a > #aca1657b flags:< a href = '/type/%23' > #< / a > poll_id:< a href = '/type/long' > long< / a > poll:flags.0?< a href = '/type/Poll' > Poll< / a > results:< a href = '/type/PollResults' > PollResults< / a > = < a href = '/type/Update' > Update< / a > ;
---functions---
< a href = '/method/messages.sendVote' > messages.sendVote< / a > #10ea6184 peer:< a href = '/type/InputPeer' > InputPeer< / a > msg_id:< a href = '/type/int' > int< / a > options:< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/bytes' > bytes< / a > > = < a href = '/type/Updates' > Updates< / a > ;< / code > < / pre >
< p > When receiving a < a href = "/constructor/message" > message< / a > with a < a href = "/constructor/messageMediaPoll" > messageMediaPoll< / a > , users can vote in it using < a href = "/method/messages.sendVote" > messages.sendVote< / a > , specifying the chosen < code > option< / code > identifiers. < / p >
< p > The method will return an < a href = "/constructor/updateMessagePoll" > updateMessagePoll< / a > , containing an updated < a href = "/constructor/pollResults" > pollResults< / a > constructor, with the < code > chosen< / code > flag set on the options we chose, and the < code > correct< / code > flag set on the correct answers. < / p >
< h3 > < a class = "anchor" href = "#getting-poll-votes" id = "getting-poll-votes" name = "getting-poll-votes" > < i class = "anchor-icon" > < / i > < / a > Getting poll votes< / h3 >
< pre > < code > < a href = '/constructor/pollAnswerVoters' > pollAnswerVoters< / a > #3b6ddad2 flags:< a href = '/type/%23' > #< / a > chosen:flags.0?< a href = '/constructor/true' > true< / a > correct:flags.1?< a href = '/constructor/true' > true< / a > option:< a href = '/type/bytes' > bytes< / a > voters:< a href = '/type/int' > int< / a > = < a href = '/type/PollAnswerVoters' > PollAnswerVoters< / a > ;
2024-02-10 15:36:22 +01:00
< a href = '/constructor/pollResults' > pollResults< / a > #7adf2420 flags:< a href = '/type/%23' > #< / a > min:flags.0?< a href = '/constructor/true' > true< / a > results:flags.1?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/PollAnswerVoters' > PollAnswerVoters< / a > > total_voters:flags.2?< a href = '/type/int' > int< / a > recent_voters:flags.3?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/Peer' > Peer< / a > > solution:flags.4?< a href = '/type/string' > string< / a > solution_entities:flags.4?< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/MessageEntity' > MessageEntity< / a > > = < a href = '/type/PollResults' > PollResults< / a > ;
2022-02-24 19:51:11 +01:00
< a href = '/constructor/updateMessagePoll' > updateMessagePoll< / a > #aca1657b flags:< a href = '/type/%23' > #< / a > poll_id:< a href = '/type/long' > long< / a > poll:flags.0?< a href = '/type/Poll' > Poll< / a > results:< a href = '/type/PollResults' > PollResults< / a > = < a href = '/type/Update' > Update< / a > ;
---functions---
< a href = '/method/messages.getPollResults' > messages.getPollResults< / a > #73bb643b peer:< a href = '/type/InputPeer' > InputPeer< / a > msg_id:< a href = '/type/int' > int< / a > = < a href = '/type/Updates' > Updates< / a > ;< / code > < / pre >
< p > Regularly, if new users have voted in polls available to the user, they will receive an < a href = "/constructor/updateMessagePoll" > updateMessagePoll< / a > , with updated < a href = "/constructor/pollResults" > pollResults< / a > . < / p >
< p > The same constructor can also be fetched manually using < a href = "/method/messages.getPollResults" > messages.getPollResults< / a > .< / p >
< h3 > < a class = "anchor" href = "#getting-poll-voters-in-non-anonymous-polls" id = "getting-poll-voters-in-non-anonymous-polls" name = "getting-poll-voters-in-non-anonymous-polls" > < i class = "anchor-icon" > < / i > < / a > Getting poll voters in non-anonymous polls< / h3 >
2024-02-10 15:36:22 +01:00
< pre > < code > < a href = '/constructor/messagePeerVote' > messagePeerVote< / a > #b6cc2d5c peer:< a href = '/type/Peer' > Peer< / a > option:< a href = '/type/bytes' > bytes< / a > date:< a href = '/type/int' > int< / a > = < a href = '/type/MessagePeerVote' > MessagePeerVote< / a > ;
< a href = '/constructor/messagePeerVoteInputOption' > messagePeerVoteInputOption< / a > #74cda504 peer:< a href = '/type/Peer' > Peer< / a > date:< a href = '/type/int' > int< / a > = < a href = '/type/MessagePeerVote' > MessagePeerVote< / a > ;
< a href = '/constructor/messagePeerVoteMultiple' > messagePeerVoteMultiple< / a > #4628f6e6 peer:< a href = '/type/Peer' > Peer< / a > options:< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/bytes' > bytes< / a > > date:< a href = '/type/int' > int< / a > = < a href = '/type/MessagePeerVote' > MessagePeerVote< / a > ;
2022-02-24 19:51:11 +01:00
2024-02-10 15:36:22 +01:00
< a href = '/constructor/messages.votesList' > messages.votesList< / a > #4899484e flags:< a href = '/type/%23' > #< / a > count:< a href = '/type/int' > int< / a > votes:< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/MessagePeerVote' > MessagePeerVote< / a > > chats:< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/Chat' > Chat< / a > > users:< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/User' > User< / a > > next_offset:flags.0?< a href = '/type/string' > string< / a > = < a href = '/type/messages.VotesList' > messages.VotesList< / a > ;
2022-02-24 19:51:11 +01:00
2024-02-10 15:36:22 +01:00
< a href = '/constructor/updateMessagePollVote' > updateMessagePollVote< / a > #24f40e77 poll_id:< a href = '/type/long' > long< / a > peer:< a href = '/type/Peer' > Peer< / a > options:< a href = '/type/Vector%20t' > Vector< / a > < < a href = '/type/bytes' > bytes< / a > > qts:< a href = '/type/int' > int< / a > = < a href = '/type/Update' > Update< / a > ;
2022-02-24 19:51:11 +01:00
---functions---
< a href = '/method/messages.getPollVotes' > messages.getPollVotes< / a > #b86e380e flags:< a href = '/type/%23' > #< / a > peer:< a href = '/type/InputPeer' > InputPeer< / a > id:< a href = '/type/int' > int< / a > option:flags.0?< a href = '/type/bytes' > bytes< / a > offset:flags.1?< a href = '/type/string' > string< / a > limit:< a href = '/type/int' > int< / a > = < a href = '/type/messages.VotesList' > messages.VotesList< / a > ; < / code > < / pre >
< p > < a href = "/method/messages.getPollVotes" > messages.getPollVotes< / a > can be used to get poll results for non-anonymous polls, to see how each user voted for a poll option.< br >
Bots will also receive an < a href = "/constructor/updateMessagePollVote" > updateMessagePollVote< / a > every time a user their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.< / p > < / div >
< / div >
< / div >
< / div >
< div class = "footer_wrap" >
< div class = "footer_columns_wrap footer_desktop" >
< div class = "footer_column footer_column_telegram" >
< h5 > Telegram< / h5 >
< div class = "footer_telegram_description" > < / div >
Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed.
< / div >
< div class = "footer_column" >
< h5 > < a href = "//telegram.org/faq" > About< / a > < / h5 >
< ul >
< li > < a href = "//telegram.org/faq" > FAQ< / a > < / li >
2022-09-09 12:10:24 +02:00
< li > < a href = "//telegram.org/privacy" > Privacy< / a > < / li >
2022-09-09 23:58:59 +02:00
< li > < a href = "//telegram.org/press" > Press< / a > < / li >
2022-02-24 19:51:11 +01:00
< / ul >
< / div >
< div class = "footer_column" >
< h5 > < a href = "//telegram.org/apps#mobile-apps" > Mobile Apps< / a > < / h5 >
< ul >
< li > < a href = "//telegram.org/dl/ios" > iPhone/iPad< / a > < / li >
2022-09-09 23:58:59 +02:00
< li > < a href = "//telegram.org/android" > Android< / a > < / li >
< li > < a href = "//telegram.org/dl/web" > Mobile Web< / a > < / li >
2022-02-24 19:51:11 +01:00
< / ul >
< / div >
< div class = "footer_column" >
< h5 > < a href = "//telegram.org/apps#desktop-apps" > Desktop Apps< / a > < / h5 >
< ul >
< li > < a href = "//desktop.telegram.org/" > PC/Mac/Linux< / a > < / li >
< li > < a href = "//macos.telegram.org/" > macOS< / a > < / li >
< li > < a href = "//telegram.org/dl/web" > Web-browser< / a > < / li >
< / ul >
< / div >
< div class = "footer_column footer_column_platform" >
< h5 > < a href = "/" > Platform< / a > < / h5 >
< ul >
< li > < a href = "/api" > API< / a > < / li >
< li > < a href = "//translations.telegram.org/" > Translations< / a > < / li >
< li > < a href = "//instantview.telegram.org/" > Instant View< / a > < / li >
< / ul >
< / div >
< / div >
< div class = "footer_columns_wrap footer_mobile" >
< div class = "footer_column" >
< h5 > < a href = "//telegram.org/faq" > About< / a > < / h5 >
< / div >
< div class = "footer_column" >
< h5 > < a href = "//telegram.org/blog" > Blog< / a > < / h5 >
< / div >
< div class = "footer_column" >
< h5 > < a href = "//telegram.org/apps" > Apps< / a > < / h5 >
< / div >
< div class = "footer_column" >
< h5 > < a href = "/" > Platform< / a > < / h5 >
< / div >
< div class = "footer_column" >
2024-02-15 06:44:06 +01:00
< h5 > < a href = "//telegram.org/press" > Press< / a > < / h5 >
2022-02-24 19:51:11 +01:00
< / div >
< / div >
< / div >
< / div >
2022-12-10 23:50:15 +01:00
< script src = "/js/main.js?47" > < / script >
2022-02-24 19:51:11 +01:00
< script src = "/js/jquery.min.js?1" > < / script >
< script src = "/js/bootstrap.min.js?1" > < / script >
< script > w i n d o w . i n i t D e v P a g e N a v & & i n i t D e v P a g e N a v ( ) ;
backToTopInit("Go up");
removePreloadInit();
< / script >
< / body >
< / html >