version: 2.1.3
sendPoll
Use this method to send a native poll. On success, the sent Message is returned.
Parameters
chat_id | int | string | Unique identifier for the target chat or username of the target channel (in the format @channelusername) | Optional |
question | string | Poll question, 1-300 characters | Yes |
options | Array of string | A JSON-serialized list of answer options, 2-10 strings 1-100 characters each | Yes |
is_anonymous | bool | True, if the poll needs to be anonymous, defaults to True | Optional |
type | string | Poll type, “quiz” or “regular”, defaults to “regular” | Optional |
allows_multiple_answers | bool | True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False | Optional |
correct_option_id | int | 0-based identifier of the correct answer option, required for polls in quiz mode | Optional |
explanation | string | 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 after entities parsing | Optional |
explanation_parse_mode | string | Mode for parsing entities in the explanation. See formatting options for more details. | Optional |
explanation_entities | Array of MessageEntity | A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of parse_mode | Optional |
open_period | int | Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date. | Optional |
close_date | int | 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 open_period. | Optional |
is_closed | bool | Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. | Optional |
disable_notification | bool | Sends the message silently. Users will receive a notification with no sound. | Optional |
protect_content | bool | Protects the contents of the sent message from forwarding and saving | Optional |
reply_to_message_id | int | If the message is a reply, ID of the original message | Optional |
allow_sending_without_reply | bool | Pass True, if the message should be sent even if the specified replied-to message is not found | Optional |
reply_markup | InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. | Optional |
token | String | You can use this method on another bot with specify this parameter | Optional |
return_array | Boolean | Specify the result type , if pass true results will be array otherwise will be object | Optional |
forgot | Boolean | You can set to not receive request result, dont set it or pass null for turn it off | Optional |
answer | Boolean | You can set to answer to webhook, dont set it or pass null for turn it off | Optional |
Method errors
ErrorName | description |
---|---|
required parameters not found | required parameter for this method is not founded. you can see them in log |
answer mode not allowed | you can use answer mode only once for each webhook update and you already did |
answer mode not allowed bc multi | you can't use answer mode when multi is on |
Method examples
$this->sendPoll(['chat_id' => int | string, 'question' => string, 'options' => Array of string, 'is_anonymous' => bool, 'type' => string, 'allows_multiple_answers' => bool, 'correct_option_id' => int, 'explanation' => string, 'explanation_parse_mode' => string, 'explanation_entities' => Array of MessageEntity, 'open_period' => int, 'close_date' => int, 'is_closed' => bool, 'disable_notification' => bool, 'protect_content' => bool, 'reply_to_message_id' => int, 'allow_sending_without_reply' => bool, 'reply_markup' => InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply]);
$this->sendPoll(['question' => string, 'options' => Array of string]);
Method alices
sendpoll
poll