New services
Explore Plans
Mobile menu Close menu

Documentation

Creating Applets

The Applet creation tool is designed to help you build valuable Applets and publish them for the world to use. Your Applets can have multiple actions and custom filter code to go beyond the basic “if this, then that” paradigm. If there are terms below that you don't understand, check out the glossary.

Some tips on using the tool

  • Applet title: Be specific. This is your chance to tell the user what they should expect this Applet to do for them — approach it like you would writing an instruction manual, instead of a catchy headline. Keep it short and to the point.

  • Applet description: This is where you can add in details about triggers and actions, and any information the user should customize, such as location or a hashtag.

  • Trigger: Select the trigger that you’d like to use for the Applet. The tool allows you to select from all services on IFTTT that have at least one trigger.

  • Trigger fields: The tool allows you to either hide or show trigger fields to the user when turning on the Applet. If the value for the field should be the same for all users, fill out the field and mark it as hidden. For example, if your Applet is “Tweet new technology articles from the New York Times”, you would select “Technology” for the NY Times “Section” trigger field and then hide it. If your Applet is “Tweet new articles from a section of the New York Times” you would mark the “Section” field to be chosen by the user.

  • Queries: Coming soon is the ability to query for information to be used as filtering conditions or to provide more data to be used in an action run.

  • Filter: You can write simple filter code which dictates which actions should run based on the trigger data coming in.

  • Action(s): You can select one or more actions to run when the trigger event occurs. Add additional actions by clicking the “Add action” button. Keep in mind that users must have activated all services used in the Applet in order to turn it on.

  • Action fields: Like trigger fields, data can be pre filled and hidden in an action field or can be filled out by the user. In the case of action fields, it is important to hide any fields that don’t need to be filled out by the user. For example, if your Applet is “Tweet your Instagram photos”, you would place the Instagram “SourceURL” ingredient in the Twitter “Image URL” action field and then hide it as this is the only appropriate ingredient to have in that field. You might ask the user to fill out other types of action fields themselves such as their location, their email address, or a name of a photo album private to them. Note that action fields marked to be “chosen by the user” can include prefilled text or numbers, but cannot include prefilled ingredients.

Using filter code

When you build an Applet with the creation tool, you can use the filter code feature to add extra flexibility and power by writing your own JavaScript that runs whenever the Applet does. Your code has access to the data returned by the trigger, as well as metadata like the current time in the user's time zone, and it can use that information to override action field values or skip actions.

See the Applets Cookbook section for some examples of what you can do with filter code.

There are some fields that are always available:

  • Meta.currentUserTime: The current time when your code is evaluated, in the user's timezone. This returns a Moment.js object.

  • Meta.triggerTime: The time that the trigger event happened, in the user's timezone. This should be close to currentUserTime, but could vary depending on the polling period of the Applet's trigger. This returns a Moment.js object.

There are additional fields available depending on the specific trigger and actions that your Applet uses. For example, if your Applet uses the Weather Underground service's "Sunrise" trigger, your code can use Weather.sunRises to get the trigger's ingredients. If it uses the LIFX service's "Toggle lights on/off" action, your code can use Lifx.toggle to override that action's fields or skip it instead of running it.

The trigger's object contains the values of each of the trigger's ingredients. If you're using the "Sunrise" trigger, you can get the current temperature in Celsius by writing Weather.sunRises.TempCelsius. For convenience, you can also just write Trigger.TempCelsius, since an Applet can only have one trigger. Note that the ingredient values are always strings, even when they represent numeric data.

Each action's object has the following methods:

  • skip(): This lets you skip an action instead of running it. You can optionally provide a message that will be shown in the user's event feed to explain why the Applet decided not to run the action.

  • set[FieldName](): For each hidden field of the action, you can use a correspondingly-named setter method to override its value. If you do, the value you provide will be used verbatim, skipping the templating step that normally happens with hidden fields. If you want to use ingredient values, you can do so by just using string concatenation or JavaScript template literals:

Twitter.postNewTweet.setTweet(
  `The sun rose at ${Weather.sunRises.SunriseAt}`
)

When you override the value of a dropdown field, the argument you pass in should be the option's value, not its label. The filter code editor has autocomplete support for dropdown field setters to make this easier.

Technical details

  • When you write filter code, you're technically writing TypeScript, not JavaScript. This helps prevent runtime problems with your code by catching simple mistakes as early as possible. You should generally be able to just write normal JavaScript, but the TypeScript documentation may be helpful if you run into issues with more advanced use cases.

  • Filter code is run in an isolated environment with a short timeout. There are no methods available that do any I/O (blocking or otherwise), so your code should execute quickly.

Testing and publishing your Applets

  • When your Applet has been all filled out, click the "Preview" button to create a private version of the Applet.

  • Visit your service page to try out the Applet to make sure that it is working as expected. Private Applets can be modified based on your testing.

Applets Cookbook

In this section we provide a series of examples of Applets that take advantage of the Filter Code. It is important to note that JavaScript (Typescript) is a full-fledged programming language - if you need help you might consider participating in the Maker community on Hackster.io or learning JavaScript.

Example: Random light colors

Applet description

  • Random light colors
  • Change your LIFX colors to a random color

Trigger

  • Button Widget: Button Press

Filter code

var colors = ["#FF8400", "#FF0000", "#15FF00", "#FF00D4","#00D4FF","#003CFF"]
var index = Math.floor((Math.random() * colors.length))
Lifx.color.setAdvancedOptions('color: ' + colors[index] + '; brightness: 1; duration: 12')

Action(s)

  • Lifx: change color of lights

Example: Adjust your lights as it gets darker outside

Applet description

  • Adjust your lights as it gets darker outside
  • Change your LIFX light bulbs to reflect the color outside and have a more natural color as it gets darker outside

Trigger

  • Date & Time: Every hour

Filter code

var hour     = Meta.currentTime.hour()
var colorKey = hour.toString()

var colors: {[key:string]:string} = {
  "17":"#F3F2EB",
  "18":"#F7F2E6",
  "19":"#F9EFE0",
  "20":"#FBEFDC",
  "21":"#FBE5C6",
  "22":"#FBE5C6"
}

if (hour < 17) {
  Lifx.color.skip("Too early")
} else if (hour < 22)  {
  Lifx.color.setAdvancedOptions(
    'color: ' + colors[colorKey] + '; brightness: 1; duration: 12'
  )
} else {
  Lifx.color.skip("Too late")
}

Action(s)

  • Lifx: change color of lights

Example: Flight deals from or to San Francisco

Applet description

  • Flight deals: San Francisco
  • Get a daily email with flight tickets on sale below $400.00.

Trigger

  • Twitter: New tweet from search
  • This Applet uses a search field (hidden from the user) with value: (from:SecretFlying OR from:AirFareSpot OR from:FTMileageRuns OR from:ThePointsGuy OR from:airfarewatchdog) AND (SanFrancisco OR "San Francisco" OR SFO OR "SF" OR "SFBayArea" OR OAK OR "Oakland" OR "Bay Area")

Template for creating an IFTTT Applet

Filter code

var txt = Ingredients.Text || ""
var price = parseInt((txt.match(/\s\$(\d+)\s/) || [])[1])

if (price > 400) {
  EmailDigest.sendDailyEmail.skip("Too expensive")
}

Action(s)

  • Lifx: change color of lights

Example: Daily motivational quote

Applet description

  • Daily quote
  • Receive a daily motivational quote on your phone and a weekly digest with all the quotes.

Trigger

  • Date & Time: Everyday at a time chosen by the user

Filter code

// quotes by brainyquote.com
var data = [{"quote":"Life is 10% what happens to you and 90% how you react to it.","author":"Charles R. Swindoll"},{"quote":"Only I can change my life. No one can do it for me.","author":"Carol Burnett"},{"quote":"Infuse your life with action. Don't wait for it to happen. Make it happen. Make your own future. Make your own hope. Make your own love. And whatever your beliefs, honor your creator, not by passively waiting for grace to come down from upon high, but by doing what you can to make grace happen... yourself, right now, right down here on Earth.","author":"Bradley Whitford"},{"quote":"Optimism is the faith that leads to achievement. Nothing can be done without hope and confidence.","author":"Helen Keller"}]

var day  = Meta.currentTime.day()
var wday = Meta.currentTime.format('dddd')
var msg  = data[day]['quote'] + 'by ' + data[day]['author']

IfNotifications.sendNotification.setMessage(msg)
EmailDigest.sendWeeklyEmail.setTitle(wday)
EmailDigest.sendWeeklyEmail.setMessage(msg)

Action(s)

  • Notifications: Send notification
  • Email Digest: Add to weekly email digest

Example: Random Motivational quote button

Applet description

  • Random motivational quote button
  • Receive a random quote every time you a press a button. Quotes from brainyquote.com

Trigger

  • Button Widget: button press

Filter code

// Quotes by brainyquote.com
var data = [{"quote":"Life is 10% what happens to you and 90% how you react to it.","author":"Charles R. Swindoll"},{"quote":"Only I can change my life. No one can do it for me.","author":"Carol Burnett"},{"quote":"Infuse your life with action. Don't wait for it to happen. Make it happen. Make your own future. Make your own hope. Make your own love. And whatever your beliefs, honor your creator, not by passively waiting for grace to come down from upon high, but by doing what you can to make grace happen... yourself, right now, right down here on Earth.","author":"Bradley Whitford"},{"quote":"Optimism is the faith that leads to achievement. Nothing can be done without hope and confidence.","author":"Helen Keller"},{"quote":"Good, better, best. Never let it rest. 'Til your good is better and your better is best.","author":"St. Jerome"},{"quote":"Always do your best. What you plant now, you will harvest later.","author":"Og Mandino"},{"quote":"In order to succeed, we must first believe that we can.","author":"Nikos Kazantzakis"},{"quote":"If you fell down yesterday, stand up today.","author":"H. G. Wells"},{"quote":"With the new day comes new strength and new thoughts.","author":"Eleanor Roosevelt"},{"quote":"Failure will never overtake me if my determination to succeed is strong enough.","author":"Og Mandino"},{"quote":"Keep your eyes on the stars, and your feet on the ground.","author":"Theodore Roosevelt"},{"quote":"It always seems impossible until it's done.","author":"Nelson Mandela"},{"quote":"It does not matter how slowly you go as long as you do not stop.","author":"Confucius"},{"quote":"Quality is not an act, it is a habit.","author":"Aristotle"},{"quote":"The secret of getting ahead is getting started.","author":"Mark Twain"},{"quote":"If you can dream it, you can do it.","author":"Walt Disney"},{"quote":"A creative man is motivated by the desire to achieve, not by the desire to beat others.","author":"Ayn Rand"},{"quote":"Believe in yourself! Have faith in your abilities! Without a humble but reasonable confidence in your own powers you cannot be successful or happy.","author":"Norman Vincent Peale"},{"quote":"Problems are not stop signs, they are guidelines.","author":"Robert H. Schuller"},{"quote":"You can't cross the sea merely by standing and staring at the water.","author":"Rabindranath Tagore"},{"quote":"Setting goals is the first step in turning the invisible into the visible.","author":"Tony Robbins"},{"quote":"We should not give up and we should not allow the problem to defeat us.","author":"A. P. J. Abdul Kalam"},{"quote":"Start where you are. Use what you have. Do what you can.","author":"Arthur Ashe"},{"quote":"Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.","author":"Thomas A. Edison"},{"quote":"Accept the challenges so that you can feel the exhilaration of victory.","author":"George S. Patton"},{"quote":"Knowing is not enough; we must apply. Willing is not enough; we must do.","author":"Johann Wolfgang von Goethe"}, {"quote":"Never, never, never give up.","author":"Winston Churchill"},{"quote":"If you want to conquer fear, don't sit home and think about it. Go out and get busy.","author":"Dale Carnegie"},{"quote":"We may encounter many defeats but we must not be defeated.","author":"Maya Angelou"},{"quote":"When something is important enough, you do it even if the odds are not in your favor.","author":"Elon Musk"},{"quote":"You are never too old to set another goal or to dream a new dream.","author":"Les Brown"},{"quote":"Look up at the stars and not down at your feet. Try to make sense of what you see, and wonder about what makes the universe exist. Be curious.","author":"Stephen Hawking"},{"quote":"The will to win, the desire to succeed, the urge to reach your full potential... these are the keys that will unlock the door to personal excellence.","author":"Confucius"},{"quote":"Do the difficult things while they are easy and do the great things while they are small. A journey of a thousand miles must begin with a single step.","author":"Lao Tzu"},{"quote":"Be kind whenever possible. It is always possible.","author":"Dalai Lama"},{"quote":"Set your goals high, and don't stop till you get there.","author":"Bo Jackson"},{"quote":"The past cannot be changed. The future is yet in your power.","author":"Unknown"},{"quote":"March on. Do not tarry. To go forward is to move toward perfection. March on, and fear not the thorns, or the sharp stones on life's path.","author":"Khalil Gibran"},{"quote":"Motivation is the art of getting people to do what you want them to do because they want to do it.","author":"Dwight D. Eisenhower"},{"quote":"When you reach the end of your rope, tie a knot in it and hang on.","author":"Franklin D. Roosevelt"},{"quote":"Never give up, for that is just the place and time that the tide will turn.","author":"Harriet Beecher Stowe"},{"quote":"Things do not happen. Things are made to happen.","author":"John F. Kennedy"},{"quote":"The way to get started is to quit talking and begin doing.","author":"Walt Disney"},{"quote":"Aim for the moon. If you miss, you may hit a star.","author":"W. Clement Stone"},{"quote":"Be miserable. Or motivate yourself. Whatever has to be done, it's always your choice.","author":"Wayne Dyer"},{"quote":"Your talent is God's gift to you. What you do with it is your gift back to God.","author":"Leo Buscaglia"},{"quote":"Perseverance is not a long race; it is many short races one after the other.","author":"Walter Elliot"},{"quote":"Always desire to learn something useful.","author":"Sophocles"},{"quote":"Go for it now. The future is promised to no one.","author":"Wayne Dyer"},{"quote":"There's a way to do it better - find it.","author":"Thomas A. Edison"},{"quote":"The more man meditates upon good thoughts, the better will be his world and the world at large.","author":"Confucius"},{"quote":"Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.","author":"Samuel Beckett"}, {"quote":"If you don't like how things are, change it! You're not a tree.","author":"Jim Rohn"},{"quote":"There is only one corner of the universe you can be certain of improving, and that's your own self.","author":"Aldous Huxley"},{"quote":"Perseverance is failing 19 times and succeeding the 20th.","author":"Julie Andrews"},{"quote":"If you're going through hell, keep going.","author":"Winston Churchill"},{"quote":"A good plan violently executed now is better than a perfect plan executed next week.","author":"George S. Patton"},{"quote":"It is very important to know who you are. To make decisions. To show who you are.","author":"Malala Yousafzai"},{"quote":"The more things you do, the more you can do.","author":"Lucille Ball"},{"quote":"Be Impeccable With Your Word. Speak with integrity. Say only what you mean. Avoid using the word to speak against yourself or to gossip about others. Use the power of your word in the direction of truth and love.","author":"Don Miguel Ruiz"},{"quote":"I am not afraid... I was born to do this.","author":"Joan of Arc"},{"quote":"The ultimate aim of the ego is not to see something, but to be something.","author":"Muhammad Iqbal"},{"quote":"I was motivated to be different in part because I was different.","author":"Donna Brazile"},{"quote":"Consult not your fears but your hopes and your dreams. Think not about your frustrations, but about your unfulfilled potential. Concern yourself not with what you tried and failed in, but with what it is still possible for you to do.","author":"Pope John XXIII"},{"quote":"What you get by achieving your goals is not as important as what you become by achieving your goals.","author":"Zig Ziglar"},{"quote":"Even if you fall on your face, you're still moving forward.","author":"Victor Kiam"},{"quote":"No bird soars too high if he soars with his own wings.","author":"William Blake"},{"quote":"One way to keep momentum going is to have constantly greater goals.","author":"Michael Korda"},{"quote":"Beginning today, treat everyone you meet as if they were going to be dead by midnight. Extend to them all the care, kindness and understanding you can muster, and do it with no thought of any reward. Your life will never be the same again.","author":"Og Mandino"},{"quote":"The first step toward success is taken when you refuse to be a captive of the environment in which you first find yourself.","author":"Mark Caine"},{"quote":"If you think you can do it, you can.","author":"John Burroughs"},{"quote":"Expect problems and eat them for breakfast.","author":"Alfred A. Montapert"},{"quote":"Well done is better than well said.","author":"Benjamin Franklin"},{"quote":"Do not wait; the time will never be 'just right.' Start where you stand, and work with whatever tools you may have at your command, and better tools will be found as you go along.","author":"George Herbert"},{"quote":"Don't watch the clock; do what it does. Keep going.","author":"Sam Levenson"},{"quote":"Poverty was the greatest motivating factor in my life.","author":"Jimmy Dean"},{"quote":"Never retreat. Never explain. Get it done and let them howl.","author":"Benjamin Jowett"},{"quote":"Deserve your dream.","author":"Octavio Paz"}, {"quote":"I've worked too hard and too long to let anything stand in the way of my goals. I will not let my teammates down and I will not let myself down.","author":"Mia Hamm"},{"quote":"The key is to keep company only with people who uplift you, whose presence calls forth your best.","author":"Epictetus"},{"quote":"Motivation will almost always beat mere talent.","author":"Norman Ralph Augustine"},{"quote":"The harder the conflict, the more glorious the triumph.","author":"Thomas Paine"},{"quote":"Do something wonderful, people may imitate it.","author":"Albert Schweitzer"},{"quote":"Either you run the day or the day runs you.","author":"Jim Rohn"},{"quote":"Arriving at one goal is the starting point to another.","author":"John Dewey"},{"quote":"You just can't beat the person who never gives up.","author":"Babe Ruth"},{"quote":"Many are called but few get up.","author":"Oliver Herford"},{"quote":"I'd rather attempt to do something great and fail than to attempt to do nothing and succeed.","author":"Robert H. Schuller"},{"quote":"I've found that luck is quite predictable. If you want more luck, take more chances. Be more active. Show up more often.","author":"Brian Tracy"},{"quote":"God always strives together with those who strive.","author":"Aeschylus"},{"quote":"I know where I'm going and I know the truth, and I don't have to be what you want me to be. I'm free to be what I want.","author":"Muhammad Ali"},{"quote":"Go big or go home. Because it's true. What do you have to lose?","author":"Eliza Dushku"},{"quote":"You can't build a reputation on what you are going to do.","author":"Henry Ford"},{"quote":"By failing to prepare, you are preparing to fail.","author":"Benjamin Franklin"},{"quote":"We aim above the mark to hit the mark.","author":"Ralph Waldo Emerson"},{"quote":"Hitch your wagon to a star.","author":"Ralph Waldo Emerson"},{"quote":"Learning is the beginning of wealth. Learning is the beginning of health. Learning is the beginning of spirituality. Searching and learning is where the miracle process all begins.","author":"Jim Rohn"},{"quote":"A somebody was once a nobody who wanted to and did.","author":"John Burroughs"},{"quote":"Every exit is an entry somewhere else.","author":"Tom Stoppard"},{"quote":"Wherever you are - be all there.","author":"Jim Elliot"},{"quote":"Do your work with your whole heart, and you will succeed - there's so little competition.","author":"Elbert Hubbard"},{"quote":"Never give in and never give up.","author":"Hubert H. Humphrey"},{"quote":"Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire. This is your moment. Own it.","author":"Oprah Winfrey"},{"quote":"A will finds a way.","author":"Orison Swett Marden"}, {"quote":"I learned that we can do anything, but we can't do everything... at least not at the same time. So think of your priorities not in terms of what activities you do, but when you do them. Timing is everything.","author":"Dan Millman"},{"quote":"The wise does at once what the fool does at last.","author":"Baltasar Gracian"},{"quote":"A goal is a dream with a deadline.","author":"Napoleon Hill"},{"quote":"You create your opportunities by asking for them.","author":"Shakti Gawain"},{"quote":"If you don't ask, you don't get.","author":"Stevie Wonder"},{"quote":"Without hard work, nothing grows but weeds.","author":"Gordon B. Hinckley"},{"quote":"You have to make it happen.","author":"Denis Diderot"},{"quote":"You must take action now that will move you towards your goals. Develop a sense of urgency in your life.","author":"H. Jackson Brown, Jr."},{"quote":"Don't think, just do.","author":"Horace"},{"quote":"Your heaviest artillery will be your will to live. Keep that big gun going.","author":"Norman Cousins"},{"quote":"It's always too early to quit.","author":"Norman Vincent Peale"},{"quote":"Set yourself earnestly to see what you are made to do, and then set yourself earnestly to do it.","author":"Phillips Brooks"},{"quote":"Who seeks shall find.","author":"Sophocles"},{"quote":"Determine never to be idle. No person will have occasion to complain of the want of time who never loses any. It is wonderful how much may be done if we are always doing.","author":"Thomas Jefferson"},{"quote":"They can conquer who believe they can.","author":"Virgil"},{"quote":"The more we do, the more we can do.","author":"William Hazlitt"},{"quote":"Begin to be now what you will be hereafter.","author":"William James"},{"quote":"Do whatever you do intensely.","author":"Robert Henri"},{"quote":"There is nothing deep down inside us except what we have put there ourselves.","author":"Richard Rorty"},{"quote":"We make the world we live in and shape our own environment.","author":"Orison Swett Marden"},{"quote":"Step by step and the thing is done.","author":"Charles Atlas"},{"quote":"The weeds keep multiplying in our garden, which is our mind ruled by fear. Rip them out and call them by name.","author":"Sylvia Browne"},{"quote":"Crave for a thing, you will get it. Renounce the craving, the object will follow you by itself.","author":"Swami Sivananda"},{"quote":"I like motivational books, because I like the go-getting American spirit - your destiny is in your own hands, life is what you make it, don't accept your limitations, jump before you're pushed, leap before you look.","author":"Louise Mensch"},{"quote":"I like to put on hardcore when I have to clean my apartment, which I hate to do, but it's motivational. I like old heavy metal when I'm outside working on my car. Music has definite functions for me.","author":"Peter Steele"},{"quote":"I went to a motivational training course once, a course of self-discovery, and I found out after a week that my fear - it was not a fear of not being accepted - was a very violent fear of failure.","author":"Emanuel Steward"}]

var i = Math.floor((Math.random() * data.length))
var msg = data[i]['quote'] + 'by ' + data[i]['author']

IfNotifications.sendNotification.setMessage(msg)

Action(s)

  • Notifications: Send notification