Yes, that’s a lot of fancy words for one blog post. But, suppose you have a Particle Button and you want it to POST its data to a Google Spreadsheet every time a published event happened? This method is an easy way of accomplishing this.
- Make sure you have your Particle Internet Button fully set up, connected, and ready to go
- Find a script or code that you want to run. In this case, I am running my code through their online builder at https://build.particle.io.
- Add some event publishing to your script. For examples on how to do this, see this link on publishing. This is an example line of code that I was working with:
- Go to your Particle dashboard and verify that you can see your events being published in the log. Verify that you can see the integrations tab. You will need this later.
- Sign up for a Zapier account.
- Have a Google account ready to use.
- Make sure you have a Google Spreadsheet created with the following items in the top row:
Device Id, Event Name, Data, Timestamp
Step 1: Get Your Zap Prepared
- Go to Zapier and choose to create a Webhooks-to-Google Sheets zap
- Copy and paste the custom webhooks URL generated by Zapier. You will need this later. Click ‘ok and continue’.
- Skip the section about the Child Key, we won’t be needing it for this tutorial. Save, and choose the Google Account.
- Now you will arrive to a bug in Zapier. It will tell you to ‘Try Turning the Zap On’, and will fail.
- Click Cancel. Now you should see the page with your non-activated Zap. Click on it.
- Now you will see two steps: Catch Hook, and Create Spreadsheet Row. Click on Create Spreadsheet Row.
- Go through the steps until it is time to choose a spreadsheet- choose the spreadsheet that you created earlier with the prefilled first row. Select Sheet1 or whatever worksheet page your rows are on.
- You will come back to this, make sure everything is saved.
Step 2: Integrate your Webhook
- Remember the URL you got earlier? Go back to your Particle dashboard and click on integration and add a new integration. Select the Webhooks option.
- You will now see the menu where you will need to fill in your event name (case matters, make sure it is the exact same name that is in your code), the URL (paste in the webhooks URL you got from Zapier earlier), leave the request type as the default POST, and select your device under the device option (or if you have multiple buttons registered that will be running the code, leave as any).
- Create the Webhook.
- Make sure that your code is running on the Particle and that events are being published on the Dashboard. This is important.
Step 3: Get Your Zap On!
- Back to Zapier, click on your hook and go back to Step 1 (Catch Hook)
- Go to the item called Catch Hook and continue through the instructions.
- In the last instruction, called Test This Step, if you have done everything correctly your hook will be caught successfully.
- Now, go back to Step 2, Create a Spreadsheet Row. Click on the Edit Template step.
- Now you will be able to click on the ‘lines with a plus sign’ icon to the right of your row names (such as Device ID), and select the correct input (coreid) that is being passed from the webhook.
- Once you have done this for all of the row names in your Spreadsheet, turn your ‘Zap’ on using the toggle.
- Check your Google Docs spreadsheet. If everything has been done correctly, you will see your spreadsheet being filled up with data from the Particle Dashboard.
Note: You will need to create a new Webhook integration, but not a new Zap, for each event you have. Aka if you have an event called LED_ON and LED_OFF, you will need two Webhooks integration through the Particle dashboard- but they can use the same Zap url.