send_poll
Create and send interactive polls to Telegram channels with customizable questions, multiple options, and anonymous voting settings for gathering feedback and engagement.
Instructions
Create and send a poll to the Telegram channel
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| is_anonymous | No | Whether the poll is anonymous | |
| options | Yes | Poll options (2-10 items) | |
| question | Yes | Poll question | |
| type | No | Poll type | regular |
Input Schema (JSON Schema)
{
"properties": {
"is_anonymous": {
"default": true,
"description": "Whether the poll is anonymous",
"type": "boolean"
},
"options": {
"description": "Poll options (2-10 items)",
"items": {
"type": "string"
},
"maxItems": 10,
"minItems": 2,
"type": "array"
},
"question": {
"description": "Poll question",
"type": "string"
},
"type": {
"default": "regular",
"description": "Poll type",
"enum": [
"quiz",
"regular"
],
"type": "string"
}
},
"required": [
"question",
"options"
],
"type": "object"
}
Implementation Reference
- src/index.ts:376-401 (handler)The switch case handler that executes the 'send_poll' tool. It destructures arguments, validates the number of options, sends the poll via Telegram bot, and returns a formatted success response.case 'send_poll': { const { question, options, is_anonymous = true, type = 'regular' } = args as { question: string; options: string[]; is_anonymous?: boolean; type?: string; }; if (options.length < 2 || options.length > 10) { throw new Error('Poll must have between 2 and 10 options'); } const result = await bot.sendPoll(CHANNEL_ID, question, options, { is_anonymous, type: type as any, }); return { content: [ { type: 'text', text: `β Poll created successfully!\n\nπ± Channel: ${CHANNEL_ID}\nπ Message ID: ${result.message_id}\nβ Question: ${question}\nπ Options: ${options.length}\nπ Anonymous: ${is_anonymous ? 'Yes' : 'No'}\nπ Type: ${type}`, }, ], }; }
- src/index.ts:103-132 (registration)The tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for 'send_poll'.{ name: 'send_poll', description: 'Create and send a poll to the Telegram channel', inputSchema: { type: 'object', properties: { question: { type: 'string', description: 'Poll question', }, options: { type: 'array', items: { type: 'string' }, minItems: 2, maxItems: 10, description: 'Poll options (2-10 items)', }, is_anonymous: { type: 'boolean', description: 'Whether the poll is anonymous (default: true)', }, type: { type: 'string', enum: ['quiz', 'regular'], description: 'Poll type (default: regular)', }, }, required: ['question', 'options'], }, },
- src/index.ts:106-131 (schema)The detailed input schema for the 'send_poll' tool, specifying properties, types, descriptions, and required fields.inputSchema: { type: 'object', properties: { question: { type: 'string', description: 'Poll question', }, options: { type: 'array', items: { type: 'string' }, minItems: 2, maxItems: 10, description: 'Poll options (2-10 items)', }, is_anonymous: { type: 'boolean', description: 'Whether the poll is anonymous (default: true)', }, type: { type: 'string', enum: ['quiz', 'regular'], description: 'Poll type (default: regular)', }, }, required: ['question', 'options'], },