التصويت الآلي في الاستطلاعات (Poll Vote)
تسجيل الأصوات والتفاعل مع استطلاعات الواتساب برمجياً.
تسجيل الدخول مطلوب
سجل الدخول لاستبدال المعرفات (Instance ID) ورمز الوصول (Access Token) بمعلومات حسابك الحقيقي لاختبار ال API مباشرة.
تسجيل الدخوللا توجد معاملات استعلام مطلوبة
هذه النهاية الطرفية لا تتوقع بيانات في الرابط.
Programmatic Participation: Mastering the Poll Vote Engine
In highly automated environments, bots often need to participate in the decision-making process alongside human users. The /v2/send/poll/vote endpoint provides the capability to cast, change, or rescind votes on existing WhatsApp polls programmatically. This enables complex "Bot-in-the-Loop" scenarios where an AI agent can express its findings, preferences, or status via the native interactive poll UI.
🏗️ The Programmatic Voting Architecture
Dynamic voting via an API requires a precise understanding of the poll's state machine:
-
Target Attachment: The engine requires a valid
messageIdof a previously sent poll. This ensures the vote is anchored to the correct interactive context. -
Option Indexing: Wawp allows you to vote using either the literal string name of an option (e.g.,
"Awesome!") or its 0-indexed position within the poll. Our engine automatically resolves these to the internal binary IDs required by the WhatsApp network, preventing "Ghost Vote" errors. -
State Overwriting: WhatsApp follows an "Overwrite" model for voting. When you call this endpoint, your new
votesarray completely replaces your previous selection for that poll. If you send an empty array[], tips: [ { type: 'info', title: 'Mechanism', content: 'Casts a vote on an existing poll message.' }, { type: 'warning', title: 'Validation', content: 'Fails if the poll is closed or the option ID is invalid.' } ], recommendations: [ "Verify the Poll Message ID before attempting to vote.", "Use this for automated testing of poll workflows." ]your previous vote is retracted entirely.
🛡️ Strategic Best Practices for Bot Participation
1. Verification Before Voting
To ensure high reliability, your system should verify the poll exists and is still "active."
- Implementation: Before voting, check your local database or use a listener to confirm the poll hasn't been deleted. Programmatically voting on a non-existent or expired poll will return a
Message Not Founderror. - Timing: Avoid voting immediately (within milliseconds) after a poll is created by another user. Adding a small delay (1–2 seconds) mimics natural processing time and ensures the poll has fully propagated across the WhatsApp WebSocket mesh.
2. Managing Multi-Answer Logic
The votes parameter is an array for a reason.
- Checkboxes vs. Radio Buttons: If the original poll was created with
multipleAnswers: true, your array can contain multiple indices (e.g.,[0, 2]). If it was a single-choice poll, provided arrays with more than one element will typically result in only the last item being counted by the WhatsApp client UI. - UX Consistency: Ensure your bot's votes align with any previous text-based statements it made to avoid confusing human participants.
3. The Power of Selective Retraction
Programmatic voting allows for "Temporary Consensus."
- Scenario: Your bot can vote for an option while it's "investigating" a problem, and then retract its vote or switch to a "Success" option once the investigation is complete. This provides a visual progress indicator that is much more subtle and professional than spamming the chat with status messages.
🧩 Advanced Use Cases
Automated Consensus Building
Build a "Moderator Bot" that monitors a group poll. Once a specific option reaches a threshold (e.g., 5 votes), the bot can cast its own vote for that option to "Seal the Deal" and then automatically trigger a coordination message or calendar invite.
Sentiment Re-alignment
In an AI-driven support flow, if a user starts a poll to rate their experience, the bot can programmatically vote for the "Neutral" option initially. As the conversation improves and sentiment analysis scores rise, the bot can update its vote to "Positive," providing the human agent with a visual cue of the AI's current assessment of the interaction.
🛠️ Common Pitfalls and Solutions
- License Barriers: Ensure your instance is correctly provisioned before integrating programmatic voting into your production workflow.
- Case Sensitivity: When voting via string names, ensured your strings match the poll options exactly (including case and trailing spaces). A mismatch will cause the vote to be ignored or return an error. Using Indices (integers) is the recommended best practice for high-reliability systems.
- Race Conditions: If multiple instances of your bot attempt to update a vote on the same poll simultaneously, the last request received by the Wawp proxy will define the final state. Use a centralized queue or locking mechanism in your backend if you have multiple bot clusters interacting with the same chat.
Summary of Capabilities:
- Programmatically cast, update, or retract votes on native WhatsApp polls.
- Support for voting by literal option strings or numeric indices.
- Exclusive for advanced automation and AI integration.
- Full support for multi-choice (checkbox) and single-choice (radio) poll architectures.
- Real-time synchronization with the WhatsApp network for instantaneous UI updates on recipient devices.
البارامترات
قم بتهيئة المعاملات المطلوبة للتفاعل مع نقطة النهاية هذه. جميع وسائط الاستعلام والبيانات مدرجة أدناه مع تفاصيلها.
محتوى الطلب
يرسل كـ JSONstring | Your unique WhatsApp Instance ID مثال: | ||
string | Your API Access Token مثال: | ||
string | Target phone number or group ID مثال: | ||
string | The unique ID of the poll message مثال: | ||
array | Array of selected option names or indices مثال: |
برمج بالذكاء الاصطناعي باستخدام Wawp MCP
MCP READYقم بربط الـ API مباشرة مع Cursor أو Windsurf أو Claude Desktop، ودع الذكاء الاصطناعي يكتب لك كود الربط وينفذه تلقائياً!
أمثلة الكود
استخدم أمثلة الكود الجاهزة لدمج واجهة برمجة التطبيقات (API) في مشروعك بسرعة وكفاءة. اختر لغة البرمجة والمكتبة التي تفضلها.
الردود المتوقعة
استكشف كافة الردود والنتائج المحتملة من الخادم. قمنا بتوثيق كل كود حالة (Status Code) مع أمثلة للبيانات لتسهيل معالجة الأخطاء والنجاح.
Example
{
"_data": {
"id": {
"fromMe": true,
"remote": "000000000000@c.us",
"id": "MSG_ID_123456",
"_serialized": "true_000000000000@c.us_MSG_ID_123456"
},
"viewed": false,
"body": "BASE64_IMAGE_DATA",
"type": "image",
"t": 1759108866,
"from": {
"server": "c.us",
"user": "111111111111",
"_serialized": "111111111111@c.us"
},
"to": {
"server": "c.us",
"user": "000000000000",
"_serialized": "000000000000@c.us"
},
"ack": 0,
"isNewMsg": true,
"star": false,
"kicNotified": false,
"caption": "Here's your requested image.",
"deprecatedMms3Url": "https://example.com/media-url",
"directPath": "/media/direct/path/example",
"mimetype": "image/jpeg",
"filehash": "FILE_HASH_PLACEHOLDER",
"encFilehash": "ENC_FILE_HASH_PLACEHOLDER",
"size": 192487,
"mediaKey": "MEDIA_KEY_PLACEHOLDER",
"mediaKeyTimestamp": 1759108865,
"streamable": false,
"mediaHandle": null,
"isFromTemplate": false,
"pollInvalidated": false,
"isSentCagPollCreation": false,
"latestEditMsgKey": null,
"latestEditSenderTimestampMs": null,
"mentionedJidList": {
},
"groupMentions": {
},
"isEventCanceled": false,
"eventInvalidated": false,
"isVcardOverMmsDocument": false,
"isForwarded": false,
"isQuestion": false,
"questionReplyQuotedMessage": null,
"questionResponsesCount": 0,
"readQuestionResponsesCount": 0,
"labels": {
},
"hasReaction": false,
"disappearingModeInitiator": "chat",
"disappearingModeTrigger": "chat_settings",
"productHeaderImageRejected": false,
"lastPlaybackProgress": 0,
"isDynamicReplyButtonsMsg": false,
"isCarouselCard": false,
"parentMsgId": null,
"callSilenceReason": null,
"isVideoCall": false,
"callDuration": null,
"callCreator": null,
"callParticipants": null,
"isCallLink": null,
"callLinkToken": null,
"isMdHistoryMsg": false,
"stickerSentTs": 0,
"lastUpdateFromServerTs": 0,
"invokedBotWid": null,
"bizBotType": null,
"botResponseTargetId": null,
"botPluginType": null,
"botPluginReferenceIndex": null,
"botPluginSearchProvider": null,
"botPluginSearchUrl": null,
"botPluginSearchQuery": null,
"botPluginMaybeParent": false,
"botReelPluginThumbnailCdnUrl": null,
"botMessageDisclaimerText": null,
"botMsgBodyType": null,
"requiresDirectConnection": false,
"bizContentPlaceholderType": null,
"hostedBizEncStateMismatch": false,
"senderOrRecipientAccountTypeHosted": false,
"placeholderCreatedWhenAccountIsHosted": false,
"galaxyFlowDisabled": false,
"links": {
}
},
"mediaKey": "MEDIA_KEY_PLACEHOLDER",
"id": {
"fromMe": true,
"remote": "000000000000@c.us",
"id": "MSG_ID_123456",
"_serialized": "true_000000000000@c.us_MSG_ID_123456"
},
"ack": 0,
"hasMedia": true,
"body": "Here's your requested image.",
"type": "image",
"timestamp": 1759108866,
"from": "111111111111@c.us",
"to": "000000000000@c.us",
"deviceType": "android",
"isForwarded": false,
"forwardingScore": 0,
"isStatus": false,
"isStarred": false,
"fromMe": true,
"hasQuotedMsg": false,
"hasReaction": false,
"vCards": {
},
"mentionedIds": {
},
"groupMentions": {
},
"isGif": false,
"links": {
}
}Command Palette
Search for a command to run...