Skip to main content
Beta
Loops are in beta and require the Developer Toolkit. To join the beta, email [email protected].

Create a Ticket When an Expected Email Does Not Arrive

Your backup software emails you when a job succeeds and when it fails. Email Processing already turns the failure emails into tickets. The dangerous case is the job that hangs: it neither succeeds nor fails, so no email arrives, no ticket is created, and nobody notices until someone needs a restore.

An email rule cannot react to an email that never comes. A loop can. This tutorial builds one loop for each backup job. Every success email resets the loop's clock. If the clock runs out before the next success email, the loop creates a ticket.

Building blocks, not a fixed recipe

This tutorial uses backup emails, but the same arrangement works for anything that should report in regularly: a nightly report, a monitoring heartbeat, a sync job, or a vendor's daily file. Change the field names, the wait, and what happens when time runs out.


Decide What Should Happen​

Picture a job that runs every night at 1:00 AM. Decide two things before you build:

DecisionThis tutorialOther valid choices
How long to wait26 hours: one day plus two hours of slack for a job that runs late.A shorter wait for jobs that run more often, or a longer one for weekly jobs.
What to do when time runs outCreate one ticket, then wait for the next success email.Send an email to the on-call tech, or create a ticket and keep reminding every day until the job recovers.

Before You Start​

Prerequisites​

  • Loops enabled on your account. Loops require the Developer Toolkit. If you do not see Loops under Apps in the top bar, email [email protected] to join the beta.
  • A mailbox that receives your backup success emails. If you do not have one yet, start with Create Your First Mailbox.

Look at your success emails​

Open a few success emails and find:

  • The job: a value that is different for every job and the same in every email about that job, such as the job name.
  • The customer: the company name, so the ticket lands on the right account.
  • The success marker: a word or phrase that only success emails contain.

This tutorial uses this simplified email:

Subject: [Success] Nightly backup ACME-FS01
Body: Company: Acme Corp
Job: ACME-FS01 Nightly
Result: Success

Your software's labels will be different. Adjust the extraction step to match the labels in your emails.


Part 1: Build the Loop Type​

The loop type describes one backup job being watched. It has two fields and two stages.

Step 1: Create the loop type and its fields​

  1. Click Apps in the top bar, then click Loops.
  2. Click Loop Types in the sidebar, then click New loop type.
  3. Enter the Name Backup Watch.
  4. On the Fields tab, click Add field under Fields of this loop type and add two fields:
NameTypeIndexedWhy
job_nameTextYesEach success email finds its loop by job name. Only indexed fields can be used to find a loop.
company_nameTextNoThe ticket uses it to find the right account.

Step 2: Add the two stages​

  1. On the Stages tab, a new loop type already has one stage. Enter the Stage name Healthy. Keep it first in the list: new loops start in the first stage.
  2. Select Wake on a schedule for Healthy and set it to every 26 Hours.
  3. Click Add stage and name the new stage Missing. Leave Wake on a schedule cleared, so the loop waits quietly there until the job reports in again.
  4. Click Create to save the loop type. The stage lists in the loop actions show saved stages only, so saving now lets you choose Missing in the next step.

Step 3: Move the loop to Missing when time runs out​

  1. In the Healthy stage, leave the When entered list empty. Every success email enters this stage, so anything you add here runs once per success email.
  2. Edit the When woken list and add Move Loop to Stage. Leave Loop empty, so it moves this loop, and choose the stage Missing.

A wake in Healthy only happens when 26 hours pass without a success email. That is the moment something is wrong.

Step 4: Create the ticket in the Missing stage​

Edit the When entered list of the Missing stage. For Autotask, add these actions:

ActionConfiguration
Autotask API: Query for one objectEntity Type Account, the condition AccountName equals {{loop.company_name}}, and Store the results in variable set to account.
Autotask API: Create an objectEntity Type Ticket. Set AccountID to {{custom.account.id}} (unlock the field to enter a variable), Title to No backup success email for {{loop.job_name}}, and the status, priority, and queue your team uses for backup problems.
Add Loop NoteNote: Created a ticket: no success email for 26 hours.

For ConnectWise, use Create ConnectWise Ticket, and for HaloPSA, use Create Halo Ticket, finding the company the same way you do in your other automations.

Click Update and Close to save the loop type.


Part 2: Send Success Emails to the Loop​

Now make every success email find its job's loop and move it back into Healthy.

Step 5: Create the rule​

  1. In the mailbox that receives your backup emails, click Add New Rule.
  2. Name it Reset Backup Watch.
  3. Add a condition so the rule runs only for success emails, for example the subject contains [Success].

Step 6: Extract the job and the company​

  1. Click Add Action, select Extract Strings, and click OK.
  2. Add two definitions:
VariableExtraction TypeTextIf Empty
job_nameText Expression{{after_string email.body "Job:" flags="tn"}}Generate an exception and stop processing
company_nameText Expression{{after_string email.body "Company:" flags="tn"}}Generate an exception and stop processing
  1. In Store the results in variable, enter extracted.

Step 7: Find the job's loop, or start watching a new job​

  1. Click Add Action, select Find or Open Loop, and click OK.
  2. Set Loop Type to Backup Watch.
  3. Under Match Fields, choose the field job_name with the value {{custom.extracted.job_name}}.
  4. Set Title to {{custom.extracted.job_name}}.
  5. Under Initial Field Values, choose company_name with the value {{custom.extracted.company_name}}.
  6. In Store the results in variable, enter backup_loop.

The first success email for a job opens its loop. Every later email for that job finds the same loop. You do not need to set up each job by hand.

Step 8: Reset the clock​

  1. Click Add Action, select Move Loop to Stage, and click OK.
  2. Set Loop to {{custom.backup_loop.loop.id}}.
  3. Set Stage to Healthy. This field is a text field outside a loop type, so type the stage name.

Moving a loop into the stage it is already in starts a new visit, and the 26-hour wait starts over from that moment.

Why not send an event?

Send Loop Event is a good way to hand information to a loop, but an event does not change the loop's stage or its wake schedule. For a clock that resets, the loop has to enter the stage again, so use Move Loop to Stage.


What Happens Now​

Follow one job through a week:

  1. Monday, 1:05 AM: the first success email for ACME-FS01 Nightly arrives. The rule opens a loop for the job in Healthy. The wait ends Tuesday at 3:05 AM.
  2. Tuesday, 1:04 AM: the next success email moves the loop back into Healthy. The wait now ends Wednesday at 3:04 AM.
  3. Wednesday: the job hangs. No email arrives.
  4. Wednesday, 3:04 AM: the wait runs out. The loop wakes, moves to Missing, and creates a ticket on Acme Corp titled No backup success email for ACME-FS01 Nightly.
  5. Thursday, 1:10 AM: a tech fixes the job and it succeeds. The success email moves the loop back into Healthy and the watch starts again. The ticket stays open for the tech to close.

Open the loop from All Loops to see this story on its timeline, and click View run on any entry to see exactly what ran.


Things to Know​

  • Each success email is a run. Moving the loop into Healthy runs that stage's When entered list, even when it is empty, and adds an entry to the loop's timeline. Each wake is a run too. Both count like any other run in History.
  • A new job enters Healthy twice. When Find or Open Loop opens a loop, the loop enters its first stage, and then Step 8 moves it into Healthy again. This is harmless.
  • A late success email can cross with the alert. If a success email arrives while the loop is already creating the ticket, the ticket is still created, and the loop returns to Healthy right after. If the timing is very close, the loop can end up in Missing even though the job succeeded; the next success email puts it back in Healthy.
  • Wakes are not to the second. A wake can run a minute or two after its scheduled time.
  • To stop watching a job, close its loop. Open the loop and click Close. Find or Open Loop still finds a closed loop, so a later success email for that job fails at Move Loop to Stage and appears in History. If you want success emails to restart watching instead, delete the loop rather than closing it; the next success email opens a new one.

Make It Your Own​

  • Keep reminding. Give Missing a wake schedule of every 1 day and add an email or a ticket note in its When woken list.
  • Close the ticket on recovery. Add a ticket_id field and store the new ticket's ID with Update Loop Data after you create it. In the email rule, {{custom.backup_loop.loop.stage.name}} tells you whether the loop was in Missing when the success email arrived, and {{custom.backup_loop.loop.data.ticket_id}} gives you the ticket to update.
  • Watch weekly jobs. Create a second loop type, or a second stage with a longer wait, such as 8 days.

For how wakes, stages, and fields work in detail, see How Loops Work.