You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已部署邮件通道的Microsoft Bot接收新邮件的输入样本咨询

嘿,我刚好做过连接邮件通道的Azure Bot,给你捋捋新邮件进来时Bot拿到的输入是什么样的!

新邮件到达时的输入样本(简化版)

当有新邮件触发Bot时,你会收到一个标准的Bot Framework Activity 对象,格式大概是这样的(我给你简化了核心字段,实际会包含更多元数据):

{
  "type": "message",
  "id": "abc123-xyz456",
  "timestamp": "2024-05-20T14:30:00.000Z",
  "serviceUrl": "https://smtp.botframework.com/",
  "channelId": "email",
  "from": {
    "id": "sender@example.com",
    "name": "John Doe"
  },
  "recipient": {
    "id": "your-bot-email@outlook.com",
    "name": "Your Bot Name"
  },
  "conversation": {
    "id": "email-thread-12345",
    "topic": "Question about your Bot service"
  },
  "subject": "Question about your Bot service",
  "text": "Hi there, I have a question about how your email bot works...",
  "textFormat": "plain",
  "attachments": [
    {
      "name": "sample.pdf",
      "contentType": "application/pdf",
      "contentUrl": "https://temp-storage.azure.com/.../sample.pdf"
    }
  ],
  "toRecipients": [
    { "id": "your-bot-email@outlook.com", "name": "Your Bot Name" }
  ],
  "ccRecipients": [
    { "id": "cc-user@example.com", "name": "CC User" }
  ]
}
Bot接收邮件时的核心输入内容拆解

你重点关注这些字段就够了:

  • 发件人详情:从from字段获取,id是发件人邮箱地址,name是对方的显示名称
  • 邮件主题:直接取subject字段,若为回复邮件,这个字段会自动带上"Re: "前缀
  • 正文内容:text是纯文本格式的邮件正文;如果原邮件是HTML格式,attachments里还会附带一个contentType为text/html的附件,对应HTML版正文
  • 附件信息:attachments数组里的每个元素包含附件名称、类型,以及临时有效的contentUrl(你可以通过这个链接下载附件,注意链接有有效期限制)
  • 会话关联:conversation.id是邮件线程的唯一标识,用户回复同一条邮件线程时,这个ID会保持一致,方便Bot跟踪会话上下文
  • 收件人列表:toRecipients是主收件人集合,ccRecipients是抄送收件人集合,你可以通过这个判断Bot是否处于抄送列表中

另外补充个小细节:如果用户回复的是Bot之前发送的邮件,replyToId字段会带上Bot之前发送消息的ID,你可以用这个字段做更精准的会话上下文关联~

内容的提问来源于stack exchange,提问作者Priya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:26:04