Outlook - New Email
当 Microsoft Outlook 邮箱收到新邮件时触发。
以某个 Outlook 邮箱文件夹中的新邮件启动工作流。按计划运行时,每个轮询间隔检查一次自上次检查以来的邮件;手动运行时会等待新邮件到达(最长 30 分钟)。
通过 Microsoft Graph API 订阅监听收到的邮件。收到新邮件时,工作流会携带完整的邮件数据(id、subject、from、body、附件信息)被触发。
工作原理:
- 工作流启动时,为所配置的邮箱创建一个 Graph API 订阅。
- 新邮件到达时,Microsoft 通知 Sommatic AI。
- 触发器获取完整邮件并传给下一个节点。
适用场景:
- 自动回复收到的支持邮件。
- 处理邮件附件(OCR、分类)。
- 按发件人或主题将邮件路由到不同的工作流。
工作原理
- 触发来源:后端调度器每 10 秒检查一次已发布且包含本节点的活跃工作流;距上次启动超过
polling_interval秒(默认 60)时,以{ $scheduled: true }加上已保存的$trigger_state作为输入启动已发布版本。 - 解析节点配置,必须提供
connection_id和mailbox_email,获取 Graph 令牌,并始终访问/users/<mailbox_email>。 - 若输入项包含
resource(Graph 变更通知),则获取该邮件并经out返回。 - 计划运行:查询一次
folder中从$trigger_state.lastTimeChecked到当前收到的邮件,按时间升序,最多 50 封。手动运行:从运行开始时起每polling_interval秒执行同样的查询,每轮刷新令牌,直到有邮件到达或满 30 分钟。 - 统计每封带附件邮件的附件数量(最多 100 个);恰好收到一封邮件时,将该邮件的字段复制到输出根级。
- 没有邮件时选择
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": "[email protected]",
"folder": "inbox",
"polling_interval": 60,
"attachment_threshold": 5
}
}{
"ok": true,
"data": {
"messages": [
{
"id": "AAMkAGI2TG93AAA=",
"subject": "Order 123 question",
"from": "[email protected]",
"to": [
"[email protected]"
],
"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": "<[email protected]>",
"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": "[email protected]",
"to": [
"[email protected]"
],
"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": "<[email protected]>",
"attachmentCount": 1
},
"port": "out",
"meta": {
"trigger_state": {
"lastTimeChecked": "2026-11-26T14:03:00.120Z"
}
}
}配置
-
connection_idstring 必填 -
用于访问 Microsoft Graph API 的凭据。接受 `oauth2`(access + refresh token)、`service-account`(tenant id + client id + client secret)或 `object`(高级 Graph 配置)类型的凭据。
-
mailbox_emailstring 必填 支持表达式 -
要监控新邮件的邮箱地址。
-
folderstring 可选 -
要监视新邮件的邮件文件夹。
-
polling_intervalnumber 可选 -
检查新邮件的频率。最少 60 秒。
-
attachment_thresholdnumber 可选 -
附件数量达到或超过此值时,邮件路由到 heavy_attachments 端口。便于路由到专门的附件处理节点。
配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
polling_interval - 并不强制 60 秒的最小值。调度器从工作流草稿中读取该值;手动运行时它是两次检查之间的等待时间。
-
attachment_threshold - 仅在恰好收到一封邮件时才评估;收到多封邮件时端口总是
out。 -
folder - Graph 预定义文件夹名称,原样用于请求路径。
输出端口
out 默认 收到新邮件(且不属于单封多附件的情况)。仅在恰好收到一封邮件时,输出根级才包含该邮件的字段。
{
"messages": [
{
"id": "AAMkAGI2TG93AAA=",
"subject": "Order 123 question",
"from": "[email protected]",
"to": [
"[email protected]"
],
"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": "<[email protected]>",
"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": "[email protected]",
"to": [
"[email protected]"
],
"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": "<[email protected]>",
"attachmentCount": 1
}heavy_attachments 恰好收到一封邮件,且其附件数不少于 attachment_threshold。输出结构与 out 相同。
{
"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]>",
"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": "[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]>",
"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 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Outlook - New Email").item.json.id消息 ID。用于回复/转发/删除操作。 | ||
$("Outlook - New Email").item.json.subject | ||
$("Outlook - New Email").item.json.from发件人邮箱地址。 | ||
$("Outlook - New Email").item.json.to收件人邮箱地址。 | ||
$("Outlook - New Email").item.json.receivedDateTime | ||
$("Outlook - New Email").item.json.body邮件正文内容。 | ||
$("Outlook - New Email").item.json.bodyPreview | ||
$("Outlook - New Email").item.json.isRead | ||
$("Outlook - New Email").item.json.hasAttachments | ||
$("Outlook - New Email").item.json.attachmentCount附件数量。 | ||
$("Outlook - New Email").item.json.importance | ||
$("Outlook - New Email").item.json.messages | — | |
$("Outlook - New Email").item.json.count | — | |
$("Outlook - New Email").item.json.hasNewEmails | — | |
$("Outlook - New Email").item.json.lastTimeChecked | — | |
$("Outlook - New Email").item.json.previousCheckAt | — | |
$("Outlook - New Email").item.json.cc | — | |
$("Outlook - New Email").item.json.bodyContentType | — | |
$("Outlook - New Email").item.json.conversationId | — | |
$("Outlook - New Email").item.json.internetMessageId | — |
— 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 | 无法读取变更通知所引用的邮件。 |
输出契约
-
idstring 可选 -
消息 ID。用于回复/转发/删除操作。
-
subjectstring 可选 -
fromstring 可选 -
发件人邮箱地址。
-
toarray 可选 -
收件人邮箱地址。
-
receivedDateTimestring 可选 -
bodystring 可选 -
邮件正文内容。
-
bodyPreviewstring 可选 -
isReadboolean 可选 -
hasAttachmentsboolean 可选 -
attachmentCountnumber 可选 -
附件数量。
-
importancestring 可选
契约(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
}
}
}{
"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"
]
}{
"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"
}
}
}[
{
"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."
}
]执行
- 执行方式
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