WhatsApp Polls in Glific: Quick Decisions, Seamless Conversations

amishabisht

MARCH 17, 2025

Share

For NGOs, staying connected isn’t just important—it’s essential. Whether it’s coordinating volunteers, sharing updates, or making quick decisions, WhatsApp is the go-to platform. That’s why we built WhatsApp Groups in Glific, making it easier for NGOs to bring their teams together in one place. Now, creating and managing WhatsApp groups happens seamlessly within Glific, keeping conversations organized and efficient.

And to take it a step further, we’ve introduced WhatsApp Polls in Glific—because sometimes, a quick poll is all it takes to make the right call.

Here’s a look at the features available in WhatsApp polls:

Create and Sending polls:

We can create a WhatsApp poll from the UI by clicking on the Create button.

After clicking, we will be redirected to the creation page, where we can:

  • Add a label for the poll.
  • Provide content i.e the questions we want to ask users.
  • Define the poll options.
  • We can preview how the poll will look before sending it.

There is a checkbox labeled “Allow multiple options”:

  • If checked, users can select more than one option, similar to how WhatsApp polls work.

Managing Created Polls

  • Once a poll is created, it appears under the Group Polls tab.
  • In this tab, you can:
    • Search for a poll using its label.
    • Copy a poll to create a duplicate.
    • View the complete poll, including all options.
    • Delete a poll if needed.

Why is there no Edit option?

  • Editing a poll is not allowed to prevent confusion when tracking responses.
  • If the content of a poll changes after some users have already responded, it can lead to inconsistent data and misinterpretation of results.
  • Instead, if changes are needed, you can copy the old poll and create a new one with the correct details.

Sending WhatsApp Polls

After some discussion and back-and-forth, we decided to send WhatsApp polls using the Webhook Node instead of creating a separate node for polls.

  • A separate node for WhatsApp polls wasn’t necessary because normal flows don’t inherently support WhatsApp polls. Gupshup doesn’t provide support for WhatsApp polls, so building a dedicated node wouldn’t be useful.
  • Instead, creating a function was more convenient in terms of design and effort while still achieving the goal of sending polls via flows.
  • This approach was simpler and efficient, so we took the easier route.

Creating the Flow for WhatsApp Polls

  1. Call the Webhook Function
    • Start by adding a  Call Webhook Node in the flow.
    • In the dropdown, choose Function and set the name to send_wa_group_poll.
  1. Define the Function Body
    • Pass the poll UUID as a key and paste the copied UUID from the Group Polls tab as its value, and another key, wa_groups set its value to @wa_group.
  2. @wa_group will internally expand to this map as follows:

Starting the Poll Flow

  • For a Single WhatsApp Group:
    • Start the flow directly by clicking Start a Flow, which will trigger the poll flow for the group.
  • For a WhatsApp Group Collection:
    • Instead of using WABA, select WhatsApp Group Collection.
    • Choose the collection name and schedule the flow for the collection.
  • WhatsApp Group Flows don’t support the simulator yet because polls are still in the early stage.
  • We didn’t find a strong need for a poll preview in the flow simulator since the poll’s appearance is already shown during creation.

  Challenges We Faced During Development

  1. Underestimating Timelines – The Sneaky Surprise
    • When we started planning WhatsApp group support, we thought it would be quick—especially the webhook function.
    • We later realized that Glific’s older flow code didn’t support WhatsApp groups. The webhook function was designed to handle only contact variables — for example, using @contact.name would replace it with the contact’s actual name, but it wouldn’t work for whatsapp group-specific data.
    • But there was no equivalent support for WhatsApp groups, which completely caught us off guard. 
  1. Code Refactoring – The Necessary Evil
    • The first version of Glific was pretty straightforward—it mostly just created and sent messages without touching the core system.
    • Previously, send_message also worked through flows, but the code related to WhatsApp groups wasn’t generic. This time, we integrated WhatsApp groups directly into flows — tackling one of the most complex and critical parts of Glific — while adding support for multiple nodes and making the code fully generic.
    • We couldn’t just add new code—we had to refactor and restructure existing code to fit the new functionality. This meant being extra careful not to break anything while making things better. It was like trying to upgrade a moving train without derailing it!
  1. Glific’s Codebase – A Giant Maze
    • To be honest, Glific’s codebase is massive—a real jungle of logic and functions.
    • Understanding every line took time (and coffee). 
    • But once we figured it out, things started to click (well, mostly).

We have covered the unit test cases and Cypress tests for this feature.

The major learning from this experience is the importance of estimating timelines correctly and performing a basic feasibility check beforehand. We have already started implementing this approach in our new features and issue resolutions after working on WhatsApp polls.

They say ‘Never assume’—and now, after digging through old code, we know why. Lesson learned: Always check before you wreck

Leave a Reply

Tags

#Glific

Discover more from Glific

Subscribe now to keep reading and get access to the full archive.

Continue reading