# Outlook - Multi-Mailbox Trigger

> Se dispara cuando llega un correo nuevo a CUALQUIERA de varios buzones de Microsoft Outlook.

Source: https://docs.sommatic.ai/es/nodes/connectors.microsoft.outlook.trigger.multi/

- Slug: `connectors.microsoft.outlook.trigger.multi`
- Familia: Conectores
- Versión: 1.0.0
- Estado: Parcial. El planificador no arranca este trigger: solo corre si lo inicias a mano, y se dispara una vez por ejecución, no una vez por correo y buzón.
- Ejecución: async

Se dispara cuando llega un correo nuevo a CUALQUIERA de varios buzones de Microsoft Outlook.

Escucha de buzones múltiples de nivel empresarial. Un solo nodo trigger vigila en paralelo una lista de buzones y dispara **una ejecución del workflow por cada correo nuevo**, con el buzón de origen identificado en el payload. Ideal para arquitecturas de buzones compartidos (PQRS, soporte, recepción jurídica, RR. HH.) en las que varios buzones funcionales deben alimentar el mismo workflow de triaje.

**Cómo funciona:**
- En cada ciclo de consulta, el trigger revisa TODOS los buzones configurados en paralelo (una llamada a Graph API por buzón).
- Cada correo nuevo encontrado se emite como un disparo independiente: si 3 buzones reciben 1 correo nuevo cada uno en el mismo ciclo, el workflow se ejecuta 3 veces.
- El buzón de origen se expone como `mailbox_email` en el payload de salida para que los nodos posteriores puedan enrutar o etiquetar en consecuencia.
- El estado `lastTimeChecked` se lleva **por buzón** de forma independiente (así, un buzón lento no bloquea a los demás).
- Si un correo tiene muchos adjuntos, se usa el puerto `heavy_attachments` en lugar de `out` para un procesamiento posterior dedicado.

**Cuándo preferirlo frente al trigger de un solo buzón:**
- Tienes 2 o más buzones compartidos que deben ejecutar el mismo workflow.
- Quieres evitar mantener N workflows en paralelo (uno por buzón) que hacen lo mismo.
- Necesitas un seguimiento de estado coherente en un grupo de buzones.

**Cuándo NO preferirlo:**
- Tienes más de 10.000 correos al mes y necesitas una latencia inferior a un segundo: usa webhooks de Graph + una cola (p. ej., Service Bus).
- Cada buzón tiene una lógica posterior sustancialmente distinta: usa workflows separados.

## Configuración

- `connection_id` (string, obligatorio): Credencial de acceso a Microsoft Graph API. El registro de la aplicación debe tener el permiso Mail.Read (de aplicación) en todos los buzones monitoreados. Acepta credenciales de tipo `oauth2` (token de acceso + token de actualización), `service-account` (tenant id + client id + client secret) u `object` (configuración avanzada de Graph).
- `mailbox_emails` (array<string>, obligatorio): Lista de direcciones de los buzones que se monitorean. La credencial configurada debe tener acceso a cada dirección.
- `folder` (string, opcional): La carpeta de correo que se vigila en busca de mensajes nuevos (la misma carpeta aplica a todos los buzones). Por defecto: `inbox`. Valores permitidos: `inbox`, `sentitems`, `drafts`, `deleteditems`, `junkemail`, `archive`.
- `polling_interval` (number, opcional): Con qué frecuencia se buscan correos nuevos. Mínimo 60 segundos. En cada ciclo, los buzones se revisan en paralelo. Por defecto: `60`.
- `attachment_threshold` (number, opcional): Número de adjuntos a partir del cual el correo se dirige al puerto heavy_attachments en lugar de out. Por defecto: `5`.
- `max_emails_per_cycle` (number, opcional): Valor $top de Graph API. Límite de correos nuevos por buzón que se obtienen en un ciclo de consulta (el resto espera al siguiente ciclo). Por defecto: `50`.

Su configuración muestra los ajustes de ejecución compartidos, pero este nodo aún no aplica reintentos (`retryOnFail`, `maxTries`). Ningún nodo aplica `continueOnFail`.

## Puertos de salida

- `out` (por defecto): Se recibió un correo nuevo (por debajo del umbral de adjuntos). Se dispara una vez por correo y por buzón.
- `heavy_attachments`: El correo tiene un número de adjuntos igual o superior al umbral. Enrútalo a un nodo dedicado al procesamiento de adjuntos.
- `empty`: No se encontraron correos nuevos en ningún buzón monitoreado en este ciclo de consulta.
- `error`: No se pudieron obtener los correos o hubo un error de autenticación.

## Contrato de salida

- `id` (string, opcional): El ID de mensaje de Graph. Úsalo para las operaciones de responder, reenviar o eliminar.
- `mailbox_email` (string, opcional): El buzón en el que se recibió este correo. Úsalo para enrutar por buzón en los nodos posteriores.
- `subject` (string, opcional)
- `from` (string, opcional): Dirección de correo del remitente.
- `to` (array, opcional): Direcciones de correo de los destinatarios.
- `cc` (array, opcional)
- `receivedDateTime` (string, opcional)
- `body` (string, opcional): Contenido del cuerpo del correo.
- `bodyContentType` (string, opcional)
- `bodyPreview` (string, opcional)
- `isRead` (boolean, opcional)
- `hasAttachments` (boolean, opcional)
- `attachmentCount` (number, opcional)
- `importance` (string, opcional)
- `conversationId` (string, opcional)
- `internetMessageId` (string, opcional)

## En expresiones

Lo que un nodo posterior puede leer de la salida de este nodo con `$("Outlook - Multi-Mailbox Trigger").item.json.<ruta>` (escribe la etiqueta de tu nodo en lugar de `Outlook - Multi-Mailbox Trigger`). **Editor** marca las rutas que sugiere el editor de workflows en Previous Nodes (el contrato de salida); **Worker** marca las rutas que el worker devuelve de verdad por `out`, según la salida que muestra Puertos.

- `$("Outlook - Multi-Mailbox Trigger").item.json.id` (string) = `"AAMkAGI2TG93AAA="`: El ID de mensaje de Graph. Úsalo para las operaciones de responder, reenviar o eliminar.
- `$("Outlook - Multi-Mailbox Trigger").item.json.mailbox_email` (string) = `"billing@example.com"`: El buzón en el que se recibió este correo. Úsalo para enrutar por buzón en los nodos posteriores.
- `$("Outlook - Multi-Mailbox Trigger").item.json.subject` (string) = `"Invoice request"`
- `$("Outlook - Multi-Mailbox Trigger").item.json.from` (string) = `"ana@example.com"`: Dirección de correo del remitente.
- `$("Outlook - Multi-Mailbox Trigger").item.json.to` (array) = `[…] (1)`: Direcciones de correo de los destinatarios.
- `$("Outlook - Multi-Mailbox Trigger").item.json.cc` (array) = `[…] (0)`
- `$("Outlook - Multi-Mailbox Trigger").item.json.receivedDateTime` (string) = `"2026-11-26T14:02:51Z"`
- `$("Outlook - Multi-Mailbox Trigger").item.json.body` (string) = `"<html><body><p>Please send the invoice.</p><…"`: Contenido del cuerpo del correo.
- `$("Outlook - Multi-Mailbox Trigger").item.json.bodyContentType` (string) = `"html"`
- `$("Outlook - Multi-Mailbox Trigger").item.json.bodyPreview` (string) = `"Please send the invoice."`
- `$("Outlook - Multi-Mailbox Trigger").item.json.isRead` (boolean) = `false`
- `$("Outlook - Multi-Mailbox Trigger").item.json.hasAttachments` (boolean) = `false`
- `$("Outlook - Multi-Mailbox Trigger").item.json.attachmentCount` (number) **El worker no la devuelve: se lee como undefined.**
- `$("Outlook - Multi-Mailbox Trigger").item.json.importance` (string) = `"normal"`
- `$("Outlook - Multi-Mailbox Trigger").item.json.conversationId` (string) = `"AAQkAGI2TG93CCC="`
- `$("Outlook - Multi-Mailbox Trigger").item.json.internetMessageId` (string) = `"<CAF1x2y3z@mail.example.com>"`
- `$("Outlook - Multi-Mailbox Trigger").item.json.messages` (array) = `[…] (1)` (El editor no la sugiere)
- `$("Outlook - Multi-Mailbox Trigger").item.json.count` (number) = `1` (El editor no la sugiere)
- `$("Outlook - Multi-Mailbox Trigger").item.json.hasNewEmails` (boolean) = `true` (El editor no la sugiere)
- `$("Outlook - Multi-Mailbox Trigger").item.json.lastTimeChecked` (string) = `"2026-11-26T14:03:00.120Z"` (El editor no la sugiere)


## Cómo funciona

Inicia un workflow con los mensajes nuevos de varios buzones de Outlook, revisados en paralelo, guardando una hora de última revisión por buzón. Cada ejecución emite una salida con todos los mensajes nuevos en `messages` y el primero copiado a la raíz.

1. Qué lo inicia: una ejecución manual del workflow. En esta versión el programador del backend no inicia este nodo (solo programa `cron.trigger` y `connectors.microsoft.outlook.trigger`); la rama programada solo se ejecuta cuando la entrada trae `$scheduled: true`.
2. Resuelve la configuración del nodo, exige `connection_id` y al menos una dirección en `mailbox_emails` (arreglo o texto separado por comas) y obtiene un token de Graph.
3. Para cada buzón consulta en `folder` los mensajes recibidos desde su `$trigger_state.perMailbox[<buzón>].lastTimeChecked` (o desde ahora si no existe), del más antiguo al más reciente, como máximo `max_emails_per_cycle` (por defecto 50), y marca cada mensaje con `mailbox_email`.
4. Rama programada: una sola pasada; un buzón cuya consulta falla se omite y conserva su hora de última revisión. Ejecución manual: repite la pasada cada `polling_interval` segundos, renovando el token, hasta que algún buzón tenga correo o pasen 30 minutos; un buzón que falla hace fallar la ejecución.
5. Cuenta los adjuntos (hasta 100) de los mensajes que los tienen, copia los campos del primer mensaje a la raíz y elige `empty` (sin correo), `heavy_attachments` (el primer mensaje tiene `attachment_threshold` adjuntos o más) u `out`. Devuelve `meta.trigger_state.perMailbox`, que el backend guarda al terminar la ejecución.

## En un workflow

### Nodo

```json
{
  "node_id": "node-shared-inboxes",
  "label": "Shared inboxes",
  "operator_slug": "connectors.microsoft.outlook.trigger.multi",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "mailbox_emails": [
      "billing@example.com",
      "support@example.com"
    ],
    "folder": "inbox",
    "polling_interval": 60,
    "attachment_threshold": 5,
    "max_emails_per_cycle": 50
  }
}
```

### Envelope

```json
{
  "ok": true,
  "data": {
    "messages": [
      {
        "id": "AAMkAGI2TG93AAA=",
        "subject": "Invoice request",
        "from": "ana@example.com",
        "to": [
          "billing@example.com"
        ],
        "cc": [],
        "receivedDateTime": "2026-11-26T14:02:51Z",
        "body": "<html><body><p>Please send the invoice.</p></body></html>",
        "bodyContentType": "html",
        "bodyPreview": "Please send the invoice.",
        "isRead": false,
        "hasAttachments": false,
        "importance": "normal",
        "conversationId": "AAQkAGI2TG93CCC=",
        "internetMessageId": "<CAF1x2y3z@mail.example.com>",
        "mailbox_email": "billing@example.com"
      }
    ],
    "count": 1,
    "hasNewEmails": true,
    "lastTimeChecked": "2026-11-26T14:03:00.120Z",
    "id": "AAMkAGI2TG93AAA=",
    "subject": "Invoice request",
    "from": "ana@example.com",
    "to": [
      "billing@example.com"
    ],
    "cc": [],
    "receivedDateTime": "2026-11-26T14:02:51Z",
    "body": "<html><body><p>Please send the invoice.</p></body></html>",
    "bodyContentType": "html",
    "bodyPreview": "Please send the invoice.",
    "isRead": false,
    "hasAttachments": false,
    "importance": "normal",
    "conversationId": "AAQkAGI2TG93CCC=",
    "internetMessageId": "<CAF1x2y3z@mail.example.com>",
    "mailbox_email": "billing@example.com"
  },
  "port": "out",
  "meta": {
    "trigger_state": {
      "perMailbox": {
        "billing@example.com": {
          "lastTimeChecked": "2026-11-26T14:03:00.120Z"
        },
        "support@example.com": {
          "lastTimeChecked": "2026-11-26T14:03:00.120Z"
        }
      }
    }
  }
}
```

## Puertos de salida (comportamiento en el código)

### `out`

Al menos un buzón tenía correo nuevo y el primer mensaje está por debajo del umbral de adjuntos.

```json
{
  "messages": [
    {
      "id": "AAMkAGI2TG93AAA=",
      "subject": "Invoice request",
      "from": "ana@example.com",
      "to": [
        "billing@example.com"
      ],
      "cc": [],
      "receivedDateTime": "2026-11-26T14:02:51Z",
      "body": "<html><body><p>Please send the invoice.</p></body></html>",
      "bodyContentType": "html",
      "bodyPreview": "Please send the invoice.",
      "isRead": false,
      "hasAttachments": false,
      "importance": "normal",
      "conversationId": "AAQkAGI2TG93CCC=",
      "internetMessageId": "<CAF1x2y3z@mail.example.com>",
      "mailbox_email": "billing@example.com"
    }
  ],
  "count": 1,
  "hasNewEmails": true,
  "lastTimeChecked": "2026-11-26T14:03:00.120Z",
  "id": "AAMkAGI2TG93AAA=",
  "subject": "Invoice request",
  "from": "ana@example.com",
  "to": [
    "billing@example.com"
  ],
  "cc": [],
  "receivedDateTime": "2026-11-26T14:02:51Z",
  "body": "<html><body><p>Please send the invoice.</p></body></html>",
  "bodyContentType": "html",
  "bodyPreview": "Please send the invoice.",
  "isRead": false,
  "hasAttachments": false,
  "importance": "normal",
  "conversationId": "AAQkAGI2TG93CCC=",
  "internetMessageId": "<CAF1x2y3z@mail.example.com>",
  "mailbox_email": "billing@example.com"
}
```

### `heavy_attachments`

El primer mensaje tiene `attachment_threshold` adjuntos o más. Misma forma que `out`, con `attachmentCount` en el mensaje.

```json
{
  "messages": [
    {
      "id": "AAMkAGI2TG94AAA=",
      "subject": "Scanned documents",
      "from": "ana@example.com",
      "to": [
        "support@example.com"
      ],
      "cc": [],
      "receivedDateTime": "2026-11-26T14:03:40Z",
      "body": "<html><body><p>Attached.</p></body></html>",
      "bodyContentType": "html",
      "bodyPreview": "Attached.",
      "isRead": false,
      "hasAttachments": true,
      "importance": "normal",
      "conversationId": "AAQkAGI2TG94CCC=",
      "internetMessageId": "<CAF4u5v6w@mail.example.com>",
      "mailbox_email": "support@example.com",
      "attachmentCount": 7
    }
  ],
  "count": 1,
  "hasNewEmails": true,
  "lastTimeChecked": "2026-11-26T14:04:00.087Z",
  "id": "AAMkAGI2TG94AAA=",
  "subject": "Scanned documents",
  "from": "ana@example.com",
  "to": [
    "support@example.com"
  ],
  "cc": [],
  "receivedDateTime": "2026-11-26T14:03:40Z",
  "body": "<html><body><p>Attached.</p></body></html>",
  "bodyContentType": "html",
  "bodyPreview": "Attached.",
  "isRead": false,
  "hasAttachments": true,
  "importance": "normal",
  "conversationId": "AAQkAGI2TG94CCC=",
  "internetMessageId": "<CAF4u5v6w@mail.example.com>",
  "mailbox_email": "support@example.com",
  "attachmentCount": 7
}
```

### `empty`

Ningún buzón tenía correo nuevo (rama programada), o una ejecución manual esperó 30 minutos sin correo (entonces con `timedOut: true` y `polledForMs`).

```json
{
  "messages": [],
  "count": 0,
  "hasNewEmails": false,
  "lastTimeChecked": "2026-11-26T14:33:00.502Z",
  "timedOut": true,
  "polledForMs": 1800381
}
```

### `error`

Falló una validación (la salida es el sobre `{ ok, errors, port }`) o, en una ejecución manual, falló la consulta de un buzón (la salida es `{ error }`).

```json
{
  "ok": false,
  "errors": [
    "At least one mailbox email is required"
  ],
  "port": "error"
}
```

## Comportamiento en el código

- `mailbox_emails`: Acepta un arreglo o un texto separado por comas. La credencial debe poder leer cada buzón con el permiso de aplicación `Mail.Read`.
- `attachment_threshold`: Se evalúa solo sobre el primer mensaje, aunque lleguen varios.
- `polling_interval`: Espera entre pasadas en una ejecución manual. El mínimo de 60 segundos no se valida y el programador del backend no lo usa para este nodo.

## Errores

| Mensaje | Puerto | Causa y solución |
| --- | --- | --- |
| `Microsoft 365 credential is required` | `error` | `connection_id` está vacío. |
| `At least one mailbox email is required` | `error` | `mailbox_emails` está vacío o no contiene ningún texto válido. |
| `Failed to resolve Microsoft 365 access token` | `error` | No se pudo resolver la credencial o falló la solicitud del token. |
| `Poll failed: <message>` | `error` | Ejecución manual: falló la consulta de uno de los buzones (por ejemplo 403 sin `Mail.Read` sobre ese buzón). |

## Notas y límites

- La definición dice que se dispara una vez por correo y por buzón; el código se dispara una vez por ejecución. Todos los mensajes encontrados están en `messages`, solo el primero se copia a la raíz y las horas de última revisión avanzan para todos, así que recorre `messages` (por ejemplo con `flow.split`) en lugar de depender de los campos de la raíz.
- A diferencia del disparador de un solo buzón, una ejecución manual parte de las horas de última revisión guardadas por buzón cuando existen, así que también devuelve el correo recibido desde la ejecución anterior.
- Con datos de muestra el motor omite este nodo y entrega la entrada de muestra por `out`. Una ejecución manual se bloquea hasta 30 minutos.


## Contratos (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "connectors.microsoft.outlook.trigger.multi",
  "name": "Outlook - Multi-Mailbox Trigger",
  "category": "integrations",
  "version": "1.0.0",
  "description": "Triggers when a new email arrives in ANY of multiple Microsoft Outlook mailboxes.\n\n  Enterprise-grade multi-tenant mailbox listener. A single trigger node watches a list of mailboxes in parallel and fires **one workflow execution per new email**, with the originating mailbox identified in the payload. Ideal for shared inbox architectures (PQRS, support, legal intake, HR) where several functional mailboxes must feed the same triage workflow.\n\n  **How it works:**\n  - On each polling cycle, the trigger checks ALL configured mailboxes in parallel (one Graph API call per mailbox).\n  - Every new email found is emitted as an independent trigger fire — if 3 mailboxes each receive 1 new email in the same cycle, the workflow executes 3 times.\n  - The originating mailbox is exposed as `mailbox_email` in the output payload so downstream nodes can route or tag accordingly.\n  - `lastTimeChecked` state is tracked **per mailbox** independently (so a slow-polling mailbox does not block others).\n  - If an email has many attachments, the `heavy_attachments` port is used instead of `out` for dedicated downstream processing.\n\n  **When to prefer this over the single-mailbox trigger:**\n  - You have 2+ shared inboxes that should run the same workflow.\n  - You want to avoid maintaining N parallel workflows (one per mailbox) that all do the same thing.\n  - You need consistent state tracking across a mailbox cluster.\n\n  **When NOT to prefer this:**\n  - You have >10K emails/month and need sub-second latency — use Graph webhooks + a queue (e.g. Service Bus) instead.\n  - Each mailbox has materially different downstream logic — use separate workflows.",
  "capabilities": [
    "email",
    "microsoft",
    "outlook",
    "trigger",
    "multi-mailbox",
    "shared-inbox"
  ],
  "group": [
    {
      "key": "microsoft",
      "name": "Microsoft",
      "icon_url": "/icons/integrations/microsoft/microsoft.svg"
    },
    {
      "key": "microsoft365",
      "name": "Microsoft 365",
      "icon_url": "/icons/integrations/microsoft/microsoft365.svg"
    }
  ],
  "icon_url": "/icons/integrations/microsoft/outlook.svg",
  "config_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string",
        "title": "Microsoft 365 Credential",
        "description": "Credential for Microsoft Graph API access. The app registration must have Mail.Read permission (Application) on all monitored mailboxes. Accepts credentials of type `oauth2` (access + refresh token), `service-account` (tenant id + client id + client secret), or `object` (advanced Graph config).",
        "ui_widget": "connection_picker",
        "ui_options": {
          "credential_types": [
            "oauth2",
            "service-account",
            "object"
          ],
          "types": [
            "outlook",
            "microsoft365",
            "oauth2"
          ]
        }
      },
      "mailbox_emails": {
        "type": "array",
        "title": "Mailbox Emails",
        "description": "List of mailbox email addresses to monitor. Each email address must be accessible by the configured credential.",
        "items": {
          "type": "string",
          "format": "expression"
        }
      },
      "folder": {
        "type": "string",
        "title": "Folder",
        "enum": [
          "inbox",
          "sentitems",
          "drafts",
          "deleteditems",
          "junkemail",
          "archive"
        ],
        "default": "inbox",
        "description": "The mail folder to watch for new messages (same folder applies to all mailboxes)."
      },
      "polling_interval": {
        "type": "number",
        "title": "Polling Interval (seconds)",
        "default": 60,
        "description": "How often to check for new emails. Minimum 60 seconds. Each mailbox is checked in parallel per cycle."
      },
      "attachment_threshold": {
        "type": "number",
        "title": "Heavy Attachments Threshold",
        "default": 5,
        "description": "Number of attachments at or above which the email routes to the heavy_attachments port instead of out."
      },
      "max_emails_per_cycle": {
        "type": "number",
        "title": "Max Emails Per Mailbox Per Cycle",
        "default": 50,
        "description": "Graph API $top value. Cap on how many new emails per mailbox are fetched in a single polling cycle (rest wait for next cycle)."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    },
    "required": [
      "connection_id",
      "mailbox_emails"
    ]
  },
  "input_contract_schema": null,
  "output_contract_schema": {
    "type": "object",
    "description": "The incoming email data, with the originating mailbox surfaced for routing.",
    "properties": {
      "id": {
        "type": "string",
        "description": "The Graph message ID. Use this for reply/forward/delete operations."
      },
      "mailbox_email": {
        "type": "string",
        "description": "The mailbox this email was received in. Use this for per-mailbox routing downstream."
      },
      "subject": {
        "type": "string"
      },
      "from": {
        "type": "string",
        "description": "Sender email address."
      },
      "to": {
        "type": "array",
        "description": "Recipient email addresses."
      },
      "cc": {
        "type": "array"
      },
      "receivedDateTime": {
        "type": "string",
        "format": "date-time"
      },
      "body": {
        "type": "string",
        "description": "Email body content."
      },
      "bodyContentType": {
        "type": "string"
      },
      "bodyPreview": {
        "type": "string"
      },
      "isRead": {
        "type": "boolean"
      },
      "hasAttachments": {
        "type": "boolean"
      },
      "attachmentCount": {
        "type": "number"
      },
      "importance": {
        "type": "string"
      },
      "conversationId": {
        "type": "string"
      },
      "internetMessageId": {
        "type": "string"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "New Email",
      "is_default": true,
      "description": "A new email was received (below attachment threshold). Fires once per email per mailbox."
    },
    {
      "port_id": "heavy_attachments",
      "label": "Heavy Attachments",
      "description": "Email has attachments at or above the threshold. Route to a dedicated attachment processing node."
    },
    {
      "port_id": "empty",
      "label": "No New Emails",
      "description": "No new emails found in any monitored mailbox in this polling cycle."
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Failed to fetch emails or authentication error."
    }
  ],
  "execution_mode": "async",
  "tags": [
    "email",
    "microsoft",
    "outlook",
    "trigger",
    "multi-mailbox",
    "shared-inbox",
    "premium"
  ],
  "is_stateful": true,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "properties": {
    "connection_id": {
      "type": "string",
      "title": "Microsoft 365 Credential",
      "description": "Credential for Microsoft Graph API access. The app registration must have Mail.Read permission (Application) on all monitored mailboxes. Accepts credentials of type `oauth2` (access + refresh token), `service-account` (tenant id + client id + client secret), or `object` (advanced Graph config).",
      "ui_widget": "connection_picker",
      "ui_options": {
        "credential_types": [
          "oauth2",
          "service-account",
          "object"
        ],
        "types": [
          "outlook",
          "microsoft365",
          "oauth2"
        ]
      }
    },
    "mailbox_emails": {
      "type": "array",
      "title": "Mailbox Emails",
      "description": "List of mailbox email addresses to monitor. Each email address must be accessible by the configured credential.",
      "items": {
        "type": "string",
        "format": "expression"
      }
    },
    "folder": {
      "type": "string",
      "title": "Folder",
      "enum": [
        "inbox",
        "sentitems",
        "drafts",
        "deleteditems",
        "junkemail",
        "archive"
      ],
      "default": "inbox",
      "description": "The mail folder to watch for new messages (same folder applies to all mailboxes)."
    },
    "polling_interval": {
      "type": "number",
      "title": "Polling Interval (seconds)",
      "default": 60,
      "description": "How often to check for new emails. Minimum 60 seconds. Each mailbox is checked in parallel per cycle."
    },
    "attachment_threshold": {
      "type": "number",
      "title": "Heavy Attachments Threshold",
      "default": 5,
      "description": "Number of attachments at or above which the email routes to the heavy_attachments port instead of out."
    },
    "max_emails_per_cycle": {
      "type": "number",
      "title": "Max Emails Per Mailbox Per Cycle",
      "default": 50,
      "description": "Graph API $top value. Cap on how many new emails per mailbox are fetched in a single polling cycle (rest wait for next cycle)."
    },
    "execution": {
      "type": "object",
      "title": "Execution Settings",
      "properties": {
        "alwaysOutputData": {
          "type": "boolean",
          "title": "Always Output Data",
          "description": "Always output data, even on error (if configured).",
          "default": false
        },
        "retryOnFail": {
          "type": "boolean",
          "title": "Retry On Fail",
          "description": "Retry the execution if it fails.",
          "default": false
        },
        "maxTries": {
          "type": "integer",
          "title": "Max Retries",
          "description": "Number of retries.",
          "default": 3,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "waitBetweenTries": {
          "type": "integer",
          "title": "Wait Between Retries (ms)",
          "default": 1000,
          "displayOptions": {
            "show": {
              "retryOnFail": [
                true
              ]
            }
          }
        },
        "continueOnFail": {
          "type": "boolean",
          "title": "Continue On Fail",
          "description": "Do not crash workflow on error.",
          "default": false
        },
        "timeout_ms": {
          "type": "integer",
          "title": "Timeout (ms)",
          "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
          "default": 300000
        }
      }
    }
  },
  "required": [
    "connection_id",
    "mailbox_emails"
  ]
}
```

### output_contract_schema

```json
{
  "type": "object",
  "description": "The incoming email data, with the originating mailbox surfaced for routing.",
  "properties": {
    "id": {
      "type": "string",
      "description": "The Graph message ID. Use this for reply/forward/delete operations."
    },
    "mailbox_email": {
      "type": "string",
      "description": "The mailbox this email was received in. Use this for per-mailbox routing downstream."
    },
    "subject": {
      "type": "string"
    },
    "from": {
      "type": "string",
      "description": "Sender email address."
    },
    "to": {
      "type": "array",
      "description": "Recipient email addresses."
    },
    "cc": {
      "type": "array"
    },
    "receivedDateTime": {
      "type": "string",
      "format": "date-time"
    },
    "body": {
      "type": "string",
      "description": "Email body content."
    },
    "bodyContentType": {
      "type": "string"
    },
    "bodyPreview": {
      "type": "string"
    },
    "isRead": {
      "type": "boolean"
    },
    "hasAttachments": {
      "type": "boolean"
    },
    "attachmentCount": {
      "type": "number"
    },
    "importance": {
      "type": "string"
    },
    "conversationId": {
      "type": "string"
    },
    "internetMessageId": {
      "type": "string"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "out",
    "label": "New Email",
    "is_default": true,
    "description": "A new email was received (below attachment threshold). Fires once per email per mailbox."
  },
  {
    "port_id": "heavy_attachments",
    "label": "Heavy Attachments",
    "description": "Email has attachments at or above the threshold. Route to a dedicated attachment processing node."
  },
  {
    "port_id": "empty",
    "label": "No New Emails",
    "description": "No new emails found in any monitored mailbox in this polling cycle."
  },
  {
    "port_id": "error",
    "label": "Error",
    "description": "Failed to fetch emails or authentication error."
  }
]
```
