- Introduction
- Getting started
- Build on any canvas
- Build with Case
- Reference
- Defining case keys (system vs. external)
- Establishing task I/O and write-back contracts
- Modeling primary and secondary stages
- Triggering a case from Data Fabric
- Implementing stage-level personas and permissions
- Setting SLAs and automated escalation rules
- Configuring a rework loop (re-entry)
- Configuring and testing the Case Manager Agent (preview)
- Build with Flow
- Build with BPMN
- Operating
- Monitoring
- Optimizing
- Reference information
Process incoming emails
Build a Maestro Orchestrate flow that starts when a new email arrives, extracts key fields, and routes the message to the right action based on its content.
What you build
A flow that starts automatically when a new email arrives, extracts key fields from the message, and routes it to the right action based on its content, for example logging support requests to a ticketing system or escalating urgent messages to a Slack channel.
Before you start
- A UiPath Automation Cloud account with access to Maestro Orchestrate.
- An Integration Service connection to your mailbox, such as Microsoft Outlook 365 or Gmail. Create a connection describes how to create one.
Nodes used
- Connector trigger with the Email Received event: starts the flow when a new email arrives in the connected mailbox.
- Script: extracts the sender, subject, and body from the email.
- Decision, twice: checks that the email has the fields you need, then routes it based on content.
- Terminate: ends the flow cleanly if the email is missing a field.
Steps
1. Create a flow and change its trigger to Email Received
- Open Maestro Orchestrate → Flow and create a new flow. The canvas opens with a Manual Trigger on it.
- Select the Manual Trigger, then select Connector trigger in the Change trigger list.
- Choose your email app, Microsoft Outlook 365 or Gmail, then the Email Received event.
- In the Connector section, select the connection to your mailbox.
2. Extract fields from the email
-
Select the + on the output handle of the trigger.
-
Search for Script and select it.
-
In Code, return the fields you need from the trigger's output:
const email = $vars.<trigger ID>.output; return { senderEmail: email.sender.<address field>, emailSubject: email.subject, emailBody: email.body.<text field> };const email = $vars.<trigger ID>.output; return { senderEmail: email.sender.<address field>, emailSubject: email.subject, emailBody: email.body.<text field> };
In Outlook, sender and body are objects: expand them under { } Insert in the Script node to find the address and the text. The exact field names vary by connector.
3. Check that the email has the fields you need
Not every email has the expected fields. Check them before the flow uses them:
- Select the + on the output handle of the Script node.
- Search for Decision and select it.
- Set the condition to check that the required fields are present, for example
$vars.script1.output.senderEmail != null. - From the False handle, add a Script node that logs the problem.
- From the output handle of that Script node, add a Terminate node.
The True branch carries the valid emails. The next step routes them.
4. Route urgent messages
- Select the + on the True handle of the Decision node from step 3.
- Search for Decision and select it.
- Set the condition to catch urgent messages, for example
$vars.script1.output.emailSubject.toLowerCase().includes("urgent"). - Connect the True branch to a high-priority action, for example a Slack notification node.
- Connect the False branch to a standard action, for example creating a ticket in your support system.
Any node that has an Error handle can also be connected to the error path from step 3. Error handling describes how.
5. Test and debug
- Select Run Debug (▶) in the bottom toolbar of the canvas. The debug run uses an email that's already in the connected mailbox, so you don't need to send one.
- In the execution panel, check the email's fields under Variables > Inputs.
- Check in the execution trace that the email took the path you expected.
- To test the other path, send yourself an email that matches it, for example one with "urgent" in the subject.
- Select Run Debug (▶) again.
- Check under Variables > Inputs that the run picked up that email.
Debugging basics describes the execution panel.
Result
The flow starts when a new email arrives, extracts the sender, subject, and body, and routes the message to the right action. Emails with missing fields end on the error path and do not break the flow.
Extend this flow
- Invoke an AI agent: before the routing Decision, add an Autonomous Agent node to classify the email with AI rather than a keyword match.
- Route to more than two paths: replace the routing Decision with a Switch node, for example to send urgent messages, support requests, and everything else to different actions.
- Loop over attachments: if the email has attachments, add a Loop node to process each one.
- Reply to the sender: after routing, add an email connector node to send a confirmation reply to
{{ $vars.script1.output.senderEmail }}.
Next steps
- Deploying a Flow: make the flow run without you.
- Build guides: more flows to build.