App

Create new Zapier Webhook Integration

The Zapier Webhook Integration allows you to keep device data synced between your business applications and our API. Zapier acts as a forwarding layer that watches for new device alerts and notifications, and will send updates to a configured business application destination.

You will need a Premium Zapier account.

Creating a new Zapier Webhook integration (Zap)

  1. You will need a Premium Zapier account. If you do not have one, click here and create one.

  2. Login to your Zapier account and select Make a Zap in the lefthand side.

    image-20210917-223756.png
  3. Select Webhook (Premium) as your trigger source.

    image-20210917-223803.png
  4. For Trigger Event select "Catch Hook".

    image-20210917-223810.png
  5. During setup, you can choose to receive an empty body response for the Webhook.
    💡 Check this box if you do not need a response from Zapier when sending data (most common configuration).

    image-20210917-223819.png
  6. Copy the generated Webhook URL.

    image-20210917-223826.png
  7. Log into your IoT Dashboard account where your devices are located.

  8. Go to ☰ → INTEGRATIONS and then select the Zapier Webhook integration.

  9. Paste the generated URL from Zapier in the Url field.

  10. Optionally, customize the webhook with the following fields:
    Event Subscriptions: In this field you can select whether your integration should pass sensor data received (uplink), gateway keepalive (ping), and alert events.
    Device Subscriptions: In this field you can select specific devices for the integration to monitor. By default All Devices are selected

    Zapier.png
  11. In the Data Fields area, you can customize the specific data points passed by the integration. By default all fields are selected.

    DataFields.png
  12. Click Save Zapier Webhook to save the integration.

You should see a new inegration added to your integrations list.

Configuring the new Zapier Webhook integration (Zap)

  1. Return to Zapier and click Continue

  2. Clicking Test Trigger should show new requests once your subscribed device emits another alert / notification. It may be instant or delayed, depending on how frequently the selected device delivers alerts.

    image-20210917-223937.png
  3. Click Continue once you have a passing trigger test.

  4. In the Action prompt, search for "Code by Zapier" and select it.

    image-20210917-223945.png
  5. In the "Action Event" field, select Run Javascript then click Continue

    image-20210917-223952.png
  6. In the "Set up action" step, you need to add four standard fields to "Input Data" that Zapier will use to map the data from the API to the destination app. These fields include deviceNamedatalabels, and timestamp. Here is a description of each:

    1. deviceName: The name of the specific device your integration monitors. Can be selected from "Device Thing Name" in the dropdown field.

    2. data: The data included in the device alert payload. Can be selected from "Event Data Payload Value" in the dropdown field.

    3. labels: The labels associated with each piece of data. Can be selected from "Event Data Payload Name" in the dropdown field.

    4. timestamp: The time at which the alert occured. Can be selected from "Event Data Timestamp" in the dropdown field.

      image-20210917-224012.png
  7. In the "Code" section, you need to copy and paste a snippet of JavaScript code that performs the data formatting. Use this code snippet (do not modify):

    // In order for Zapier to read our telemetry data correctly, 
    // we need to reformat it so it can be used correctly in the selection 
    // fields in the following step. This code does the reformatting for us.
    
    const parsedLabels = inputData.label.split(',');
    const parsedData = inputData.data.split(',');
    const formattedOutput = {}
    
    formattedOutput["Device Name"] = inputData.deviceName;
    
    parsedLabels.forEach((label, index)=>{
      formattedOutput[label] = parsedData[index];
    })
    
    const UTCDate = new Date(parseInt(inputData.timestamps));
    const formattedDate = UTCDate.toLocaleString("en-US", {timeZone: "America/Los_Angeles"});
    
    formattedOutput['Event Time'] = formattedDate + ` PDT`;
    
    output = [formattedOutput];
    
  8. At this point you should be able to run a test of the code step and see the reformatted output.

    image-20210917-224126.png
  9. Click the + symbol, and click Back to Setup. Now it's time to add the business application destination for the data. In this example we will use a Google Sheet integration.

  10. First, set up your Google Sheet the way you want to see your data represented.

    image-20210917-224142.png
  11. In Zapier, select "Create Spreadsheet Row" as the Action Event, then click Continue

    image-20210917-224150.png
  12. In the "Set up action" section fill in the Drive, Spreadsheet, and Worksheet you want to use. Then select each data field item from the Run JavaScript option.

    image-20210917-224159.png
  13. With all selections made, click Continue.

  14. In the "Test action" section, click Test & Review. You should see a success notification, and the sample output should be shown on the spreadsheet.

    image-20210917-224211.png
    image-20210917-224224.png


Click Turn on Zap, and you're done.