Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

React to Channel Activity with Text Message from IFTTT

The analytical power of ThingSpeak™ and MATLAB® allow you to generate filtered, targeted, and specific notifications of channel activity. The external web service IFTTT is a web service that lets you create Applets that act in response to a trigger action. This example shows how to use the React app to trigger an HTTP request to IFTTT in ThingHTTP. The triggered IFTTT Applet then sends a text message.

Channel 379984 logs home temperature values. In this example, you receive a text notification when the temperature falls below 50 degrees, so that seedlings getting ready for the garden in spring are not damaged.

Create an IFTTT Applet

You can set the IFTTT webhooks service to use web requests to trigger an action. The incoming action is an HTTP request to the web server and the outgoing action is a text message.

  1. Create an IFTTT account, or log into your existing account.

  2. Create an Applet. Select My Applets, and then click the New Applet button.

  3. Select input action. Click the word this.

  4. Select the Webhooks service. Enter Webhooks in the search field. Select the Webhooks card.

  5. Complete the trigger fields. After you select Webhooks as the trigger, click the Receive a web request card to continue. Enter an event name. This example uses TooCold as the event name. Click Create Trigger.

  6. Select the resulting action. Click the word that. The trigger word this is now the Webhooks icon. Enter SMS in the search bar, and select the SMS box.

  7. Select Send me an SMS, and then enter the text message information. You can pass data about the event that triggered your message using ingredients. For example, including {{Event Name}} adds the event name to your text message. Click Create action to finish the new Applet.

  8. Retrieve your Webhooks trigger information. Select My Applets > Services, and search for Webhooks. Select Webhooks, and then click the Documentation button. You see your key and the format for sending a request. Enter the event name. The event name for this example is TooCold.

    https://maker.ifttt.com/trigger/{event}/with/key/XXXXXXXXXXXXXXXXXXXXXX
    
    https://maker.ifttt.com/trigger/TooCold/with/key/XXXXXXXXXXXXXXXXXXXXXX
    

You can test the service using the test button or by pasting the URL into your browser. The IFTTT event trigger is not always instantaneous. Now create a ThingHTTP to complete the trigger request.

Create a ThingHTTP

The ThingHTTP app lets you trigger predefined HTTP requests with an API key and a GET request from the web or from a device. This example shows how to use ThingHTTP to trigger Webhooks at IFTTT.

  1. Choose Apps > ThingHTTP, and select New ThingHTTP.

  2. Edit your ThingHTTP settings.

    • Choose a Name.

    • Enter the URL from the Webhooks documentation. The URL for this example has the form https://maker.ifttt.com/triigger/toocold/with/key/xxxxxxxxxxxxxxxxxxxxxx.

    • For Method, enter GET.

  3. Save the ThingHTTP. Now create a React to trigger this ThingHTTP based on your channel data.

Create a React to Your Data

The React app can evaluate your ThingSpeak channel data and trigger other events. Create an instance of the React app that triggers when the house is too cold. Choose Apps > React, and then click New React.

  • Choose a Name.

  • Select On Data Insertion for Test Frequency.

  • Choose your temperature channel for the Condition.

  • Select the appropriate field, in this case Field 1.

  • Set the requirement to is less than.

  • Set the temperature level, in this case 50.

  • Select ThingHTTP as the Action, and choose the name of the ThingHTTP you defined previously.

  • In Options, choose Run action each time condition is met.

Trigger your Message

Once the temperature in the channel reaches the set point for your React, you receive a text message on your device.

Troubleshooting

If you do not receive the text message, you can try activating each component separately.

  1. Trigger Webhooks at IFTTT from your browser. Copy the address from the Webhooks documentation to your browser address window, you can trigger the event directly. If successful, IFTTT replies with "You have successfully triggered the TooCold event!"

  2. Trigger your ThingHTTP using a REST API call. The format for the call is available on the help pane after you edit and save your ThingHTTP. Your ThingHTTP has a unique API key.

    GET https://api.thingspeak.com/apps/thinghttp/send_request?api_key=XXXXXXXXXXXXXXXX

  3. Trigger your React by writing data to your channel which fits the conditions specified in your React. For this example, you can write a temperature of 49 degrees to field 1.

    GET https://api.thingspeak.com/apps/thinghttp/send_request?api_key=XXXXXXXXXXXXXXXX&field1=49

See Also

Related Topics