Filter code lets you add custom JavaScript logic to your Applets. You can add filter code using IFTTT Chat or the classic composer. For an overview of filter code and what you can do with it, see this guide.
Add filter code with IFTTT Chat
With IFTTT Chat, you can describe the logic you want to add to your Applet, and it can generate and add the filter code for you.
For example, you could ask IFTTT Chat:
When my camera detects motion, send me a notification, but only if it's after 9 PM.
IFTTT Chat can create the Applet and add filter code that checks the current time before running the notification Action.
You can also ask IFTTT Chat to add filter code to an existing Applet. Describe the logic you want to add and include the name or Applet id of the Applet you'd like to edit.
Add filter code with the classic composer
Add filter code to a new Applet
To add filter code to a new Applet using the classic composer:
- Go to ifttt.com/create and select the Classic tab.
- Click Add to the right of If This, then add a Trigger to your Applet.
- Click Add to the right of Then That, then add an Action to your Applet.
- Between your Applet's Trigger and Action, click the first plus button (+), then click Add to the right of Filter Code.
- Write your own JavaScript or use one of the filter code generators to get started.
When you're finished, click Create filter, then Continue and Finish.
Add filter code to an existing Applet
To add filter code to an existing Applet, go to ifttt.com/my_applets, click your Applet to view it, then click Edit Applet.
- Click the first plus button (+) between your Applet's Trigger and Action.
- Click Add to the right of Filter Code to access the filter code editor.
- Write your own JavaScript or use one of the filter code generators to get started.
When you're finished, click Create filter, then Update to.
Available methods for your Applet's Trigger, Queries, and Actions
When you're writing filter code yourself, the filter code editor displays the available methods and data for your Applet's Trigger, Queries, and Actions on the right side of the editor. Click the dropdown arrow next to a method or data field to expand it and view more details.
The editor also includes methods available to all Applets, such as Meta.currentUserTime, Meta.triggerTime, and Meta.previousTriggerTime.
These available methods are specific to the services and Applet you're working with, so check the filter code editor for the methods available to your Applet.
Filter code generators
If you're not comfortable writing JavaScript, the filter code editor includes several tools to help you generate code available under the Code generators heading.
You can choose from generators for common use cases or use the AI filter code generator to create code based on what you want your Applet to do. Describe the logic you want to add, and the AI filter code generator will generate the code for you.
For example, you could enter:
Only run this Action if the current temperature is above 80°F.
After generating the code, click Copy to clipboard to copy it, then paste it into the filter code editor. When you're finished, click Add filter code in the top right, then follow the remaining prompts to save your Applet.
Filter code on mobile
Filter code can also be viewed and edited in the IFTTT mobile app. For more information, see Can I add/edit filter code in the IFTTT mobile apps?.