SendPoll#
This method is intended for sending messages with a poll to a private or group chat. The message will be added to the send queue. The message is stored for 24 hours in the queue and will be sent immediately after phone authorization. The rate of message dispatch from the queue is governed by the Message Sending Interval parameter.
Request#
To send, you need to make a request to the address:
POST {{APIUrl}}/waInstance{{idInstance}}/sendPoll/{{apiTokenInstance}}
To get the APIUrl
, idInstance
and apiTokenInstance
request parameters, refer to the Before You Start section.
Request Parameters#
Parameter | Type | Required | Description |
---|---|---|---|
chatId | string | Yes | Chat Identifier |
message | string | Yes | Message text. Emoji characters 😃 are supported |
options | array | Yes | Array of poll options |
multipleAnswers | boolean | No | Allow multiple answers. true - enabled, false - disabled, default: false |
quotedMessageId | string | No | If specified, the message will be sent quoting the specified chat message |
options
array fields:
Parameter | Type | Description |
---|---|---|
optionName | string | Poll choice option text |
The maximum length of the message text is 255 characters.
Poll limitations:
- the number of answer options in a poll cannot be more than 12;
- answer options must be different from each other by at least one symbol.
Example of Request Body#
Sending a message to a private chat:
{
"chatId": "11001234567@c.us",
"message": "Please choose the color:",
"options": [
{"optionName": "green"},
{"optionName": "red"},
{"optionName": "blue"}
],
"multipleAnswers": false,
}
Response#
Response Fields#
Field | Type | ОписанDescriptionие |
---|---|---|
idMessage | string | Identifier of the sent message |
Example of Response Body#
{
"idMessage": "3EB0C767D097B7C7C030"
}
Example of Display for the Receiver#
SendMessage errors#
For a list of errors common to all methods, refer to Common errors section
curl example#
curl --location --request POST '{{APIUrl}}/waInstance{{idInstance}}/sendPoll/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "11001234567@c.us",
"message": "Please choose the color:",
"options": [{"optionName": "green"}, {"optionName": "red"}, {"optionName": "blue"}]
}'
Sub SendPoll()
Dim url As String
Dim RequestBody As String
Dim http As Object
Dim response As String
' The idInstance and apiTokenInstance values are available in your account, double brackets must be removed
url = "{{APIUrl}}/waInstance{{idInstance}}/sendPoll/{{apiTokenInstance}}"
' chatId - chat identifier, message - message text, options - array of data about choice options, multipleAnswers - allow multiple answers. true - enabled, false - disabled, Default: false
RequestBody = "{""chatId"":""71234567890@c.us"",""message"":""Please choose the color:"",""options"":[{""optionName"":""green""},{""optionName"":""red""},{""optionName"":""blue""}],""multipleAnswers"":false}"
Set http = CreateObject("MSXML2.XMLHTTP")
With http
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/json"
.send RequestBody
End With
response = http.responseText
Debug.Print response
' Outputting the answer to the desired cell
Range("A1").Value = response
Set http = Nothing
End Sub