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

Outlook - New Email

当 Microsoft Outlook 邮箱收到新邮件时触发。

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

以某个 Outlook 邮箱文件夹中的新邮件启动工作流。按计划运行时,每个轮询间隔检查一次自上次检查以来的邮件;手动运行时会等待新邮件到达(最长 30 分钟)。

通过 Microsoft Graph API 订阅监听收到的邮件。收到新邮件时,工作流会携带完整的邮件数据(id、subject、from、body、附件信息)被触发。

工作原理:

  • 工作流启动时,为所配置的邮箱创建一个 Graph API 订阅。
  • 新邮件到达时,Microsoft 通知 Sommatic AI。
  • 触发器获取完整邮件并传给下一个节点。

适用场景:

  • 自动回复收到的支持邮件。
  • 处理邮件附件(OCR、分类)。
  • 按发件人或主题将邮件路由到不同的工作流。

工作原理

  1. 触发来源:后端调度器每 10 秒检查一次已发布且包含本节点的活跃工作流;距上次启动超过 polling_interval 秒(默认 60)时,以 { $scheduled: true } 加上已保存的 $trigger_state 作为输入启动已发布版本。
  2. 解析节点配置,必须提供 connection_id 和 mailbox_email,获取 Graph 令牌,并始终访问 /users/<mailbox_email>。
  3. 若输入项包含 resource(Graph 变更通知),则获取该邮件并经 out 返回。
  4. 计划运行:查询一次 folder 中从 $trigger_state.lastTimeChecked 到当前收到的邮件,按时间升序,最多 50 封。手动运行:从运行开始时起每 polling_interval 秒执行同样的查询,每轮刷新令牌,直到有邮件到达或满 30 分钟。
  5. 统计每封带附件邮件的附件数量(最多 100 个);恰好收到一封邮件时,将该邮件的字段复制到输出根级。
  6. 没有邮件时选择 empty;恰好一封且其 attachmentCount 不小于 attachment_threshold 时选择 heavy_attachments;其余情况选择 out。返回的 meta.trigger_state.lastTimeChecked 会在运行结束后由后端合并到工作流已保存的触发器状态中。

在工作流中

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

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

配置

connection_id string 必填

用于访问 Microsoft Graph API 的凭据。接受 `oauth2`(access + refresh token)、`service-account`(tenant id + client id + client secret)或 `object`(高级 Graph 配置)类型的凭据。

mailbox_email string 必填 支持表达式

要监控新邮件的邮箱地址。

folder string 可选

要监视新邮件的邮件文件夹。

默认值: inbox

可选值: inboxsentitemsdraftsdeleteditemsjunkemailarchive

polling_interval number 可选

检查新邮件的频率。最少 60 秒。

默认值: 60

attachment_threshold number 可选

附件数量达到或超过此值时,邮件路由到 heavy_attachments 端口。便于路由到专门的附件处理节点。

默认值: 5

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

代码中的行为

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

polling_interval
并不强制 60 秒的最小值。调度器从工作流草稿中读取该值;手动运行时它是两次检查之间的等待时间。
attachment_threshold
仅在恰好收到一封邮件时才评估;收到多封邮件时端口总是 out。
folder
Graph 预定义文件夹名称,原样用于请求路径。

输出端口

out 默认

收到新邮件(且不属于单封多附件的情况)。仅在恰好收到一封邮件时,输出根级才包含该邮件的字段。

数据
{
  "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

恰好收到一封邮件,且其附件数不少于 attachment_threshold。输出结构与 out 相同。

数据
{
  "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

本次检查没有新邮件。手动运行等待 30 分钟仍无邮件时,输出还会包含 timedOut: true 和 polledForMs。

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

校验失败(输出为信封 { ok, errors, port }),或 Graph 查询失败(输出为 { error })。

数据
{
  "error": "Request failed with status code 403"
}

在表达式中

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

表达式EditorWorker
$("Outlook - New Email").item.json.idstring= "AAMkAGI2TG93AAA="消息 ID。用于回复/转发/删除操作。
$("Outlook - New Email").item.json.subjectstring= "Order 123 question"
$("Outlook - New Email").item.json.fromstring= "ana@example.com"发件人邮箱地址。
$("Outlook - New Email").item.json.toarray= […] (1)收件人邮箱地址。
$("Outlook - New Email").item.json.receivedDateTimestring= "2026-11-26T14:02:51Z"
$("Outlook - New Email").item.json.bodystring= "<html><body><p>Hello, where is my order?</p>…"邮件正文内容。
$("Outlook - New Email").item.json.bodyPreviewstring= "Hello, where is my order?"
$("Outlook - New Email").item.json.isReadboolean= false
$("Outlook - New Email").item.json.hasAttachmentsboolean= true
$("Outlook - New Email").item.json.attachmentCountnumber= 1附件数量。
$("Outlook - New Email").item.json.importancestring= "normal"
$("Outlook - New Email").item.json.messagesarray编辑器不提示= […] (1)—
$("Outlook - New Email").item.json.countnumber编辑器不提示= 1—
$("Outlook - New Email").item.json.hasNewEmailsboolean编辑器不提示= true—
$("Outlook - New Email").item.json.lastTimeCheckedstring编辑器不提示= "2026-11-26T14:03:00.120Z"—
$("Outlook - New Email").item.json.previousCheckAtstring编辑器不提示= "2026-11-26T14:02:00.004Z"—
$("Outlook - New Email").item.json.ccarray编辑器不提示= […] (0)—
$("Outlook - New Email").item.json.bodyContentTypestring编辑器不提示= "html"—
$("Outlook - New Email").item.json.conversationIdstring编辑器不提示= "AAQkAGI2TG93CCC="—
$("Outlook - New Email").item.json.internetMessageIdstring编辑器不提示= "<CAF1x2y3z@mail.example.com>"—

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

错误

消息 端口 原因与处理
Microsoft 365 credential is required error connection_id 为空。Mailbox email is required 是对 mailbox_email 的同类校验。
Failed to resolve Microsoft 365 access token error 凭据无法解析或令牌申请失败。
Poll failed: <message> error 邮件查询失败,例如应用缺少该邮箱的 Mail.Read 权限时返回 403,邮箱不存在时返回 404。
Failed to fetch email from resource: <message> error 无法读取变更通知所引用的邮件。

输出契约

id string 可选

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

subject string 可选
from string 可选

发件人邮箱地址。

to array 可选

收件人邮箱地址。

receivedDateTime string 可选
body string 可选

邮件正文内容。

bodyPreview string 可选
isRead boolean 可选
hasAttachments boolean 可选
attachmentCount number 可选

附件数量。

importance string 可选

契约(JSON Schema)

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

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

执行

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

说明与限制

  • 测试与生产:调度器只启动已发布版本,草稿不会自行轮询。手动运行工作流时会进入阻塞式轮询;使用示例数据时,引擎会跳过本节点,直接经 out 输出示例输入。
  • 首次计划运行(无已保存状态)检查的时间窗口为“现在到现在”,因此不会找到邮件;从下一轮起才开始收取邮件。
  • 每次检查最多读取 50 封邮件,随后 lastTimeChecked 更新为当前时间,因此同一间隔内超出前 50 封的邮件不会被收取。收到多封邮件时,请处理 messages(例如使用 flow.split)。
  • 邮箱以 /users/<mailbox_email> 方式访问,因此凭据需要应用权限 Mail.Read(client credentials)。输出包含完整的邮件 body。

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

安装智能体工具

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

安装 Sommatic AI CLI,并为检测到的智能体配置合适的插件。

npx @sommatic/cli agent setup
智能体如何读取本文档