本页内容
Sommatic 文档
打开控制台

Outlook - Multi-Mailbox Trigger

当多个 Microsoft Outlook 邮箱中的任意一个收到新邮件时触发。

以 Markdown 查看
在以下应用中打开
连接器 部分可用 connectors.microsoft.outlook.trigger.multi 版本 1.0.0 执行方式: async

以多个 Outlook 邮箱的新邮件启动工作流,各邮箱并行检查,并分别记录每个邮箱的上次检查时间。每次运行只输出一次:所有新邮件放在 messages 中,第一封邮件的字段复制到根级。

企业级多租户邮箱监听器。单个触发器节点并行监视一组邮箱,每封新邮件触发一次工作流执行,并在载荷中标明来源邮箱。非常适合共享收件箱架构(PQRS、客服、法务受理、人力资源),即多个职能邮箱需要汇入同一个分诊工作流的场景。

工作原理:

  • 每个轮询周期,触发器并行检查所有已配置的邮箱(每个邮箱一次 Graph API 调用)。
  • 每封新邮件都作为一次独立的触发:如果 3 个邮箱在同一周期各收到 1 封新邮件,工作流就执行 3 次。
  • 来源邮箱以 mailbox_email 暴露在输出载荷中,供下游节点据此路由或打标签。
  • lastTimeChecked 状态按邮箱独立跟踪(因此轮询较慢的邮箱不会阻塞其他邮箱)。
  • 若邮件附件较多,会改用 heavy_attachments 端口而非 out,以便下游专门处理。

何时优先选用它而不是单邮箱触发器:

  • 你有 2 个以上需要运行同一工作流的共享收件箱。
  • 你不想维护 N 个功能完全相同的并行工作流(每个邮箱一个)。
  • 你需要在一组邮箱之间保持一致的状态跟踪。

何时不宜选用:

  • 每月邮件量超过 1 万封且需要亚秒级延迟:请改用 Graph webhooks + 队列(例如 Service Bus)。
  • 各邮箱的下游逻辑差异明显:请使用各自独立的工作流。

工作原理

  1. 触发来源:手动运行工作流。当前版本的后端调度器不会启动本节点(只调度 cron.trigger 和 connectors.microsoft.outlook.trigger);只有输入中带有 $scheduled: true 时才会走计划运行分支。
  2. 解析节点配置,必须提供 connection_id,且 mailbox_emails(数组或逗号分隔字符串)中至少有一个地址,然后获取 Graph 令牌。
  3. 针对每个邮箱,查询 folder 中自其 $trigger_state.perMailbox[<邮箱>].lastTimeChecked(无记录时从当前时间)以来收到的邮件,按时间升序,最多 max_emails_per_cycle 封(默认 50),并为每封邮件标注 mailbox_email。
  4. 计划分支:只检查一轮;查询失败的邮箱会被跳过,并保留其上次检查时间。手动运行:每 polling_interval 秒重复一轮并刷新令牌,直到任一邮箱有新邮件或满 30 分钟;任一邮箱失败都会导致本次运行失败。
  5. 统计带附件邮件的附件数(最多 100 个),将第一封邮件的字段复制到根级,并选择 empty(无邮件)、heavy_attachments(第一封邮件附件数不少于 attachment_threshold)或 out。返回的 meta.trigger_state.perMailbox 会在运行结束后由后端保存。

在工作流中

节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。

{
  "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": [
      "[email protected]",
      "[email protected]"
    ],
    "folder": "inbox",
    "polling_interval": 60,
    "attachment_threshold": 5,
    "max_emails_per_cycle": 50
  }
}

配置

connection_id string 必填

用于访问 Microsoft Graph API 的凭据。应用注册必须对所有被监控邮箱拥有 Mail.Read 权限(Application)。接受 `oauth2`(access + refresh token)、`service-account`(tenant id + client id + client secret)或 `object`(高级 Graph 配置)类型的凭据。

mailbox_emails array<string> 必填

要监控的邮箱地址列表。每个邮箱地址都必须可由所配置的凭据访问。

folder string 可选

要监视新邮件的邮件文件夹(所有邮箱使用同一文件夹)。

默认值: inbox

可选值: inboxsentitemsdraftsdeleteditemsjunkemailarchive

polling_interval number 可选

检查新邮件的频率。最少 60 秒。每个周期并行检查各邮箱。

默认值: 60

attachment_threshold number 可选

附件数量达到或超过此值时,邮件路由到 heavy_attachments 端口而不是 out。

默认值: 5

max_emails_per_cycle number 可选

Graph API 的 $top 值。单个轮询周期内每个邮箱最多获取的新邮件数(其余等待下一周期)。

默认值: 50

配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。

代码中的行为

除 schema 描述之外,实现代码对这些键的实际处理。

mailbox_emails
接受数组或逗号分隔字符串。凭据必须具备应用权限 Mail.Read,能读取每个邮箱。
attachment_threshold
即使收到多封邮件,也只针对第一封邮件评估。
polling_interval
手动运行时两轮检查之间的等待时间。不强制 60 秒最小值,后端调度器也不会为本节点使用该值。

输出端口

out 默认

至少一个邮箱有新邮件,且第一封邮件的附件数低于阈值。

数据
{
  "messages": [
    {
      "id": "AAMkAGI2TG93AAA=",
      "subject": "Invoice request",
      "from": "[email protected]",
      "to": [
        "[email protected]"
      ],
      "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": "<[email protected]>",
      "mailbox_email": "[email protected]"
    }
  ],
  "count": 1,
  "hasNewEmails": true,
  "lastTimeChecked": "2026-11-26T14:03:00.120Z",
  "id": "AAMkAGI2TG93AAA=",
  "subject": "Invoice request",
  "from": "[email protected]",
  "to": [
    "[email protected]"
  ],
  "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": "<[email protected]>",
  "mailbox_email": "[email protected]"
}
heavy_attachments

第一封邮件附件数不少于 attachment_threshold。结构与 out 相同,邮件中带有 attachmentCount。

数据
{
  "messages": [
    {
      "id": "AAMkAGI2TG94AAA=",
      "subject": "Scanned documents",
      "from": "[email protected]",
      "to": [
        "[email protected]"
      ],
      "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": "<[email protected]>",
      "mailbox_email": "[email protected]",
      "attachmentCount": 7
    }
  ],
  "count": 1,
  "hasNewEmails": true,
  "lastTimeChecked": "2026-11-26T14:04:00.087Z",
  "id": "AAMkAGI2TG94AAA=",
  "subject": "Scanned documents",
  "from": "[email protected]",
  "to": [
    "[email protected]"
  ],
  "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": "<[email protected]>",
  "mailbox_email": "[email protected]",
  "attachmentCount": 7
}
empty

所有邮箱都没有新邮件(计划分支),或手动运行等待 30 分钟仍无邮件(此时带有 timedOut: true 和 polledForMs)。

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

校验失败(输出为信封 { ok, errors, port }),或手动运行时某个邮箱查询失败(输出为 { error })。

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

在表达式中

后续节点可通过 $("Outlook - Multi-Mailbox Trigger").item.json.<路径> 读取此节点输出中的内容(请把 Outlook - Multi-Mailbox Trigger 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。

表达式EditorWorker
$("Outlook - Multi-Mailbox Trigger").item.json.idstring= "AAMkAGI2TG93AAA="Graph 消息 ID。用于回复/转发/删除操作。
$("Outlook - Multi-Mailbox Trigger").item.json.mailbox_emailstring= "[email protected]"收到这封邮件的邮箱。用于下游按邮箱路由。
$("Outlook - Multi-Mailbox Trigger").item.json.subjectstring= "Invoice request"
$("Outlook - Multi-Mailbox Trigger").item.json.fromstring= "[email protected]"发件人邮箱地址。
$("Outlook - Multi-Mailbox Trigger").item.json.toarray= […] (1)收件人邮箱地址。
$("Outlook - Multi-Mailbox Trigger").item.json.ccarray= […] (0)
$("Outlook - Multi-Mailbox Trigger").item.json.receivedDateTimestring= "2026-11-26T14:02:51Z"
$("Outlook - Multi-Mailbox Trigger").item.json.bodystring= "<html><body><p>Please send the invoice.</p><…"邮件正文内容。
$("Outlook - Multi-Mailbox Trigger").item.json.bodyContentTypestring= "html"
$("Outlook - Multi-Mailbox Trigger").item.json.bodyPreviewstring= "Please send the invoice."
$("Outlook - Multi-Mailbox Trigger").item.json.isReadboolean= false
$("Outlook - Multi-Mailbox Trigger").item.json.hasAttachmentsboolean= false
$("Outlook - Multi-Mailbox Trigger").item.json.attachmentCountnumberworker 不返回:读取结果为 undefined —
$("Outlook - Multi-Mailbox Trigger").item.json.importancestring= "normal"
$("Outlook - Multi-Mailbox Trigger").item.json.conversationIdstring= "AAQkAGI2TG93CCC="
$("Outlook - Multi-Mailbox Trigger").item.json.internetMessageIdstring= "<[email protected]>"
$("Outlook - Multi-Mailbox Trigger").item.json.messagesarray编辑器不提示= […] (1)—
$("Outlook - Multi-Mailbox Trigger").item.json.countnumber编辑器不提示= 1—
$("Outlook - Multi-Mailbox Trigger").item.json.hasNewEmailsboolean编辑器不提示= true—
$("Outlook - Multi-Mailbox Trigger").item.json.lastTimeCheckedstring编辑器不提示= "2026-11-26T14:03:00.120Z"—

— Editor: 编辑器会提示它,但 worker 并不返回:读取结果为 undefined。

— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。

错误

消息 端口 原因与处理
Microsoft 365 credential is required error connection_id 为空。
At least one mailbox email is required error mailbox_emails 为空或不包含有效字符串。
Failed to resolve Microsoft 365 access token error 凭据无法解析或令牌申请失败。
Poll failed: <message> error 手动运行:某个邮箱的查询失败(例如缺少该邮箱的 Mail.Read 权限时返回 403)。

输出契约

id string 可选

Graph 消息 ID。用于回复/转发/删除操作。

mailbox_email string 可选

收到这封邮件的邮箱。用于下游按邮箱路由。

subject string 可选
from string 可选

发件人邮箱地址。

to array 可选

收件人邮箱地址。

cc array 可选
receivedDateTime string 可选
body string 可选

邮件正文内容。

bodyContentType string 可选
bodyPreview string 可选
isRead boolean 可选
hasAttachments boolean 可选
attachmentCount number 可选
importance string 可选
conversationId string 可选
internetMessageId string 可选

契约(JSON Schema)

与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。

{
  "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
    }
  }
}

执行

执行方式
async
有状态
是
重试(retryOnFail)
否
凭据
在服务器端根据 connection_id 解析,密钥不会进入工作流。
能力
emailmicrosoftoutlooktriggermulti-mailboxshared-inbox
标签
emailmicrosoftoutlooktriggermulti-mailboxshared-inboxpremium

说明与限制

  • 定义中称每个邮箱的每封邮件触发一次,但代码每次运行只触发一次。找到的所有邮件都在 messages 中,只有第一封复制到根级,且所有邮箱的上次检查时间都会前移,因此请遍历 messages(例如使用 flow.split),不要依赖根级字段。
  • 与单邮箱触发器不同,手动运行时若存在已保存的各邮箱上次检查时间,会从该时间开始检查,因此也会返回自上次运行以来收到的邮件。
  • 使用示例数据时,引擎会跳过本节点并经 out 输出示例输入。手动运行最长会阻塞 30 分钟。

已对照编排器代码核实 · 31e874b · 2026-11-26

安装智能体工具

为你的编程智能体接入 Sommatic AI 官方文档:技能包、文档 MCP 服务器与 Markdown 页面,无需再抓取网页。

仅安装技能包,不会自动更新;需要时重新运行即可。

npx skills add https://docs.sommatic.ai
智能体如何读取本文档