# Outlook - New Email

> Se dispara cuando llega un correo nuevo a un buzón de Microsoft Outlook.

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

- Slug: `connectors.microsoft.outlook.trigger`
- Familia: Conectores
- Versión: 1.0.0
- Estado: Disponible
- Ejecución: async

Se dispara cuando llega un correo nuevo a un buzón de Microsoft Outlook.

Escucha los correos entrantes mediante suscripciones de Microsoft Graph API. Cuando se recibe un correo nuevo, el workflow se dispara con todos los datos del correo (id, asunto, remitente, cuerpo, información de adjuntos).

**Cómo funciona:**
- Cuando se inicia el workflow, se crea una suscripción de Graph API para el buzón configurado.
- Microsoft notifica a Sommatic AI cuando llega un correo nuevo.
- El trigger obtiene el correo completo y lo pasa al siguiente nodo.

**Casos de uso:**
- Responder automáticamente a los correos de soporte entrantes.
- Procesar adjuntos de correo (OCR, clasificación).
- Enrutar correos a distintos workflows según el remitente o el asunto.

## Configuración

- `connection_id` (string, obligatorio): Credencial de acceso a Microsoft Graph API. 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_email` (string, obligatorio, acepta expresiones): Dirección del buzón que se monitorea en busca de correos nuevos.
- `folder` (string, opcional): La carpeta de correo que se vigila en busca de mensajes nuevos. 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. Por defecto: `60`.
- `attachment_threshold` (number, opcional): Número de adjuntos a partir del cual el correo se dirige al puerto heavy_attachments. Útil para enrutarlo a un nodo dedicado al procesamiento de adjuntos. Por defecto: `5`.

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).
- `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 este ciclo de consulta.
- `error`: No se pudo obtener el correo o hubo un error en la suscripción.

## Contrato de salida

- `id` (string, opcional): El ID del mensaje. Úsalo para las operaciones de responder, reenviar o eliminar.
- `subject` (string, opcional)
- `from` (string, opcional): Dirección de correo del remitente.
- `to` (array, opcional): Direcciones de correo de los destinatarios.
- `receivedDateTime` (string, opcional)
- `body` (string, opcional): Contenido del cuerpo del correo.
- `bodyPreview` (string, opcional)
- `isRead` (boolean, opcional)
- `hasAttachments` (boolean, opcional)
- `attachmentCount` (number, opcional): Número de adjuntos.
- `importance` (string, opcional)

## En expresiones

Lo que un nodo posterior puede leer de la salida de este nodo con `$("Outlook - New Email").item.json.<ruta>` (escribe la etiqueta de tu nodo en lugar de `Outlook - New Email`). **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 - New Email").item.json.id` (string) = `"AAMkAGI2TG93AAA="`: El ID del mensaje. Úsalo para las operaciones de responder, reenviar o eliminar.
- `$("Outlook - New Email").item.json.subject` (string) = `"Order 123 question"`
- `$("Outlook - New Email").item.json.from` (string) = `"ana@example.com"`: Dirección de correo del remitente.
- `$("Outlook - New Email").item.json.to` (array) = `[…] (1)`: Direcciones de correo de los destinatarios.
- `$("Outlook - New Email").item.json.receivedDateTime` (string) = `"2026-11-26T14:02:51Z"`
- `$("Outlook - New Email").item.json.body` (string) = `"<html><body><p>Hello, where is my order?</p>…"`: Contenido del cuerpo del correo.
- `$("Outlook - New Email").item.json.bodyPreview` (string) = `"Hello, where is my order?"`
- `$("Outlook - New Email").item.json.isRead` (boolean) = `false`
- `$("Outlook - New Email").item.json.hasAttachments` (boolean) = `true`
- `$("Outlook - New Email").item.json.attachmentCount` (number) = `1`: Número de adjuntos.
- `$("Outlook - New Email").item.json.importance` (string) = `"normal"`
- `$("Outlook - New Email").item.json.messages` (array) = `[…] (1)` (El editor no la sugiere)
- `$("Outlook - New Email").item.json.count` (number) = `1` (El editor no la sugiere)
- `$("Outlook - New Email").item.json.hasNewEmails` (boolean) = `true` (El editor no la sugiere)
- `$("Outlook - New Email").item.json.lastTimeChecked` (string) = `"2026-11-26T14:03:00.120Z"` (El editor no la sugiere)
- `$("Outlook - New Email").item.json.previousCheckAt` (string) = `"2026-11-26T14:02:00.004Z"` (El editor no la sugiere)
- `$("Outlook - New Email").item.json.cc` (array) = `[…] (0)` (El editor no la sugiere)
- `$("Outlook - New Email").item.json.bodyContentType` (string) = `"html"` (El editor no la sugiere)
- `$("Outlook - New Email").item.json.conversationId` (string) = `"AAQkAGI2TG93CCC="` (El editor no la sugiere)
- `$("Outlook - New Email").item.json.internetMessageId` (string) = `"<CAF1x2y3z@mail.example.com>"` (El editor no la sugiere)


## Cómo funciona

Inicia un workflow con los mensajes nuevos de una carpeta de un buzón de Outlook. Por programación revisa una vez por intervalo de sondeo desde la última revisión; en una ejecución manual espera hasta que llegue correo (máximo 30 minutos).

1. Qué lo inicia: el programador del backend revisa cada 10 segundos los workflows activos que tienen una versión publicada y contienen este nodo, e inicia la versión publicada cuando pasaron `polling_interval` segundos (por defecto 60) desde su último inicio, con la entrada `{ $scheduled: true }` más el `$trigger_state` guardado.
2. Resuelve la configuración del nodo, exige `connection_id` y `mailbox_email`, obtiene un token de Graph y siempre apunta a `/users/<mailbox_email>`.
3. Si el ítem de entrada tiene `resource` (una notificación de cambios de Graph), obtiene ese mensaje y lo devuelve por `out`.
4. Ejecución programada: una consulta de los mensajes de `folder` recibidos desde `$trigger_state.lastTimeChecked` hasta ahora, del más antiguo al más reciente, máximo 50. Ejecución manual: la misma consulta cada `polling_interval` segundos desde que empezó la ejecución, renovando el token en cada ciclo, hasta que llegue un mensaje o pasen 30 minutos.
5. Cuenta los adjuntos (hasta 100) de cada mensaje que los tenga y, cuando llegó exactamente un mensaje, copia sus campos a la raíz de la salida.
6. Elige `empty` si no llegó ningún mensaje, `heavy_attachments` si llegó exactamente uno y su `attachmentCount` es al menos `attachment_threshold`, y `out` en los demás casos. Devuelve `meta.trigger_state.lastTimeChecked`, que el backend combina con el estado del disparador guardado del workflow al terminar la ejecución.

## En un workflow

### Nodo

```json
{
  "node_id": "node-support-inbox",
  "label": "Support inbox",
  "operator_slug": "connectors.microsoft.outlook.trigger",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "mailbox_email": "support@example.com",
    "folder": "inbox",
    "polling_interval": 60,
    "attachment_threshold": 5
  }
}
```

### Envelope

```json
{
  "ok": true,
  "data": {
    "messages": [
      {
        "id": "AAMkAGI2TG93AAA=",
        "subject": "Order 123 question",
        "from": "ana@example.com",
        "to": [
          "support@example.com"
        ],
        "cc": [],
        "receivedDateTime": "2026-11-26T14:02:51Z",
        "body": "<html><body><p>Hello, where is my order?</p></body></html>",
        "bodyContentType": "html",
        "bodyPreview": "Hello, where is my order?",
        "isRead": false,
        "hasAttachments": true,
        "importance": "normal",
        "conversationId": "AAQkAGI2TG93CCC=",
        "internetMessageId": "<CAF1x2y3z@mail.example.com>",
        "attachmentCount": 1
      }
    ],
    "count": 1,
    "hasNewEmails": true,
    "lastTimeChecked": "2026-11-26T14:03:00.120Z",
    "previousCheckAt": "2026-11-26T14:02:00.004Z",
    "id": "AAMkAGI2TG93AAA=",
    "subject": "Order 123 question",
    "from": "ana@example.com",
    "to": [
      "support@example.com"
    ],
    "cc": [],
    "receivedDateTime": "2026-11-26T14:02:51Z",
    "body": "<html><body><p>Hello, where is my order?</p></body></html>",
    "bodyContentType": "html",
    "bodyPreview": "Hello, where is my order?",
    "isRead": false,
    "hasAttachments": true,
    "importance": "normal",
    "conversationId": "AAQkAGI2TG93CCC=",
    "internetMessageId": "<CAF1x2y3z@mail.example.com>",
    "attachmentCount": 1
  },
  "port": "out",
  "meta": {
    "trigger_state": {
      "lastTimeChecked": "2026-11-26T14:03:00.120Z"
    }
  }
}
```

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

### `out`

Llegaron mensajes nuevos (y no es el caso de un único mensaje con muchos adjuntos). Los campos del correo en la raíz solo aparecen cuando llegó exactamente un mensaje.

```json
{
  "messages": [
    {
      "id": "AAMkAGI2TG93AAA=",
      "subject": "Order 123 question",
      "from": "ana@example.com",
      "to": [
        "support@example.com"
      ],
      "cc": [],
      "receivedDateTime": "2026-11-26T14:02:51Z",
      "body": "<html><body><p>Hello, where is my order?</p></body></html>",
      "bodyContentType": "html",
      "bodyPreview": "Hello, where is my order?",
      "isRead": false,
      "hasAttachments": true,
      "importance": "normal",
      "conversationId": "AAQkAGI2TG93CCC=",
      "internetMessageId": "<CAF1x2y3z@mail.example.com>",
      "attachmentCount": 1
    }
  ],
  "count": 1,
  "hasNewEmails": true,
  "lastTimeChecked": "2026-11-26T14:03:00.120Z",
  "previousCheckAt": "2026-11-26T14:02:00.004Z",
  "id": "AAMkAGI2TG93AAA=",
  "subject": "Order 123 question",
  "from": "ana@example.com",
  "to": [
    "support@example.com"
  ],
  "cc": [],
  "receivedDateTime": "2026-11-26T14:02:51Z",
  "body": "<html><body><p>Hello, where is my order?</p></body></html>",
  "bodyContentType": "html",
  "bodyPreview": "Hello, where is my order?",
  "isRead": false,
  "hasAttachments": true,
  "importance": "normal",
  "conversationId": "AAQkAGI2TG93CCC=",
  "internetMessageId": "<CAF1x2y3z@mail.example.com>",
  "attachmentCount": 1
}
```

### `heavy_attachments`

Llegó exactamente un mensaje y tiene `attachment_threshold` adjuntos o más. La salida tiene la misma forma que `out`.

```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>",
      "attachmentCount": 7
    }
  ],
  "count": 1,
  "hasNewEmails": true,
  "lastTimeChecked": "2026-11-26T14:04:00.087Z",
  "previousCheckAt": "2026-11-26T14:03:00.120Z",
  "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>",
  "attachmentCount": 7
}
```

### `empty`

No hay mensajes nuevos en esta revisión. Cuando una ejecución manual espera 30 minutos sin correo, la salida también trae `timedOut: true` y `polledForMs`.

```json
{
  "messages": [],
  "count": 0,
  "hasNewEmails": false,
  "lastTimeChecked": "2026-11-26T14:05:00.031Z",
  "previousCheckAt": "2026-11-26T14:04:00.087Z"
}
```

### `error`

Falló una validación (la salida es el sobre `{ ok, errors, port }`) o falló la consulta a Graph (la salida es `{ error }`).

```json
{
  "error": "Request failed with status code 403"
}
```

## Comportamiento en el código

- `polling_interval`: El mínimo de 60 segundos no se valida. El programador lo lee del borrador del workflow y, en ejecuciones manuales, es la espera entre revisiones.
- `attachment_threshold`: Solo se evalúa cuando llegó exactamente un mensaje; con varios mensajes el puerto siempre es `out`.
- `folder`: Nombre de carpeta conocida de Graph, usado tal cual en la ruta de la solicitud.

## Errores

| Mensaje | Puerto | Causa y solución |
| --- | --- | --- |
| `Microsoft 365 credential is required` | `error` | `connection_id` está vacío. `Mailbox email is required` es la misma validación para `mailbox_email`. |
| `Failed to resolve Microsoft 365 access token` | `error` | No se pudo resolver la credencial o falló la solicitud del token. |
| `Poll failed: <message>` | `error` | Falló la consulta de mensajes, por ejemplo 403 si la aplicación no tiene `Mail.Read` sobre el buzón o 404 si el buzón no existe. |
| `Failed to fetch email from resource: <message>` | `error` | No se pudo leer el mensaje referido por una notificación de cambios. |

## Notas y límites

- Prueba frente a producción: el programador solo inicia la versión publicada, así que un borrador nunca sondea por sí solo. Al ejecutar el workflow manualmente se inicia en cambio el ciclo de sondeo bloqueante; con datos de muestra el motor omite este nodo y entrega la entrada de muestra por `out`.
- La primera ejecución programada (sin estado guardado) revisa el intervalo de ahora a ahora, así que no encuentra nada; el correo se recoge a partir del siguiente ciclo.
- Se leen como máximo 50 mensajes por revisión y luego `lastTimeChecked` pasa a ahora, así que los mensajes que superen los primeros 50 de un intervalo no se recogen. Cuando llegan varios mensajes, procesa `messages` (por ejemplo con `flow.split`).
- El buzón se direcciona como `/users/<mailbox_email>`, así que la credencial necesita el permiso de aplicación `Mail.Read` (client credentials). La salida incluye el `body` completo del mensaje.


## Contratos (JSON Schema)

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

```json
{
  "slug": "connectors.microsoft.outlook.trigger",
  "name": "Outlook - New Email",
  "category": "integrations",
  "version": "1.0.0",
  "description": "Triggers when a new email arrives in a Microsoft Outlook mailbox.\n\n  Listens for incoming emails via Microsoft Graph API subscriptions. When a new email is received, the workflow is triggered with the full email data (id, subject, from, body, attachments info).\n\n  **How it works:**\n  - When the workflow starts, a Graph API subscription is created for the configured mailbox.\n  - Microsoft notifies Sommatic AI when a new email arrives.\n  - The trigger fetches the full email and passes it to the next node.\n\n  **Use Cases:**\n  - Auto-reply to incoming support emails.\n  - Process email attachments (OCR, classification).\n  - Route emails to different workflows based on sender or subject.",
  "capabilities": [
    "email",
    "microsoft",
    "outlook",
    "trigger",
    "webhook"
  ],
  "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. 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_email": {
        "type": "string",
        "title": "Mailbox Email",
        "description": "Email address of the mailbox to monitor for new emails.",
        "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."
      },
      "polling_interval": {
        "type": "number",
        "title": "Polling Interval (seconds)",
        "default": 60,
        "description": "How often to check for new emails. Minimum 60 seconds."
      },
      "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. Useful for routing to a dedicated attachment processing node."
      },
      "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_email"
    ]
  },
  "input_contract_schema": null,
  "output_contract_schema": {
    "type": "object",
    "description": "The incoming email data from Microsoft Graph API.",
    "properties": {
      "id": {
        "type": "string",
        "description": "The message ID. Use this for reply/forward/delete operations."
      },
      "subject": {
        "type": "string"
      },
      "from": {
        "type": "string",
        "description": "Sender email address."
      },
      "to": {
        "type": "array",
        "description": "Recipient email addresses."
      },
      "receivedDateTime": {
        "type": "string",
        "format": "date-time"
      },
      "body": {
        "type": "string",
        "description": "Email body content."
      },
      "bodyPreview": {
        "type": "string"
      },
      "isRead": {
        "type": "boolean"
      },
      "hasAttachments": {
        "type": "boolean"
      },
      "attachmentCount": {
        "type": "number",
        "description": "Number of attachments."
      },
      "importance": {
        "type": "string"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "New Email",
      "is_default": true,
      "description": "A new email was received (below attachment threshold)."
    },
    {
      "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 this polling cycle."
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Failed to fetch email or subscription error."
    }
  ],
  "execution_mode": "async",
  "tags": [
    "email",
    "microsoft",
    "outlook",
    "trigger",
    "incoming"
  ],
  "is_stateful": false,
  "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. 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_email": {
      "type": "string",
      "title": "Mailbox Email",
      "description": "Email address of the mailbox to monitor for new emails.",
      "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."
    },
    "polling_interval": {
      "type": "number",
      "title": "Polling Interval (seconds)",
      "default": 60,
      "description": "How often to check for new emails. Minimum 60 seconds."
    },
    "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. Useful for routing to a dedicated attachment processing node."
    },
    "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_email"
  ]
}
```

### output_contract_schema

```json
{
  "type": "object",
  "description": "The incoming email data from Microsoft Graph API.",
  "properties": {
    "id": {
      "type": "string",
      "description": "The message ID. Use this for reply/forward/delete operations."
    },
    "subject": {
      "type": "string"
    },
    "from": {
      "type": "string",
      "description": "Sender email address."
    },
    "to": {
      "type": "array",
      "description": "Recipient email addresses."
    },
    "receivedDateTime": {
      "type": "string",
      "format": "date-time"
    },
    "body": {
      "type": "string",
      "description": "Email body content."
    },
    "bodyPreview": {
      "type": "string"
    },
    "isRead": {
      "type": "boolean"
    },
    "hasAttachments": {
      "type": "boolean"
    },
    "attachmentCount": {
      "type": "number",
      "description": "Number of attachments."
    },
    "importance": {
      "type": "string"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "out",
    "label": "New Email",
    "is_default": true,
    "description": "A new email was received (below attachment threshold)."
  },
  {
    "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 this polling cycle."
  },
  {
    "port_id": "error",
    "label": "Error",
    "description": "Failed to fetch email or subscription error."
  }
]
```
