Controlling IFTTT Applet Flow with Filter Code
Use IFTTT Filter Code to normalize inconsistent trigger payloads, gate execution, and write to multiple actions without hosting a webhook.
19 Oct 2025, 22:35 UTC

The problem: one trigger format does not fit every action
You connect an RSS feed, a Twitter mention, and a webhook to the same Slack channel. Each service sends a different field name—entryTitle, text, value1—so your Slack action template breaks or sends blank messages. You want to drop runs that do not meet a threshold, or send different fields to Slack versus Telegram, without hosting a webhook server just to transform JSON.
What Filter Code does
IFTTT Filter Code is a JavaScript block that runs between a trigger and its actions on Pro and Pro+ plans. It executes in a sandboxed Node.js-based environment with ES2021 syntax support, a 200 ms CPU-time limit, and a 64 MB memory cap per run. The runtime exposes an IFTTT global object. Trigger data is read-only through IFTTT.trigger.fieldName. Action inputs are write-only through IFTTT.setActionField(actionName, fieldKey, value), meaning a filter cannot read back a value it just wrote. Calling IFTTT.skip() aborts the remaining actions for that run.
Worked example: normalize payloads and gate execution
This example normalizes inconsistent trigger fields into a single message, then writes that message to two actions. It also skips the run when the message is empty. Paste this into the Filter Code editor of a test applet with at least two downstream actions; replace 'Slack' and 'Telegram' with your actual action names.
const rawTitle = IFTTT.trigger.entryTitle || IFTTT.trigger.text || IFTTT.trigger.value1 || '';
const message = rawTitle.trim().slice(0, 280);
if (!message) {
console.log('Skipping empty message');
IFTTT.skip();
return;
}
IFTTT.setActionField('Slack', 'message', message);
IFTTT.setActionField('Telegram', 'text', message);
console.log('Routed message:', message);
Because trigger fields are read-only and action fields are write-only, treat the filter as a pure transformation: read from IFTTT.trigger, write to actions, do not attempt to read back what you set. If an uncaught exception occurs, the activity log shows Filter code error with a stack trace and downstream actions do not run. There is no interactive debugger or local emulator, so develop logic locally as pure functions before pasting it into the editor.
Limits and plan caveats
| Plan | Filter Code | Notes |
|---|---|---|
| Free | No | Static field mapping only; downgrading silently disables the filter |
| Pro | Yes | 200 ms CPU limit, 64 MB memory, no IFTTT.query() |
| Pro+ | Yes | Adds synchronous IFTTT.query() lookups; query latency counts toward the 200 ms budget |
- The sandbox blocks
require(),fetch(),setTimeout, and file I/O. Heavy computation or external API calls belong on a webhook you host. - There is no built-in secret store. API keys written directly into filter source are visible to anyone with applet edit access.
- Query results are not cached; repeated applet runs re-execute the same query.
Verify before you rely on it
Build a test applet: Webhook trigger → Filter Code → two Slack actions. Log IFTTT.trigger in the filter, then confirm setActionField mutates both actions independently in the activity log. To check the sandbox restriction, attempt require('lodash'); expect a reference error, not a loaded module. To simulate a failure, throw an error inside the filter and verify the activity log records Filter code error.
Filter Code is versioned per applet, and the UI shows diff history but no automated rollback. Export the applet with the IFTTT Platform CLI to store filter source in Git:
ifttt export <applet-id>
Run this locally where the CLI is installed and authenticated. Confirm the exported JSON contains a filter_code field before merging changes. The export file may include source code with embedded keys, so treat it as sensitive and do not commit it to a public repository.
Closing
Use Filter Code when you need lightweight routing and normalization inside IFTTT without provisioning a server. Stay under the time and memory limits, avoid embedded secrets, and keep filter source under version control so a plan downgrade or accidental edit does not silently break your automation.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.