繁体   English   中英

SendGrid webhook 事件可以包含来自个性化的 custom_args 吗?

[英]Can SendGrid webhook events include custom_args from personalizations?

我在 SendGrid 中使用动态模板向个性化字段中的多个收件人发送通常为 go 的交易电子邮件。 消息正文包括在所有收件人之间共享的 custom_args,并且在个性化中,custom_args 和 dynamic_template_data 都特定于每个收件人。 Webhook 事件返回共享的 custom_args,但不返回特定于接收者的 custom_args。 有没有办法将事件与个性化的 custom_args 放在一起? 这是一个示例请求正文,我们在其中为每个收件人添加了一个 userId custom_arg:

{
  "from": {
    "email": "sender@example.com",
    "name": "Example Sender"
  },
  "personalizations": [
    {
      "to": [
        {
          "email": "recipient1@example.com",
          "custom_args": {
            "userId": "63r20acm4xfv"
          }
        }
      ],
      "dynamic_template_data": {
        "subject": "New Article",
        "description": "Read the lastest news on...",
        "documentId": "624dxnpvhw8g",
        "host": "https://localhost:8000",
        "userId": "63r20acm4xfv"
      }
    }
  ],
  "custom_args": {
    "documentId": "624dxnpvhw8g"
  }
}

我们收到的 webhook 事件(报告了“documentId”自定义 arg,但没有报告个性化中的“userID”custom_arg):

[
  {
    "documentId": "624dxnpvhw8g",
    "email": "recipient1@example.com",
    "event": "processed",
    "sg_event_id": "cHJvY2Vzc2VkLTI3MTk3NzMzLUtTUEJOaVpGUXpXb05KblctVDBNRkEtMA",
    "sg_message_id": "KSPBNiZFQzWoNJnW-T0MFA.filterdrecv-58c58fcb9f-44vrp-1-6312139C-1F6.0",
    "sg_template_id": "d-1ebc6b474b7041c0b439d1bdb17650e4",
    "sg_template_name": "DEFAULT TEMPLATE",
    "smtp-id": "<redacted>",
    "timestamp": 1662128000
  },
  {
    "documentId": "624dxnpvhw8g",
    "email": "recipient1@example.com",
    "event": "delivered",
    "ip": "<redacted>",
    "response": "250 Message received",
    "sg_event_id": "ZGVsaXZlcmVkLTAtMjcxOTc3MzMtS1NQQk5pWkZReldvTkpuVy1UME1GQS0w",
    "sg_message_id": "KSPBNiZFQzWoNJnW-T0MFA.filterdrecv-58c58fcb9f-44vrp-1-6312139C-1F6.0",
    "sg_template_id": "d-1ebc6b474b7041c0b439d1bdb17650e4",
    "sg_template_name": "DEFAULT TEMPLATE",
    "smtp-id": "<redacted>",
    "timestamp": 1662128002,
    "tls": 1
  }
]

呃 - 个性化中的 custom_args 处于错误的级别。 将 custom_args 移动到与 dynamic_template_data 相同的级别后,它工作正常,并且值包含在 webhook 事件中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM