Preventing infinite loops in triggers

Plan requirement

Subscription Any plan
Access Admin

A trigger whose action satisfies its own conditions runs again. Zendesk has rate limiting and internal monitoring, but it publishes no threshold for trigger loops, so design as though nothing will catch it.

How a loop happens

A trigger's action counts as an update, and an update runs the triggers. So a rule that fires when priority is high and sets priority to high fires again on the update it just caused.

Two rules can do it between them, which is harder to spot: one sets a tag, the other reacts to the tag and changes a field the first watches.

What it looks like

  • A ticket with dozens of identical events seconds apart.
  • A customer receiving the same email repeatedly.
  • Your API usage rising sharply for no obvious reason.

What is documented sits on the incoming side rather than the trigger side. More than 20 emails from the same user within an hour and the next 20 are suspended with the cause Detected as email loop; beyond 40, further updates that hour are rejected outright. That catches the mail loop after it has started, and it does nothing about a trigger looping inside a single ticket.

Separately, Zendesk limits certain trigger conditions: a trigger that exceeds those limits is disabled, and re-enabling it produces an error.

The three defences

Use changed to, not is

A rule firing on a transition cannot fire again on the update it caused, because the transition already happened. This alone prevents most loops.

Exclude your own change

Add a condition on current user, or a tag the rule sets and then requires the absence of. Either makes the rule unable to react to itself, and the tag version is the technique Zendesk documents for automated mail: one trigger tags the tickets those messages create, and your notification triggers require that tag to be absent.

Do not set what you test

The simplest discipline. If a trigger's condition and action touch the same field, look at it twice.

Mail loops are the version customers see. Two systems auto-replying to each other, or a rule emailing an address that forwards back in. Zendesk suspends most automated mail for exactly this reason, which is why an out-of-office reply does not create a ticket. Between two Zendesk accounts with a sharing agreement there is a further protection: Zendesk keeps a list of partner support addresses and uses it to break the loop.

See also

Was this article helpful?

0

Still stuck?

Our support team will take a look with you.

Comments

0 comments

Article is closed for comments.