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
TableJSON 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 |
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'], },