Live poll with Google sheets
Here’s what you will need to start building the live-poll using Plivo SMS and Google Sheets:
- A Plivo account
- A Plivo number you want to use. You can buy one by visiting https://console.plivo.com/phone-numbers/search/ or using the PhoneNumbers API
- A paid or trial Integromat account
- A Google account
Step 1: Setup Plivo
- Login to your Integromat account
- Click on “Create a new scenario” on the top-right of the screen
- In the next screen, search for “Plivo”
- Select the Plivo integration and click on “Continue”
- You will be taken to the screen where you can create a scenario from scratch
- Click on the big “?” area to start adding modules to the scenario. You should see something like this:
- Click on “Plivo” module and you will see the possible triggers and actions as follows:
- Select “SMS received INSTANT” and you will see an interface to set up the webhook. Click on “Add” beside the drop down so you can add a new webhook:
- Give this webhook a name. In this example, we gave it the name “Poll”.
- Select the Plivo connection you want to use next. If this is your first time, or if you want to add a new connection, click on “Add”.
- In the next form give the connection a name, enter your Plivo Auth ID and Auth Token and click on “Continue”. You can find your Plivo auth credentials in your Plivo dashboard
- Awesome! Now you will have to select the number you want to use for this scenario. Since this scenario will be triggered instantly using webhooks, any application that might be using this number for webhooks will break.
- Give this application a name and select the number you want to use. Click on “Save”
- Super! We now have a trigger that will be auto-triggered whenever there is a new incoming message to the Plivo number you specified.
Step 2: Setup Google Sheets
- Open Google Drive. If you are asked to sign in, use the Google account you want to use and sign in. Note that we will connect this Google account to Integromat later.
- Create a blank spreadsheet
- Add the column headers and give this sheet a name. In this example, we named the sheet as “Integromat Poll” and added “From Number” & “Choice Selected” as the column headers.
- Super awesome. We are now ready to add Google connection to Integromat! So, heading back to the Integromat scenario creation. Click on the big “?” area and search for Google Sheets.
- Select Google Sheets to add the module to the scenario. Now click on the added module to see the possible triggers and actions.
- Select “Add a row” action. You will now be asked to select a connection. You can either choose an existing connection or create a new connection by clicking “Add”. Once you click “Add” you will be taken to a Google login page (or directly to the permissions page asking for permissions to access your spreadsheets).
- Once you log in and give the required permissions, you will then have to select the sheet you created earlier. Integromat will automatically detect the column headers and gives you an option to select which data needs to go to which column. Select the relevant data and click “OK”
- Super! The scenario is now ready! Let’s test this now!
Step 3: Test the scenario
- To test this scenario, click on “Run once” and the scenario goes into a listening mode.
- Now send a text message to the Plivo number you configured earlier. You can either use your mobile phone to do this or the Plivo Messages API to send the message. We sent the text “Option A” to the Plivo number we configured and the scenario ran successfully.
- To also check if this really ran successfully, just open the spreadsheet you created earlier and you should see a new row added, like this:
- Good job! The scenario works, but it is kind of boring to just see a huge table with results. Let’s add a nice chart in the next step.
Step 4: Create a chart in Google Sheets
- Select the Column B completely and go to Insert > Chart as follows:
- This should draw a chart which says “No Data”. Select “Use row 1 as headers” and “Aggregate column B”. This should bring up a nice column chart as follows:
- You can also make the first row bold so the table looks better.
- And… we are ready to go live! Whenever someone sends a text message to your Plivo number that is configured with this scenario, a new row would be added and the chart gets updated!
Step 5: Go live
- To make the scenario live, click on the back button near “Integration Plivo, Google Sheets” on the top-left. Save the scenario if such a prompt comes up.
- In the scenario summary screen, you can see the overview of the scenario you just created and the run history.
- Use the toggle button on the top-right to turn the scenario “ON” (also known as activating the scenario).
- Select “immediately” from the dropdown displayed and click on “Activate”.
- And, that’s a wrap! Your poll application is now live and you will now be able to see the results populated in the Google Sheet whenever you receive a text message.
- Send out a few text messages to see the magic! This is how looks when people start sending their opinions on the poll.
- Congratulations! You just built a great application!