Using IFTTT To Bring Data Into Nomie
During the past month, I went on another one of my mini “quests” to find useful tools to help me with my life logging and quantified self hobby. It was during this time that I found Nomie - an open source, privacy orientated tracking tool that gives you the flexibility of creating a robust, customisable platform for life logging and data tracking.
One of the potent features that Nomie gives you access to, is the ability to import data from other applications using the API. This means that you can utilise Nomie as a final destination for all your tracking tools, bringing everything into a private ecosystem that you control. But this process can often be daunting for a newcomer who perhaps may not have much experience with APIs, webhooks or connecting services like IFTTT (If This, Then That).
This article aims to be a comprehensive guide that can help you piece all the parts of this puzzle together, so that when you’re done reading, you’ll have the information necessary to get going on your own data imports!
Step 1 — Setting Up Your Nomie API Key
To start with, we’re assuming that you’ve installed Nomie on your chosen platform and picked between saving your data on your device or cloud encrypted using Blockstack. If you haven’t already, then I highly suggest heading to the Nomie website and following the Install instructions!
You’ll then want to navigate into the settings menu and choose the data tab at the top. You’ll see a section for “Data” and an option that says, “Nomie API” - click it to continue.
In this section you’ll see an option to “Generate API Key…” and a description which tells you a bit about what the Nomie API allows you to do. You’ll want to press the “Generate API Key…” button.
This will then take you to the Nomie API section. Here you can see a few different settings, so lets run through what all of this means.
Firstly we can see two tabs, “Settings” and “Captured (0)”. You’ll want to focus on the “Settings” tab for now. The first option in this tab is “Auto Accept”. This essentially allows you to give the program permission to take any incoming data and automatically accept it when you load your Nomie application. A good rule of thumb is to turn this on, that way your automated system will work without you needing to accept it manually.
Next you will see your “API Key”, this is your personalised key that authenticates your account with the API, basically pointing the API in the right direction. It’s best practice to usually keep your API Key private and not to share it with others. This is because we don’t want to give anyone the ability to send erronous data to our Nomie account. It’s important to note that Nomie has been created so that the API only accepts incoming data and doesn’t output any data for security.
You’ll want to copy your API Key at this point in time and have this screen handy whenever you need to fetch your key when adding new data inputs.
The “Private Key” section is something you shouldn’t have to worry about too much, but it essentially proves that your public key is yours and yours alone. Do not give away your private key!
Finally let’s navigate over to the “Captured (0)” tab.
As you can see, we have “No recent logs captured”. This means that we’re currently not receiving any incoming data. The “Check” button in the corner can be used as a refresh button. That’s it for the API Key section, if you want some more info on the API, then I highly suggest looking at the Nomie API tutorial on the website.
Step 2 — Working With IFTTT
If This, Then That or IFTTT for short is your one stop shop for connecting different web services together. You can use it to create chains of comands that can trigger when certain actions take place. We’ll dive into it now!
To start with, you’ll want to create yourself an account on IFTTT. One drawback to IFTTT is that you can only create 3 custom applets before having to go premium, however, it can still be a very useful tool and 3 should be plenty for you to get started.
Navigate over to the “Create” section by using the top level navigation bar. Here you will see a very simple screen which is a two step process and inspires the name of the service.
Essentially what we’re doing is connecting two parts together, one is our action or “If This” in IFTT terms and the other is our outcome, “Then That”. In this example, we’ll be looking at importing some weather statistics into Nomie so that each morning we can head onto our Nomie app and see what the weather has in store for the upcoming day.
If you want to learn about other examples of useful IFTTT + Nomie connections then I will be releasing another article in the coming days with a plethora of examples!
Go ahead and click “If This” to bring up a long list of services that the platform has on offer. We’ll want to type in our service — “Weather Underground” and click on the corresponding service.
Once you’ve clicked the “Weather Underground” application, you’ll see a list which is personal to the specific application. These are called “triggers”. They are certain actions that can be chosen in order to provide a type of data to us. Go ahead and look through the different options that this one app has available! We’ll be choosing the first option however, “Today’s Weather Report”.
A screen will pop up that asks you for some information and gives you the ability to select a place that you want the weather location to be based upon. I’ve gone and selected a location that’s close to me but not exactly in my location for privacy reasons for the purpose of this tutorial. In your case, you can either give the web page permission to access your location, or simply type in your location in the “location” bar.
As for the “Time Of Day”, for the purpose of demonstrating the tutorial, you can choose a time that is occuring soon, for example with me it’s currently 11.20, so I’ll choose 12pm in order to see the effect trigger and have enough time to set it up before the time elapses.
Once you’ve completed this tutorial, you can go ahead and change this time setting to something more appropriate. For example setting it so that it triggers before you wake up each day.
After filling out both the “Time of Day” and “Location” sections. Press “Create Trigger” to continue.
We’ve completed the first section part! Onto the next section. Choose “Then That” to continue. In the search bar you’ll want to type in “Webhooks”.
A webhook, used for our purpose can be explained very briefly as a way for apps to send automated messages or information to other apps. ELI5 (Explained Like I’m 5) — “You set up an agreement with your neighbour that whenever he bakes a cake, he comes over to share some with you”.
Essentially what we’re doing is allowing our chosen app in the “If This” section to send Nomie a bunch of useful information. In this case we have “Weather Underground” that is sending us all kinds of weather information that is specific to the location we set up earlier. In my case, Cardiff, Uk. Importantly, we make sure that it sends all this data at the time we specified. The API Key that we generated earlier will then be used to point the Webhook in the right direction, so it knows which account to send the information to! This will then result in us having the trackers that we will create in Nomie, be populated with the data that Weather Underground gives us.
Now that you have a good understanding of what a webhook does. You’ll want to select from the list of Webhook options (Hint, there’s only one!).
Choose the available option, “Make a web request”. To bring up the next screen:
This screen may look a little complicated but it’s not I promise! The first section, “URL” helps us to tell the IFTTT service, where it can locate and send our information to our receiving application — Nomie. For this section you’ll always want to copy or type the following address: https://nomieapi.com/log
This URL will never change no matter what webhook you are setting up, so keep this URL handy or instead navigate back to Nomie, head to the Nomie API page, and on the page you’ll see, “Example Request”. If you click that you can see lots of great information that shows you what Nomie expects to receive in a valid webhook to the platform.
Here we can see that there’s a JSON Body example, showing that “note” and “api_key” are mandatory at all times if you want the webhook to correctly work. There’s also some optional fields showcased down below, however we will leave these out in the tutorial. Crucially, you can also see the URL which has a copy button, a quick press and you’ll have that address ready to paste into your webhook!
Next, choose from the dropdown in the “Method” section, select “POST”. Which as the name suggests is a little like a mail service. We’re getting IFTTT to send us our desired information when something triggers.
From the “Content Type” section choose “application/json”. This informs the service what type of format we’ll be sending our information through as, JSON.
Finally, the most important section is “Body”. This section needs to be completed carefully, making a mistake with typos or formatting will result in an error, so make sure to check this bit carefully.
Remember a little bit ago when we went to the “Example Request” section in the Nomie API. This is the structure that we will be following.
Something you can do now to familiarse yourself with the types of information we can get from our service “Weather Underground” is to have a look through the “Add Ingredient” section. Click the button to reveal a long list of data points or “Ingredients” that you can send through the service. These “Ingredients” will change depending on which service you selected in the “If This” part of the applet.
For the purpose of our example, I will be using the Celcius options (since that’s what we’re using in the UK). If you live somewhere that operates using Fahrenheit, then use these ingredients instead. Same goes for Miles Per Hour or Kilometers Per Hour.
The syntax for a JSON Body that Nomie will accept as mentioned above, has to look something like this.
{
“note”: “Information you are sending through here”,
“api_key”: “Your API key here”
}
For the “api_key” you’ll want to put your API Key that you generated in the Nomie app. So it will look something like this:
Make sure to have all your “” quotation marks and , commas in the correct spots and the curly braces beginning and ending your Body.
Next we’ll add our “note” information in the empty “” that we have next to it. We’ll be wanting to send over the following information (this is something that you can tailor to your needs):
These fields will be useful for me so I can get a good understanding of the weather that will be happening today. Mainly if it’ll be shorts weather or coat, hat, scarf and jeans weather!
In order to write this down in JSON format we will be using the following structure:
#tag(Ingredient),
The “#tag” tells Nomie which tracker the ingredient applies to. Therefore you can change these tags to match whatever data you are bringing into Nomie. For example sending over a count of the completed tasks in Todoist, I may have a tag called: “#daily_completed_tasks()”
For the purpose of our example however, I’m going to do this in a step by step fashion, I’ve input all the tags that we will be using into the “note” section.
NOTE: It is important that you do not use the enter key to create a new line between each tag, as this can cause an error when the applet runs. You have to seperate each tag by a comma and a space and let the text wrap around to each line on its own.
I then went back and added an ingredient into each tag’s parenthesis (). To do this you’ll want to put your cursor into the parenthesis.
Click the “Add Ingredient” button and then click the “CurrentTempCelsius” (or “CurrentTempFahrenheit”):
You’ll then see that our Ingredient has been added to the tag’s parenthesis, in the form of {{CurrentTempCelsius}}. Continue the process for each tag:
You can also manually enter this into the parenthesis by using the format {{ingredient}} however I find it easier to just enter it using the Add Ingredient button. By clicking away from the field you can see that the Ingredients highlight.
An invalid option will show as red, this usually means you’ve spelt the ingredient incorrectly:
Make sure you’ve entered all your ingredients into their corresponding tag’s parenthesis. Remember that if you’re using Fahrenheit and Kph (for wind) then make sure to choose the correct option from the list. You should then have something similar to this:
Make sure that all your , and “” are in their correct places. This is one of the more common issues, misplacing this comma or quotation after the last note bracket. Also make sure there are no spaces between the tag’s () and the ingredient.
Failure to have the correct syntax can cause errors later on such as:
IMPORTANT — Before you save the Webhook, there’s a correction that needs to be made. There’s an issue that occurs when you use the “Add Ingredient” button to fill the Ingredients into the JSON body.
For some reason, IFTTT adds a space between the left bracket of the tags and the left curly brace { of the ingredient. In order to fix this, simply change all your tags so that they go from this:
to this:
Notice how there’s no space between the bracket and the brace now. Make sure to repeat this for all your tags if you used the “add ingredient” button.
Hit “Continue” to review:
Hit “Finish” to create the applet!
Once completed you can change any parts of the applet by hitting the “settings” button on the top right.
This is where you can change the time of day after this tutorial is done, so that it occurs every morning before you wake up for example!
Step 3 — Creating Our Trackers In Nomie
Remember when we added all those tag sections in our JSON Body text? We’ll be creating trackers to match those tags, so that when the data is sent into Nomie, our application can find the corresponding tracker with a matching tag and give pass that data into the tracker!
As a recap these were:
#current_temp, #low_temp, #high_temp, #uv_index, #wind_speed
Come back into your Nomie “Track” section and navigate to the top right gear/setting button. By clicking it you’ll bring up this menu:
What we’re going to do, in order to keep our weather data seperate from our other trackers, is create a new tab by clicking.. you guessed it, “Create a new Tab…”. You can name the Tab whatever you fancy, for the tutorial I’ll name it “Weather Trackers”.
We now have a seperate tab in which we will create our trackers. Click “Add a tracker” and select “Create a Tracker” from the list
Create trackers for each of the tags that we are using (specificed above). With the “Tracker Label” using Uppercase is permitted as the tag will always stay Lowercase, but make sure that the spelling and format is the same as the tags we created above. For example:
Use “Number Input” in the “Tracker Type”.
For temperatures you can click “Show Advanced Options” and choose the “Measure By” section. Change to your desired measurement unit. For me that is Celsius.
Repeat until we have our full list of trackers for each tag:
Emoji’s can be copy and pasted from a list such as this.
Make sure that the names match our tags and they are all set to “Number Input”. Once you’ve got all of these created. You’re done with the set up phase!
Step 4 — Verifying That Everything Works
The next step is to check to see if your hard work is running as planned. In order to do this, wait till the time passes that you set in the Weather Underground section of IFTTT. Sometimes the applet takes a few minutes to run, usually between 5–10 minutes. Once you’ve waited a bit, check your activity in IFTTT.
In the profile drop down, choose “Activity” to bring up a list of all the applets attempting to run. You should see the applet that we have created:
It will have informed us that we have “turned on” the applet. Our applet will run usually within a few minutes of our designated time. Refresh the page to keep an eye out for a message like this:
Amazing, our applet works! Our applet has ran successfully, We can have a look at the complete report that Weather Underground is sending up by clicking the “Weather Underground — Today’s Weather Report Tab”
Here we can see an entire list of all the data that Weather Underground has provided us a report with. Notice how we’ve been given the entire set of data that Weather Underground has, it has given us more than we need! That’s because it’s the job of the Webhook set up in part 2, to decide on what data we’ve asked for and to throw away the rest of the unecessary data.
Now let’s have a look at what the Webhook has done with this Weather Underground data. We can take a look by expanding the “Webhooks” tab.
We can see that the “Ingredients” have been swapped with the real time weather numbers. This is what the Webhook will pass into Nomie! If however you got an “Applet Failed” instead, then check the “Action failure message” to find out more information.
The most common is, “Your server returned a undefined”. If you get this message then you’ll want to go back into the Body field in the settings of your applet. Look for common issues such as not using your “” and , properly. Also make sure that you haven’t used the enter key to replace any of the spaces between the tags. What I mean by this is:
Take two tags for example:
“note”: “#low_temp(), #high_temp()”,
This would work correctly as we have a space between both tags.
“note”: “#low_temp(),#high_temp()”,
This won’t work because I don’t have a space between the tags, This is the same thing that happens even if you have just pressed enter straight after the , that ends the low temp tag.
Step 5 — Output
Head back into your Nomie application, if you’ve made sure that auto-accept is turned on in the API settings then just refresh your application to see your entered data! Alternatively you can navigate over to the “Captured()” tab in the Nomie API and check to see if any logs have come in. Press “Check” to manually refresh the page.
You should then see your data attached to your trackers on the “Weather Trackers” page! You can also view this entered data on the “History” tab at the bottom:
Notice how sometimes you won’t receive a number through. As far as I am aware Weather Underground’s data changes throughout the day, because I pulled this data through later on, the temperature is expected to stay 1 degree for the remainder of the day therefore no High Temp is sent through. From my testings when you retrieve their data in the early morning you’re more likely to receive a full amount of data.
Conclusion
There we have it, hopefully this guide has been a good introduction to the world of IFTTT + Nomie. Make sure to give my publication a follow to stay tuned for more examples of using If This, Then That with Nomie and other web services for data tracking! Or alternatively check out the Nomie library for tutorials:
Make sure to have a look at the Nomie Sub Reddit to join the community. Or if you get stuck an need extra help, the community is a great help!