vote.Integration.Im.send
Создать и отправить голосование в чат
Описание
Метод vote.Integration.Im.send создает и отправляет голосование в указанный чат мессенджера.
Параметры
chatId
integer
обязательный
Идентификатор чата, в который отправляется голосование. Получить можно методами im.chat.add, im.chat.get, im.recent.get, im.recent.list
IM_MESSAGE_VOTE_DATA
object
обязательный
Данные голосования с вопросом и вариантами ответов. Структура описана ниже
templateId
string
необязательный
Уникальный идентификатор запроса, требований к формату нет.
Цель идентификатора — защита от дублирования. Если из-за сбоя сети запрос отправится повторно с тем же templateId, сервер поймет это и создаст опрос только один раз
Параметр IM_MESSAGE_VOTE_DATA
QUESTIONS
array
обязательный
Массив вопросов голосования, структура описана ниже. Максимум 1 вопрос
ANONYMITY
integer
необязательный
Анонимность голосования. Возможные значения:
- 0 — неанонимное голосование,
- 1 — анонимное голосование.
Значение по умолчанию: 0, публичное голосование
OPTIONS
integer
необязательный
Разрешить переголосование. Возможные значения:
- 0 — нет,
- 1 — да.
Значение по умолчанию: 0, переголосование запрещено
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"chatId":**put_chat_id**,"IM_MESSAGE_VOTE_DATA":{"QUESTIONS":[{"QUESTION":"**put_question_title**","FIELD_TYPE":0,"ANSWERS":[{"MESSAGE":"**put_message_content**"},{"MESSAGE":"**put_message_content**"},{"MESSAGE":"**put_message_content**"}]}],"ANONYMITY":0,"OPTIONS":0},"templateId":null}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/vote.Integration.Im.send
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"chatId":**put_chat_id**,"IM_MESSAGE_VOTE_DATA":{"QUESTIONS":[{"QUESTION":"**put_question_title**","FIELD_TYPE":0,"ANSWERS":[{"MESSAGE":"**put_message_content**"},{"MESSAGE":"**put_message_content**"},{"MESSAGE":"**put_message_content**"}]}],"ANONYMITY":0,"OPTIONS":0},"templateId":null,"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/vote.Integration.Im.send
// This snippet is an ES module: top-level await requires type="module" or a bundler.
// $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
import { Text } from '@bitrix24/b24jssdk'
import type { B24Frame } from '@bitrix24/b24jssdk'
declare const $b24: B24Frame
// Shape of the payload returned in result (match the "response handling" section of the page)
type VoteIntegrationImSendResult = {
messageId: number
voteId: number
}
try {
const response = await $b24.actions.v2.call.make<VoteIntegrationImSendResult>({
method: 'vote.Integration.Im.send',
params: {
chatId: 1,
IM_MESSAGE_VOTE_DATA: {
QUESTIONS: [
{
QUESTION: 'What is your favorite color?',
FIELD_TYPE: 0,
ANSWERS: [
{ MESSAGE: 'Red' },
{ MESSAGE: 'Green' },
{ MESSAGE: 'Blue' },
],
},
],
ANONYMITY: 0,
OPTIONS: 0,
},
templateId: null,
},
requestId: Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
} else {
const result = response.getData()!.result
console.info('Message ID:', result.messageId, 'Vote ID:', result.voteId)
}
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
<!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
<script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
<script>
async function sendImVote() {
try {
// Initialize the SDK inside a Bitrix24 frame
const $b24 = await B24Js.initializeB24Frame()
const response = await $b24.actions.v2.call.make({
method: 'vote.Integration.Im.send',
params: {
chatId: 1,
IM_MESSAGE_VOTE_DATA: {
QUESTIONS: [
{
QUESTION: 'What is your favorite color?',
FIELD_TYPE: 0,
ANSWERS: [
{ MESSAGE: 'Red' },
{ MESSAGE: 'Green' },
{ MESSAGE: 'Blue' },
],
},
],
ANONYMITY: 0,
OPTIONS: 0,
},
templateId: null,
},
requestId: B24Js.Text.getUuidRfc4122()
})
// The payload is available only on a successful response
if (!response.isSuccess) {
console.error(response.getErrorMessages().join('; '))
return
}
const result = response.getData().result
console.info('Message ID:', result.messageId, 'Vote ID:', result.voteId)
} catch (error) {
// Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
console.error(error)
}
}
document.addEventListener('DOMContentLoaded', sendImVote)
</script>
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.vote.integration.im.send(
chat_id=1,
im_message_vote_data={
"QUESTIONS": [
{
"QUESTION": "Question title",
"FIELD_TYPE": 0,
"ANSWERS": [
{
"MESSAGE": "Answer 1",
},
{
"MESSAGE": "Answer 2",
},
{
"MESSAGE": "Answer 3",
},
],
},
],
"ANONYMITY": 0,
"OPTIONS": 0,
},
template_id=None,
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Ошибка Bitrix API",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
print(f"Непредвиденная ошибка: {error}")
try {
$response = $b24Service
->core
->call(
'vote.Integration.Im.send',
[
'chatId' => **put_chat_id**,
'IM_MESSAGE_VOTE_DATA' => [
'QUESTIONS' => [
[
'QUESTION' => '**put_question_title**',
'FIELD_TYPE' => 0,
'ANSWERS' => [
['MESSAGE' => '**put_message_content**'],
['MESSAGE' => '**put_message_content**'],
['MESSAGE' => '**put_message_content**']
]
]
],
'ANONYMITY' => 0,
'OPTIONS' => 0
],
'templateId' => null
]
);
$result = $response
->getResponseData()
->getResult();
echo 'Success: ' . print_r($result, true);
processData($result);
} catch (Throwable $e) {
error_log($e->getMessage());
echo 'Error sending vote message: ' . $e->getMessage();
}
BX24.callMethod(
"vote.Integration.Im.send",
{
"chatId": **put_chat_id**,
"IM_MESSAGE_VOTE_DATA": {
"QUESTIONS": [
{
"QUESTION": "**put_question_title**",
"FIELD_TYPE": 0,
"ANSWERS": [
{
"MESSAGE": "**put_message_content**"
},
{
"MESSAGE": "**put_message_content**"
},
{
"MESSAGE": "**put_message_content**"
}
]
}
],
"ANONYMITY": 0,
"OPTIONS": 0
},
"templateId": null
},
function(result)
{
if(result.error())
{
console.error(result.error());
}
else
{
console.dir(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'vote.Integration.Im.send',
[
'chatId' => **put_chat_id**,
'IM_MESSAGE_VOTE_DATA' => [
'QUESTIONS' => [
[
'QUESTION' => '**put_question_title**',
'FIELD_TYPE' => 0,
'ANSWERS' => [
['MESSAGE' => '**put_message_content**'],
['MESSAGE' => '**put_message_content**'],
['MESSAGE' => '**put_message_content**']
]
]
],
'ANONYMITY' => 0,
'OPTIONS' => 0
],
'templateId' => null
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
Ответ
HTTP-статус: 200
{
"result": {
"messageId": 23,
"voteId": 7
},
"time": {
"start": 1754470016.954889,
"finish": 1754470017.043656,
"duration": 0.08876705169677734,
"processing": 0.07431983947753906,
"date_start": "2025-08-06T11:46:56+03:00",
"date_finish": "2025-08-06T11:46:57+03:00",
"operating_reset_at": 1754470616,
"operating": 0.3257129192352295
}
}
Возвращаемые данные
result
object
Корневой элемент ответа. Содержит информацию о номере сообщения и голосования, стурктура описана ниже
time
time
Информация о времени выполнения запроса
Обработка ошибок
HTTP-статус: 400
{
"error": "400",
"error_description": "Access denied"
}
| Код | Описание | Значение |
|---|---|---|
403 |
Создание опроса недоступно |
|
400 |
Введите вопрос и варианты ответов |
|
400 |
Максимальное количество вопросов: 1 |
|
400 |
Минимальное количество ответов: 2 |
|
400 |
Максимальное количество ответов: 10 |
|
400 |
Не удалось сохранить данные опроса. Попробуйте ещё раз |
|
403 |
Недостаточно прав для создания опроса |

