NavigationContentFooter
Jump toSuggest an edit

Triggering IFTTT actions from IoT Hub messages

Reviewed on 29 October 2024Published on 04 January 2021
  • IoT
  • IFTTT

IFTTT, an acronym for “If This, Then That,” offers a user-friendly yet robust automation service, enabling users to trigger actions based on specific events.

With an extensive array of customizable events and actions at your fingertips, the possibilities are virtually endless — an incredibly empowering feature.

In this tutorial, we will show you how to quickly build a simple reporting application that stores your devices’ data in a Google sheet.

Before you start

To complete the actions presented below, you must have:

  • Owner status or IAM permissions allowing you to perform actions in the intended Organization

Create an IFTTT account and set up an applet

  1. Sign up to IFTTT. When done, click the create button to start building your applet.
  2. Choose Webhooks: Receive a web request as the “If This” trigger. Type in iot_event as the event name and create the trigger.
  3. Choose Google Sheets: Add row to spreadsheet as the “Then That” action. We will use default settings and just create the action without changing them.
  4. Click the continue button
  5. Choose a title, such as Scaleway IoT Hub to Google Sheet as your applet name and click Finish. You’re done with the applet.

Now the applet is set up, we need to find our webhook key. Head to your webhook settings and you will find a URL like https://maker.ifttt.com/use/<key>. Write down the key part - we will use it later.

Creating an IoT Hub and setting up the IoT Route

Now that we have our IFTTT applet ready, we need to create an IoT Hub. This will be where our simulated IoT Device will publish messages to trigger our IFTTT applet.

  1. Follow this procedure to create an IoT Hub. Select your name and plan of choice, and click the Create Hub button.

  2. Head to the Routes tab of your IoT Hub.

  3. Create a new route with the following settings:

    • Name: anything you’d like (ex: IFTTT Route)
    • Topic: This will be the topic to publish to from your Device, let’s use my/data
    • Route type: REST Query
    • Verb: POST
    • Endpoint: https://maker.ifttt.com/trigger/iot_event/with/key/<key> where <key> is the key you got from IFTTT earlier.
    • HTTP Headers: Content-Type: application/json

Now that we have everything set up, let’s add a Device and send a message from there.

Adding a Device a triggering the IFTTT applet

In your Scaleway console, head to the Devices tab of your IoT Hub. From there, to add a new Device, give it any name and pick the Allow insecure connection option (you do not want to do that in production, but this is fine for this tutorial’s purpose). Click the Add button, and, finally, the Close button.

Now your Device appears in the Device list, click it and then on the MQTT Webclient button to simulate a real device.

In the Topic field write my/data (which is the topic we chose for the IoT Route). In the Message field write { "value1" : "Hi", "value2" : "from", "value3" : "Scaleway!" }. Then click the Publish button (no confirmation will be issued).

The message published on my/data topic will be received by the IoT Route and forwarded to the IFTTT Webhook trigger, which will save the values in the Google sheet.

Now head to your Google sheet home page, open the IFTTT_Maker_Webhooks_Events spreadsheet, and voila. You can even see data flowing in live when publishing more messages.

All done

We hope you had fun collecting data from your IoT Hub to a Google sheet. This is one of the many possibilities the IoT Hub REST Route provides. Stay tuned for more REST Route usage examples.


Learn more about Scaleway IoT Hub, discover how to add Devices to the hub or check out the IoT Hub metrics.

Was this page helpful?
API DocsScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCareers
© 2023-2024 – Scaleway