Using IFTTT with the API

Although the YNAB API isn't listed as an official service on IFTTT currently (we're looking into that!) I wanted to demonstrate how to get IFTTT working with the new API so you can build that integration you have been thinking about.

Below, I'll walk you through setting up an IFTTT Applet that will allow you to send a SMS text message to enter a new YNAB transaction.  Using SMS as the trigger is just an example.  You could use any available IFTTT trigger for this.

Let's get to it.

We're going to use the IFTTT Platform, which is a special area on IFTTT's website where you can build your own Applets with more options and control than have through the main IFTTT site.

So, go to https://platform.ifttt.com and click "Join Now" (if you haven't joined already).

Once get your IFTTT Platform initially setup, you should be able to create a "New Applet".  The screen will look like this:

In this example, I'm going to use the SMS service as a trigger so that I can send a text message with an amount and have a transaction created in YNAB.

First of all, select "SMS" as the trigger and tell it to "Send IFTTT any SMS".

If you're using the SMS service for the first time, IFTTT will ask you do a bit of setup with that service and will eventually give you the target SMS phone number you will use.  You'll want to keep track of this for later. 

Next, you'll want to add "Filter Code".  This is some simple JavaScript code that will be used to transform some of the data and prepare a request to be sent to YNAB.  My filter code looks like the following:

If you want to copy/paste that example, here you go:

const account_id = "31656018-364d-FAKE-3bf5b119f3d3";
// Use current date in ISO format (i.e. '2018-06-02')
const date = Meta.currentUserTime.toISOString().substr(0, 10);
// Add a "0" to the amount specified in
// SMS message to translate to milliunits.
const amount = Sms.sendIftttAText.Message + "0";
const memo = "I came from IFTTT!";

let transaction = { account_id, date, amount, memo };
let body = JSON.stringify({ transaction });
MakerWebhooks.makeWebRequest.setBody(body);

Note: You'll want the account_id in the filter code to match the account_id on your own budget where you want the transaction to get created.  You can find this by doing a GET request on /budgets/{id}/accounts through the API or by simply opening up the YNAB app on the web, clicking on the desired account on the sidebar and noting the account_id in the URL.   Actually, to keep things simple, just do that.  Open up YNAB in a browser and select the target account. The format of the URL when you click an account on the sidebar is:

https://app.youneedabudget.com/{budget_id}/accounts/{account_id}

While you're at it, note that budget_id there too, because you'll need it next.

Finally, you'll want to "Add action" and specify "Webhooks".  This service will allow us to send a request to the YNAB API.  You'll need to have your budget_id and access_token handy for this. 

Specify the URL in the format:

https://api.youneedabudget.com/v1/budgets/{budget_id}/transactions?access_token={access_token}

The Method should be specified as "POST", Content Type specified as "application/json" and Body left blank.  All of the Visibility radios should be "Set by you".

Give your applet a nice title and description and then click Save!

Now, your new applet should show up in your "Private Applet" list.  You'll now want to click "Enable it on IFTTT" so that you can actually use it.

 

Now, you'll be taken back to IFTTT (remember, you have been on the IFTTT Platform site up to this point, not the main IFTTT site) and the new applet should be turned on and look like this:

 

Now, you're ready to test it.  If you didn't jot down your IFTTT SMS phone number earlier or don't know what it is, you can go to SMS Settings and find the the phone number listed under "Ifttt Phone Number".  This is the phone number you'll want to send a SMS message to.

Simply send a text message with an amount as the body (something like "4500") and open up YNAB to see that a transaction has been created!

This is a simple example but hopefully explains the basics, so you that you can tweak to your own liking and build something awesome.

Have fun and let us know what you build.

14replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • I would like to use IFTTT  to schedule a text to be sent on a recurring basis providing the balance of a particular budget line. Is that possible?

    Reply Like
    • Powder Blue Admiral This might be possible with Webhooks but there are some limitations.  Let us know if you get it working!

      Reply Like
  • Thank you for the post! I want to have a text message sent to a certain phone number when certain text is entered the memo line on a transaction. Do you know how I might go about that?

    Reply Like
    • Slate Blue Saxophone I don't think triggering with a Webhook if an item is added or updated on a REST API is supported in IFTTT Personal Apps so I'm not quite sure how you would accomplish this.  But, and this is a little hacky, if you were to create an RSS adapter around the YNAB API (https://glitch.com/ might be a quick an easy way to host this) then you could use an RSS "New item matches" trigger to search for memo with certain text (which would be included in the RSS item from your adapter) and then use an SMS action to send a text message using data from the RSS item.  Again, this is hacky and involves converting a REST response into RSS format which is strange but it might work!  If you go down this road let us know!

      Reply Like
  • This thread is 11 months old. Is YNAB a service on IFTTT?

    Reply Like
    • jayne_m YNAB is not one of the listed services on IFTTT.  We are working on a Zapier integration though.

      Reply Like
  • I just finished something cool today with IFTTT and YNAB. I can now say, "Hey, Google, budget 4.43, payee Ingles, category Groceries" and the transaction is immediately entered into YNAB. 

     

    I basically followed the instructions in the OP, with a few tweaks.

     

    For the trigger, I used "Google Assistant" configured as below.  Basically, everything after "budget" is going to get parsed and maniuplated in the filter. 

     

    For the filter, I use regular expressions to extract the variables, then post the data to YNAB. Here's the updated filter code:

     

    const account_id = "ed418cbe-e73e-4d6e-89a7-29550bd84271";
    // // Use current date in ISO format (i.e. '2018-06-02')
    const date = Meta.triggerTime.toISOString().substr(0, 10);
    
    const regex = /(.*) payee (.*) category (.*)/gm;
    
    const memo = GoogleAssistant.voiceTriggerWithOneTextIngredient.TextField;
    
    var a = regex.exec(memo)
    const amount = "-" + a[1].replace(/[^0-9]/g, "") + "0";
    const payee = a[2];
    const category = a[3];
    
    let boo = {
      "transaction": {
        "account_id": account_id,
        "date": date,
        "amount": amount,
        "payee_name": payee,
        "category_name": category,
        "memo": memo,
        "flag_color": "red"
      }
    };
    
    let body = JSON.stringify(boo);
    MakerWebhooks.makeWebRequest.setBody(body);

     

    It works great and I'm super excited. It's miles faster and easier than entering a transaction manually on the phone. 

    Reply Like 1
    • alexdresko Awesome!  This is great!

      Reply Like
      • msteppe91
      • msteppe91
      • 1 mth ago
      • Reported - view

      alexdresko Am I blind or is there no option for filter code anymore? I added the Google Assistant "If This" stage and the WebHooks "Then That" stage and see no option for filter code to actually parse my speech from the Google Assistant.

      Reply Like
      • alexdresko
      • I'm not a player, I just code a lot.
      • Forest_Green_Sidewinder
      • 7 days ago
      • 1
      • Reported - view

      msteppe91 You can still add filter code. You just have to add an action first for some reason. As soon as you add the webhooks action, you can add filter code. 

      Reply Like 1
  • I tried to set up a similar Applet as in the OP, but using email as the trigger instead, as my bank sends email notifications. The trouble is that IFTTT then requires the email to come from the email address of my IFTTT account. I tried to set up forwarding from Gmail to IFTTT, but can't verify the forwarding email address.

    Reply Like
    • Salmon Pegasus  

      I am trying  to build something similar but stuck on getting the information about the transaction in the mail transferred to the IFTTT recipe. Care to give some insight? 
      Did you resolve the forwarding issue?

      Zapier doesn't seem to have these kind of triggers out of the box neither, or am I missing something?
      Thanks

      Reply Like
    • Tomato Packet 

      Tomato Packet said:
      Zapier doesn't seem to have these kind of triggers out of the box neither, or am I missing something?

      I stand corrected. Zapier's own and free email parser does the trick! I've set up a zap to auto import Paypal transactions in YNAB through the confirmation email. Works perfect. Gmail forwarding verification is fully supported >> https://zapier.com/blog/email-parser-guide/#four

      Reply Like
  • FYI: Although we had been evaluating implementing an official IFTTT integration, we have not moved forward on this for several reasons but we have implemented a Zapier integration which provides similar abilities. 

    Reply Like
Like11 Follow
  • 11 Likes
  • 7 days agoLast active
  • 14Replies
  • 3016Views
  • 10 Following