Send Poll
send_pollSend a WhatsApp poll message to a recipient or group. Define the poll question, the number of selectable options, and the list of choices.
Instructions
Send a WhatsApp poll message via the pinned instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | Recipient JID or phone number (e.g. 5511999999999 or group@g.us) | |
| name | Yes | Poll question/title | |
| selectableCount | Yes | Number of options the recipient can select | |
| values | Yes | Array of poll options (minimum 2) |
Implementation Reference
- src/tools/send-poll.ts:7-12 (schema)Input schema for send_poll tool: number (PhoneOrJidSchema), name (poll question), selectableCount (number of selectable options), values (array of poll options, min 2).
const schema = { number: PhoneOrJidSchema, name: z.string().min(1).describe("Poll question/title"), selectableCount: z.number().int().min(1).describe("Number of options the recipient can select"), values: z.array(z.string().min(1)).min(2).describe("Array of poll options (minimum 2)"), }; - src/tools/send-poll.ts:1-37 (handler)Full implementation of the send_poll tool handler. Registers the tool with the MCP server, sends a POST request to /message/sendPoll/{instanceName} with the poll parameters, and returns the JSON response.
import { z } from "zod"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { McpError } from "@modelcontextprotocol/sdk/types.js"; import type { EvolutionClient } from "../evolution-client.js"; import { PhoneOrJidSchema } from "../schemas.js"; const schema = { number: PhoneOrJidSchema, name: z.string().min(1).describe("Poll question/title"), selectableCount: z.number().int().min(1).describe("Number of options the recipient can select"), values: z.array(z.string().min(1)).min(2).describe("Array of poll options (minimum 2)"), }; export function registerSendPoll(server: McpServer, client: EvolutionClient): void { server.registerTool( "send_poll", { title: "Send Poll", description: "Send a WhatsApp poll message via the pinned instance.", inputSchema: schema, }, async (args) => { try { const data = await client.post(`/message/sendPoll/${client.instanceName}`, { number: args.number, name: args.name, selectableCount: args.selectableCount, values: args.values, }); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (e) { if (e instanceof McpError) return { isError: true, content: [{ type: "text" as const, text: e.message }] }; throw e; } } ); } - src/tools/index.ts:21-21 (registration)Import of registerSendPoll from send-poll.ts.
import { registerSendPoll } from "./send-poll.js"; - src/tools/index.ts:94-94 (registration)Registration call for send_poll tool.
registerSendPoll(server, client); - src/schemas.ts:8-11 (helper)PhoneOrJidSchema used by send_poll's number field, accepting phone numbers or JIDs.
export const PhoneOrJidSchema = z .string() .min(1) .describe("Recipient JID or phone number (e.g. 5511999999999 or group@g.us)");