IFTTT Integration

5 Sep
Guides > Labs > IFTTT Integration
Note: IFTTT has changed its interface and approach to setting up applets and integration with services. This guide is no longer accurate.

 

The Funnel Cake (0.8) release of the Nightscout site code brings IFTTT integration to Nightscout users. IFTTT is an extensible system by which users can create custom recipes following an “if this then that” logic. Nightscout users can use IFTT in response to Nightscout “events” (like a high or low warning, a Care Portal treatment entry, a site announcement, etc.). The potential of the IFTTT system is exciting, and users can create their own recipes using any available IFTTT channel in combination with the Maker channel. Possible applications of IFTTT integration range from sending an SMS message or phone notification when a Nightscout event happens, to tweeting a Nightscout event, to changing the color of household lights based on a Nightscout event (if you use a smart lighting system like Philips hue).

ENABLE Maker

To take advantage of IFTTT in Funnel Cake, you first need to ENABLE the feature, just as you ENABLE other features. (Reminder: all features that you ENABLE go in the same box, separated by a space.) To ENABLE IFTTT, add “maker” to the ENABLE value box:

f-enable-maker

(Be sure to save your site settings after making any change.)

Create an IFTTT Account

To get started using IFTTT and Nightscout, you need to first create an IFTTT account on the IFTTT site. (The account is free.)

After you have an account, you need to find your Maker key. This is shown on the Maker channel page when you are logged in.

You need to copy your Maker key and enter it in your site settings (Azure or Heroku) as the value for the MAKER_KEY variable, as shown below:

f-makerkey

(Note: Your Maker key is specifically tied to your IFTTT account. You can add more than one Maker key in this field using a space between each separate key.)

Create an IFTTT Recipe

After you have added your Maker key to your site configuration and ENBALED maker, you can create a recipe. As noted above, each user may find different ways to take advantage of IFTTT integration. To understand the process of creating a recipe, we will use setting IFTTT up to send a notification to your cellphone (iOS in this example) to demonstrate the process.

  1. Log in to IFTTT.
  2. Choose to “Create a Recipe” by going to My Recipes / Create a Recipe.
  3. First you have to identify the THIS part of the “if this, then that” statement. Click the large blue underlined THIS to start the process.

    f-maker-ifTHIS

  4. Type “Maker” into the “Choose Trigger Channel” search box.

    f-maker-channel

  5. Click the “Maker” icon.
  6. Click the trigger (the box) shown. (In this example, “Receive a web request” is the trigger.

    f-maker-chooseTrigger

  7. Enter the name of the “event” you are using from available Nightscout events. (You can review all of the possible Nightscout events below. For this example, enter ns-event — this event will send an alert for any Nightscout event.)

    f-maker-name

  8. Click “Create Trigger.”
  9. Click the large blue underlined THAT to set up the second half of the recipe.

    f-maker-THAT

  10. You can now choose from any available action channel. (Note: You may have to do additional steps to set up or configure a channel for use, including installing the IFTTT app on your cellphone and activating it.) For this example, enter “iOS” or “Android” in the search box.

    f-maker-ios

    or

    f-maker-android

  11. For either iOS or Android, click the IF Notifications icon (shown in a red box in the images above).
  12. If you have not connected the channel before, you may need to take steps to “connect” the selected channel. You will need to follow any necessary steps to connect the channel before you can complete the recipe. (Connecting the notifications channel will include downloading the IFTTT app, if you have not already done so.)
  13. Click the action (the box) shown. (In this example, the action is “Send a notification.”)

    f-maker-sendnotification-ios

  14. The default notification text will be shown.

    f-maker-defaultaction

  15. You can add additional information to the notification by clicking the “beaker” icon to the right, and then clicking the dropdown menu for “Select an ingredient.” Any or all of the available ingredients can be added to the notification text (one by one).

    f-maker-ingredients

  16. For each ingredient you wish to add, select it from the list and click “Add Ingredient.”

    f-maker-selectingredient

  17. The following image shows a notification that will contain all available pieces of information:

    f-maker-ingredients-all

  18. Click the “Create Action” button.
  19. Give your recipe a name. (It can be anything you wish to help you know what your recipe is.)

    f-maker-recipetitle

  20. Click “Create Recipe.”
  21. The recipe then appears in your “My Recipes” area. You can edit it from this location at any point.

    f-recipe-final

  22. When your recipe runs, you will receive a notification on your device. (In your device settings for notifications, you may be able to control where/how your notifications appear.)

Using the same steps above, you can configure an SMS message to be sent when a Nightscout event occurs. You would then end up with another recipe, like this one:

f-maker-SMS

To see steps for creating a recipe that sends a tweet, click here.

Fine-tuning Your IFTTT Recipes

The following “events” are available for Nightscout/IFTTT. You can create recipes specifically for any of these events. Just be aware that some of the event categories overlap. (If you receive multiple notifications when something happens, you likely need to look closely at what events you have chosen.)

  • ns-event – This event is sent to the maker service for all alarms and notifications. This is good catch all event for general logging.
  • ns-allclear – This event is sent to the maker service when an alarm has been acknowledged or when the server starts up without triggering any alarms. For example, you could use this event to turn a light to green.
  • ns-info – Plugins that generate notifications at the info level will cause this event to also be triggered. It will be sent in addition to ns-event.
  • ns-warning – Alarms at the warning level with cause this event to also be triggered. It will be sent in addition to ns-event.
  • ns-urgent – Alarms at the urgent level with cause this event to also be triggered. It will be sent in addition to ns-event.
  • ns-warning-high – Alarms at the warning level with cause this event to also be triggered. It will be sent in addition tons-event and ns-warning.
  • ns-urgent-high – Alarms at the urgent level with cause this event to also be triggered. It will be sent in addition tons-event and ns-urgent.
  • ns-warning-low – Alarms at the warning level with cause this event to also be triggered. It will be sent in addition tons-event and ns-warning.
  • ns-urgent-low – Alarms at the urgent level with cause this event to also be triggered. It will be sent in addition to ns-event and ns-urgent.
  • ns-info-treatmentnotify – When a treatment is entered into the care portal this event is triggered. It will be sent in addition to ns-event and ns-info.
  • ns-warning-bwp – When the BWP plugin generates a warning alarm. It will be sent in addition to ns-event and ns-warning.
  • ns-urgent-bwp – When the BWP plugin generates an urgent alarm. It will be sent in addition to ns-event and ns-urgent.

You also have the ability to set up a second stream in Funnel Cake by setting a MAKER_ANNOUNCEMENT_KEY variable in your site settings. Any keys you add in the value for that variable will receive site-wide announcements, another new feature in Funnel Cake.

The following image shows a sample MAKER_ANNOUNCEMENT_KEY in site configuration:

f-maker-announcement-key

Understanding IFTTT

One important thing to understand about IFTTT is that recipes you create are specific to your IFTTT account. You can’t, for example, create a recipe to send a notification to a different caregiver’s phone. That caregiver would have to also have an IFTTT account, a maker key, and individual recipes, and that caregiver’s maker key would need to be added to the Nightscout site settings.

Please be sure and test your recipes. You may notice that there is a delay with notifications and SMS messages (or other IFTTT actions) in response to Nightscout events. IFTTT actions may arrive later (or slower) than Pushover notifications.
Unlike Pushover notifications, you do not need to “clear” or “acknowledge” IFTTT notifications.