15

I'm using a neat little IFTTT recipe that automatically responds to text messages I receive through Google Voice. This one, to be precise.

I only need it to run when I'm at work, so I've been turning it on and off manually every day as needed.

Is there any way to make the recipe active only at set times? Like between 9 am and 5 pm on weekdays, for example?

At first I thought the Date & Time channel would be useful but it doesn't look like there's a way to use it to trigger existing recipes or chain recipes together.

I did some internet searching and found this post on r/IFTTT asking the same question and receiving no answers.

5

It doesn't look like it. They have the trigger half of the solution with the Date & Time channel. You can set actions to trigger on certain days of the week at certain times. So imagine one recipe to turn your Google Voice recipe on at 9am and one to turn it off at 5pm.

However, the IFTTT channel has no actions to do anything like turn on or off a recipe. You could consider contacting them to ask if they could add these features. My guess is they've considered it and thought that either no one would use it, or it would be abused in some way.

7

There is a way to do it, however it can be a bit complicated and requires a unix web host with php 5, so be warned.


Step 1

The first thing you have to do is add the maker channel. You do this the same way you'd add any other channel, by clicking "channels" at the top of the page and searching for it, then clicking on it and pressing the "add channel" button.

Step 2

Create a blank php document on your webhost. It doesn't really matter where, as long as you can access it with a browser.

Step 3

What you do now, is make a recipe where your trigger activates the maker channel. Once you get your trigger set up, just click the maker channel then "Make a web request". Then type in the web URL of the document we made in step 2 in the URL field. Change the method to GET and leave the other fields blank.

Step 4

Now make a recipe that's triggered by a web request. Make the event name whatever you want, as long as you remember it. Make the "that" of the recipe whatever you want it to do.

Step 5

Now, we add code into that PHP document we made back in step 2. Add this code in, changing time time allowed (currently 6am), the pass, the time zone, and the URL where you'll change "example-key" to your key (found here)and {{event}} to the event you named in step 4.

<?php
    date_default_timezone_set("EST"); 
$time = strftime("%H");
if($time == 6){
echo exec('curl -X POST https://maker.ifttt.com/trigger/{{event}}/with/key/example-key');
}
}
?>

Save the document, and you're done.

  • If you don't have a Web server, you could try a service like hook.io – jamesmstone Jan 26 '16 at 20:06
0

Not mine but this works great for me! Go to https://platform.ifttt.com/maker and create applet and use this in the filter code section. The *.skip() is important to set cancel the action after the trigger. P.S. not a coder!

// Change startTime and stopTime to set the time range when you want // your service's action (the 'That') to happen: // var startTime = moment('03:00 pm', "HH:mm a"); var stopTime = moment('06:00 pm', "HH:mm a"); // // startTime is the first time when the action can happen // stopTime is the last time the action can happen... until time // reaches the next startTime. // // Notes: // - startTime can be later than stopTime. For example, startTime // can be 10:00pm and stopTime 06:00am. This means actions can // happen from 10pm of one day until 6am of the next day but // not between 6am and 10pm of either day. // // - startTime cannot be the same as stopTime // // - 'Skip' messages are written when the service's action does not // happen, such as after the stopTime and before the next // start time. // // - If you want to use this code with a service other than // Gmail.sendYourselfAnEmail, you must change the lines that // reference Gmail.sendYourselfAnEmail.skip to the skip method // for your service. // // -------------------------- // // The code converts everything to minutes for comparision purposes // var startTimeMinutes = startTime.minutes() + startTime.hours() * 60; var stopTimeMinutes = stopTime.minutes() + stopTime.hours() * 60; var triggerTimeMinutes = Meta.triggerTime.minutes() + Meta.triggerTime.hours()* 60; // // StartTime = stopTime not allowed. // // Set some defaults... // var doThat = new Boolean(false); var whatsup = "'That' has been skipped"; // // If start time is less than stop time, then the range is assumed to // be a continuous period during a single day. E.g., 9am-6pm. // if ((startTimeMinutes<stopTimeMinutes) && (triggerTimeMinutes >= startTimeMinutes && triggerTimeMinutes <= stopTimeMinutes)) { doThat = Boolean(true); whatsup = "range within a single day"; } // // If start time > stop time, then the range is assumed to span // midnight (12am). E.g. 10pm-6am. This range covers parts of two // days. // else if ((startTimeMinutes>stopTimeMinutes) && (triggerTimeMinutes > startTimeMinutes || triggerTimeMinutes < stopTimeMinutes)) { doThat = Boolean(true); whatsup = "range spans midnight"; } // // Out of range... // if (doThat == false) {
AndroidMessages.sendAMessage.skip("Event happened outside time range (" + whatsup +") - time of trigger was "+Meta.triggerTime.format('LT')+", but start time to allow the action is "+ startTime.format('LT') + " and stop time is "+ stopTime.format('LT') + " Debug info: minutes are "+triggerTimeMinutes + " " + startTimeMinutes + " " + stopTimeMinutes); } // // The following code can be uncommented for debugging. It writes // an entry to the activity log instead of performing the // action. // // else // { // IfNotifications.sendNotification.setMessage("Action can happen (" + whatsup +") - time of trigger was "+Meta.triggerTime.format('LT')+", start time is "+ startTime.format('LT') + ", and stop time is "+ stopTime.format('LT') + ". Debug info: Minutes are trigger="+triggerTimeMinutes + ", start=" + startTimeMinutes + ", and stop=" + stopTimeMinutes); // } // }

0

Another way to achieve that, without resorting to creating a manual applet, is using Stringify.com as a middleman.
It allows you to include an "only if" node in your flows (Stringify flow = IFTTT recipe). If you're lucky enough, Stringify already supports what you want to trigger, but there's only a handful of "things" they support - comparing to the plethora on IFTTT.

You can set "input" recipes on IFTTT that will trigger a Stringify trigger, and an "output" recipe that gets triggered from a Stringify action.

For instance:

  • IFTTT Recipe #1 triggers Flow #1 when I leave my home wifi
  • Stringify Flow #1 only runs when it's night and it triggers Recipe #2
  • IFTTT Recipe #2 turns my eWeLink light off

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.