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).
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:
(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:
(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.
- Log in to IFTTT.
- Choose to “Create a Recipe” by going to My Recipes / Create a Recipe.
- 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.
- Type “Maker” into the “Choose Trigger Channel” search box.
- Click the “Maker” icon.
- Click the trigger (the box) shown. (In this example, “Receive a web request” is the trigger.
- 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.)
- Click “Create Trigger.”
- Click the large blue underlined THAT to set up the second half of the recipe.
- 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.
- For either iOS or Android, click the IF Notifications icon (shown in a red box in the images above).
- 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.)
- Click the action (the box) shown. (In this example, the action is “Send a notification.”)
- The default notification text will be shown.
- 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).
- For each ingredient you wish to add, select it from the list and click “Add Ingredient.”
- The following image shows a notification that will contain all available pieces of information:
- Click the “Create Action” button.
- Give your recipe a name. (It can be anything you wish to help you know what your recipe is.)
- Click “Create Recipe.”
- The recipe then appears in your “My Recipes” area. You can edit it from this location at any point.
- 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:
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:
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.