UiPath Documentation
maestro-automate
latest
false
Guía de usuario de Maestro Automate

Procesar correos electrónicos entrantes

Build a workflow that starts when a new email arrives, extracts key fields, and routes the message to the right action based on its content.

Lo que creas​

Un flujo de trabajo que se inicia automáticamente cuando llega un nuevo correo electrónico, extrae campos clave del mensaje y lo enruta a la acción correcta en función de su contenido, por ejemplo, registrar solicitudes de soporte en un sistema de tickets o escalar mensajes urgentes a un canal de Slack.

Antes de comenzar​

Nodos utilizados​

  • Connector trigger with the Email Received event: starts the workflow 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 workflow cleanly if the email is missing a field.

Pasos​

Consejo:

Con una configuración de agente de codificación, puedes omitir los pasos manuales. Pregúntelo:

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 Decision node to send urgent messages to Slack and everything else to my support system.
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 Decision node to send urgent messages to Slack and everything else to my support system.

A continuación, abre el flujo de trabajo en el lienzo, compruébalo con los siguientes pasos y pruébalo. Configurar tu agente de codificación describe la configuración.

1. Create a workflow and change its trigger to Email Received​

  1. Create a project, as Your first workflow describes. The canvas opens with a Manual Trigger on it.
  2. Select the Manual Trigger, then select Connector trigger in the Change trigger list.
  3. Choose your email app, Microsoft Outlook 365 or Gmail, then the Email Received event.
  4. In the Connector section, select the connection to your mailbox.

2. Extraer campos del correo electrónico​

  1. Select the + on the output handle of the trigger.

  2. Search for Script and select it.

  3. 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 workflow uses them:

  1. Select the + on the output handle of the Script node.
  2. Search for Decision and select it.
  3. Set the condition to check that the required fields are present, for example $vars.script1.output.senderEmail != null.
  4. From the False handle, add a Script node that logs the problem.
  5. 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​

  1. Select the + on the True handle of the Decision node from step 3.
  2. Search for Decision and select it.
  3. Set the condition to catch urgent messages, for example $vars.script1.output.emailSubject.toLowerCase().includes("urgent").
  4. Connect the True branch to a high-priority action, for example a Slack notification node.
  5. 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. The Error handling page describes how.

5. Probar y depurar​

  1. 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.
  2. In the execution panel, check the email's fields under Variables > Inputs.
  3. Check in the execution trace that the email took the path you expected.
  4. To test the other path, send yourself an email that matches it, for example one with "urgent" in the subject.
  5. Select Run Debug (▶) again.
  6. Check under Variables > Inputs that the run picked up that email.

Debugging basics describes the execution panel.

Resultado​

The workflow 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 workflow.

Ampliar este flujo de trabajo​

  • 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.
  • Recorrer los archivos adjuntos: si el correo electrónico tiene archivos adjuntos, añade un nodo de bucle para procesar cada uno.
  • Reply to the sender: after routing, add an email connector node to send a confirmation reply to {{ $vars.script1.output.senderEmail }}.

Próximos pasos​

¿Te ha resultado útil esta página?

Conectar

¿Necesita ayuda? Soporte(opens in new window)

¿Quiere aprender? UiPath Academy(opens in new window)

¿Tiene alguna pregunta? Foro de UiPath(opens in new window)

Manténgase actualizado