- Get started
- Build
- Deploy and run
- Examples
- Reference
Process incoming emails
Build an email triage workflow step by step with a connector trigger, Transform, and a Decision, then extend it.
What you build
A workflow 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 connection to your mailbox, such as Microsoft Outlook 365 or Gmail. Create a connection describes how to create one.
Nodes used
- Email integration trigger: starts the workflow when a new email arrives in the connected mailbox.
- Transform: extracts sender, subject, and body from the email payload.
- Decision: routes the email based on content.
- Terminate: ends the workflow cleanly if the payload is malformed.
Steps
With a coding agent set up, you can skip the manual steps. Ask it:
Build a Maestro Automate workflow that starts when a new email arrives in my mailbox connection, extracts the sender, subject, and body, and uses a Switch node to route support requests and urgent messages to different paths.
Build a Maestro Automate workflow that starts when a new email arrives in my mailbox connection, extracts the sender, subject, and body, and uses a Switch node to route support requests and urgent messages to different paths.
Then open the workflow on the canvas, check it against the steps below, and test it. Set up your coding agent describes the setup.
1. Create a new workflow and add an email trigger
- Create a project, as Your first workflow describes. The canvas opens with a Manual Trigger already on it, which stays for testing.
- Select the + in the bottom toolbar, open the Connector category of the Add node panel, and find your email connector (Microsoft 365 or Gmail).
- Select the Email received trigger.
- In the properties panel, select the Connection to use and configure any filters (for example, a specific inbox folder).
2. Extract fields from the email
- Select the + on the output handle of the email trigger, search for Data Transform, and select it.
- Map the fields you need from the trigger's output payload:
trigger.body.from→senderEmailtrigger.body.subject→emailSubjecttrigger.body.body.content→emailBody
The exact field names vary by connector. The trigger's output schema in the properties panel lists them.
3. Route based on content
- Select the + on the output handle of the Data Transform node, search for Decision, and select it.
- Set the condition to evaluate the email content. For example, to catch urgent messages:
$vars.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).
4. Handle malformed payloads
Not every email has the expected fields. Malformed payloads are guarded against before they break the workflow:
- Add a Decision node after the Data Transform and check that required fields are present, for example
$vars.senderEmail != null. - Connect the valid branch to the routing Decision from step 3.
- Connect the invalid branch to a Script node that logs the problem.
- Connect the Script node to a Terminate node.
Any node that has an Error handle can also be connected to the same error path. The Error handling page describes how.
5. Test and debug
To test without waiting for a real email, the Manual Trigger that came with the new project is used:
- Configure the Manual Trigger with a sample input schema that matches the email payload shape.
- Connect it to the Data Transform node, and select Run Debug (▶) in the bottom toolbar of the canvas with sample values.
- Verify the routing logic in the execution trace.
- Delete the Manual Trigger before deploying.
Result
The workflow starts when a new email arrives, extracts the sender, subject, and body, and routes the message to the right action. Malformed payloads end on the error path and do not break the workflow.
Extend this workflow
- Invoke an AI agent: before the Decision node, add an Autonomous Agent node to classify the email with AI rather than a keyword match.
- 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 integration action node to send a confirmation reply to
{{ $vars.senderEmail }}.
Next steps
- Deploy a workflow: make the workflow run without you.
- Guides: more workflows to build.
- Community: share what you built, or ask other builders for help.