Turn UniFi Offline and Reconnected Emails into One Autotask Ticket
UniFi sends one email when a device goes offline and a separate email when it reconnects. Autotask cannot tell that the two messages belong together. The sender also may not identify the customer, so each email can become a separate ticket on the wrong account.
This tutorial builds an automation that connects the two messages:
- A
Device Offlineemail creates a ticket. - A
Device Reconnectedemail finds that ticket by device name, adds the recovery email as a note, and closes the ticket. - An optional account lookup puts the ticket on the customer associated with the sender's email address.
Email Processing gives you building blocks such as extract, look up, create, update, and branch. This tutorial arranges them for UniFi's offline and reconnected emails. You can change the account lookup, ticket fields, fallback, or closing behavior to fit your process.
Decide What Should Happen
UniFi naturally fits an auto-close design because it sends a clear recovery message:
| Approach | How it behaves |
|---|---|
| Create on offline and close on reconnect (this tutorial) | Device Offline creates a ticket. Device Reconnected adds a note and closes that ticket. |
| Keep one ticket open until a tech closes it | The first alert creates a ticket. Later alerts become notes while the ticket remains open. See Monitoring Alerts to the Right Autotask Account and Ticket. |
| Create a separate ticket for every email | Every offline and reconnected message creates its own ticket. |
All three designs work. Choose the one that matches how your team responds to UniFi alerts.
Before You Start
Create a Hosted Mailbox for UniFi
- Open Email2AT, then click Hosted Mailboxes.
- Create a Hosted Mailbox, for example
[email protected]. - Configure UniFi to send alerts to that address.
We recommend a dedicated address for each monitoring tool because it keeps its rules and History separate. There is no technical requirement to do this. You can use a shared support mailbox if you add conditions that identify UniFi messages reliably.
Send examples before you build
Send one offline alert and one reconnected alert to the Hosted Mailbox before adding rules. Both emails appear in History, but nothing processes them yet.
Open each email in History and inspect the plain text body. Confirm that your messages contain:
- The subject
Device OfflineorDevice Reconnected - A line such as
Device Name: ACME-AP-01
UniFi versions may format alerts differently. Building from the text in History shows you exactly what the automation receives.
Part 1: Create the Offline Ticket and Close It on Reconnection
Start with the smallest useful version. It extracts the device name, creates an offline ticket on your zero account, then finds and closes that ticket when UniFi reports the reconnection.
The video builds the same result with two rules, one for each subject, and uses Stop actions to keep later rules from processing the email. The written steps below use one rule with a Match action, which works like an if/then/else and keeps the decision in one place. The written layout is the current recommendation.
Create one rule for both UniFi subjects
- In the Hosted Mailbox, click Add New Rule.
- Name it
Process UniFi Offline and Reconnected Alerts. - Set the rule condition to an Any of these (OR) group:
email.subjectequalsDevice Offlineemail.subjectequalsDevice Reconnected
The exact subject conditions keep unrelated messages out of this rule.
Step 1: Extract the device name
- Click Add Action, select Extract Strings, then click OK.
- Name the step
Extract Device Name. - Add this definition:
| Variable | Extraction Type | Text | If Empty |
|---|---|---|---|
device_name | Text Expression | {{after_string email.body "Device Name: " flags="tn"}} | Continue processing |
- In Store results in variable, enter
extracted.
The after_string helper takes the text after Device Name: . The n flag stops at the next line, and the t flag trims surrounding spaces. For an alert that contains Device Name: ACME-AP-01, the result appears as {{custom.extracted.device_name}}.
The remaining steps check that this value exists before they run. If UniFi changes its email format, the rule skips ticket changes and lets a later catch-all rule handle the email.
Step 2: Look for the open offline ticket
- Click Add Action, select API: Query for One Object, then click OK.
- Name the step
Find Open Offline Ticket. - Set Entity Type to
Ticket. - Set Only perform this action if to both conditions:
custom.extracted.device_nameis not emptyemail.subjectequalsDevice Reconnected
- Add these query conditions:
Statusdoes not equalCompleteDescriptioncontains[UniFi Device: {{custom.extracted.device_name}}]
- Leave Generate an exception if no results unchecked. A reconnected email can arrive when no matching open ticket exists.
- Enable Generate an exception if more than one result so the automation does not guess between duplicate open tickets.
- In Store results in variable, enter
ticket.
This step runs only for a reconnected alert. The offline path does not need to look for a ticket.
Step 3: Choose whether to close or create
The Match action checks branches from top to bottom and runs the first true branch. If no branch matches, it runs Default.
- Click Add Action, select Match, then click OK.
- Name the step
Close or Create Ticket. - Add the following branches in this order.
Branch 1: Close the matching ticket
Set the branch condition to both:
email.subjectequalsDevice Reconnectedcustom.ticket.idis not empty
Add these two actions inside the branch in this order.
Add a reconnection note
- Add API: Create an Object and name it
Add Reconnection Note. - Set Entity Type to
TicketNote. - Configure these fields:
| Field | Value |
|---|---|
| TicketID | {{custom.ticket.id}} (unlock the field to enter this) |
| Title | {{email.subject}} |
| Description | {{email.body}} |
| NoteType | Task Summary, or your preferred note type |
| Publish | All Autotask Users or Internal Only |
Close the ticket
- Add API: Update an Object and name it
Close Ticket. - Set Entity Type to
Ticket. - Configure these fields:
| Field | Value |
|---|---|
| ID | {{custom.ticket.id}} (unlock the field to enter this) |
| Status | Complete |
Autotask requires separate actions for the note and status change. Unlocking TicketID and ID changes each picklist into a field where you can enter the ticket ID found in Step 2. Type { to choose that variable from the available data.
Branch 2: Ignore an unmatched reconnection
Add a branch with this condition and leave its action list empty:
email.subjectequalsDevice Reconnected
An empty matching branch counts as the selected branch. It prevents a reconnected email with no open ticket from reaching Default and creating a new ticket. Because no ticket changed, a later catch-all rule can still handle this email.
Default: Create the offline ticket
Add API: Create an Object to the Default branch:
- Name the action
Create Offline Ticket. - Set Entity Type to
Ticket. - Set Only perform this action if to
custom.extracted.device_nameis not empty. - Configure the ticket fields:
| Field | Value |
|---|---|
| AccountID | Your zero account (unlock the field and enter 0) |
| Status | New |
| Priority | Choose the priority that fits these alerts |
| QueueID | Your monitoring alerts queue |
| Title | {{email.subject}} |
| Description | See below |
End the description with a device marker:
{{email.body}}
[UniFi Device: {{custom.extracted.device_name}}]
The marker gives both emails a shared value. For example, the offline ticket contains [UniFi Device: ACME-AP-01], and the reconnected email searches for that exact marker. Including the brackets keeps a shorter name from matching part of a longer one.
Step 4: Stop after a successful result
- Add Stop processing this message completely after Match.
- Name it
Stop After Successful Processing. - Set Only perform this action if to either condition group:
email.subjectequalsDevice OfflineANDcustom.extracted.device_nameis not emptyemail.subjectequalsDevice ReconnectedANDcustom.ticket.idis not empty
The Stop action runs only after the automation creates or closes a ticket. If the device name is missing or a reconnected email has no open ticket, the message continues to a later catch-all rule instead.
What you have so far
For an offline and recovery pair from ACME-AP-01:
- The offline email provides the device name.
- Match reaches Default and creates a ticket with
[UniFi Device: ACME-AP-01]in its description. - The reconnected email provides the same device name.
- The ticket query finds the open ticket with that marker.
- Match runs Branch 1, which adds the recovery email as a note and changes the ticket status to
Complete.
At this point, the two UniFi emails produce one ticket. Part 2 changes only where the offline ticket gets created.
Part 2: Put the Ticket on the Correct Account
Part 1 uses your zero account. If each customer's UniFi controller sends from a customer-specific address such as [email protected], you can match that address to an Autotask Contact and use the Contact's account for the ticket.
The video clones the ticket action, then guards one copy with "contact found" and the other with "contact not found." The written steps use a nested Match action for the same choice. The written layout is the current recommendation. The video also shows the zero account fallback; you can choose an exception instead.
Decide what no match should do
Choose your fallback before adding the lookup:
| Choice | Result |
|---|---|
| Stop and notify | Enable Generate an exception if no results on the Contact query. No ticket gets created until you add or correct the Contact and replay the email from History. |
| Use the zero account | Leave that option unchecked. The nested Match action creates unmatched tickets on account 0, where a tech can move them. |
Neither choice fits every MSP. An exception avoids putting a ticket on the wrong account, but someone must fix and replay the alert. The zero account keeps every alert visible, but a tech may need to move the ticket. See The Autotask Zero Account for details.
Step 1: Find the Contact by sender address
Add this action between Extract Device Name and Find Open Offline Ticket:
- Add API: Query for One Object and name it
Find Contact by Sender Address. - Set Entity Type to
Contact. - Set Only perform this action if to both:
custom.extracted.device_nameis not emptyemail.subjectequalsDevice Offline
- Add
Activeequals1to an All of these (AND) group. - Inside that group, add an Any of these (OR) group:
EmailAddressequals{{email.from.address}}EmailAddress2equals{{email.from.address}}EmailAddress3equals{{email.from.address}}
- Enable Generate an exception if more than one result so the automation does not choose between duplicate Contacts.
- Set Generate an exception if no results according to the fallback you chose above.
- In Store results in variable, enter
contact.
After this step, {{custom.contact.accountId}} identifies the Contact's account. You may also use {{custom.contact.id}} to associate the Contact with the ticket, but a monitoring system address often does not represent a person, so leaving ContactID off the ticket can make more sense.
Step 2: Choose the account in the Default branch
In the Close or Create Ticket Match action, replace the Create Offline Ticket action in Default with another Match action named Choose Ticket Account.
Contact found branch
- Add a branch where
custom.contact.idis not empty. - Add API: Create an Object with Entity Type
Ticket. - Name it
Create Ticket on Contact Account. - Keep the same status, priority, queue, title, description, device marker, and device-name guard from Part 1.
- Unlock AccountID and enter
{{custom.contact.accountId}}. - Optional: add ContactID, unlock it, and enter
{{custom.contact.id}}.
Default branch for no Contact
If you chose the zero account fallback:
- Add API: Create an Object to the nested Default branch.
- Name it
Create Ticket on Zero Account. - Keep the same fields and conditions from Part 1.
- Unlock AccountID and enter
0. - Leave ContactID off the ticket.
If you chose Stop and notify, leave the nested Default branch empty. The Contact lookup stops with an exception before the automation reaches it.
Other ways to identify the customer
The sender-to-Contact lookup works well when every controller uses a unique email address that already belongs to an Autotask Contact. You can also create an Account UDF such as UniFi Alert Address, enter each controller's sender address on its customer account, and query that UDF instead.
A UDF gives you a value that you control specifically for this integration. It also avoids creating a Contact for an automated system. For approaches based on a customer name, an Account UDF, or both, plus the choices when no account matches, see Identify the Customer.
Optional: include the account when finding the open ticket
The device marker usually identifies the open ticket. If customers reuse names such as AP-01, also identify the account before querying for a ticket on reconnected emails, then add this ticket query condition:
AccountIDequals the account ID found for the sender
This makes the customer plus device marker the shared identifier. Apply the sender lookup to both subjects when you use this option, not only to Device Offline.
What happens now
- Known sender goes offline: the Contact lookup finds
[email protected], and the Default path creates the ticket on that Contact's account. - Known device reconnects: the automation finds the open ticket by its device marker, adds a note, and closes it.
- Unknown sender goes offline: the automation either stops with an exception or creates the ticket on the zero account, according to your choice.
- Unexpected email format: the guarded actions skip ticket changes, so a later catch-all rule can handle the email.
Test the Automation
- Replay the offline email from History. Confirm that the extraction produced the device name and the ticket description ends with the exact
[UniFi Device: ...]marker. - If you completed Part 2, confirm that the ticket uses the expected customer account or your chosen fallback.
- Replay the reconnected email. Confirm that the automation found the same ticket, added a note, and changed its status to
Complete. - Replay the reconnected email again. Confirm that it did not create a new ticket because no open matching ticket remains.
- Test an email without
Device Name:. Confirm that the guarded actions skip and your catch-all rule handles it.
After you change a rule, click the Play button on a History entry to process the same email again. You do not need to send a new test message after every change.
Key Takeaways
- Decide the ticket lifecycle first: this tutorial creates on offline and closes on reconnection, while the general monitoring tutorial shows the alternative where notes continue until a tech closes the ticket.
- Use one predictable device marker: put
[UniFi Device: name]in the ticket description and search for the same complete marker. - Guard dependent actions: only query when the device exists, and only add a note or close when the ticket exists.
- Treat account fallback as a design choice: stop with an exception when accuracy matters most, or use the zero account when every alert must create a visible ticket.
- Use sender-to-Contact matching when it fits your data: an Account UDF provides another reliable option that does not require an automated Contact.
Related Documentation
- Monitoring Alerts to the Right Autotask Account and Ticket: build the notes-until-closed pattern and compare customer matching options
- The Autotask Zero Account: understand account
0and when to use it - Extract Strings: extract values with text expressions or regular expressions
- Match: run one branch of actions based on conditions
- API: Query for One Object: query Autotask for a single result
- API: Create an Object: create tickets and ticket notes
- API: Update an Object: update the ticket status