---
# System prepended metadata

title: ' SendGrid 科技接觸整合'

---


# SendGrid 科技接觸整合


- 月費每月89.95美金，每月可以發送15萬封信件
- 提供SSO，可以整合CRM帳號登入
- 1000個teammate(業務、行銷、行政、工程帳號)，可以指定權限及發送限制
- 固定IP，可請客戶設定白名單
- 5組 Webhook，開信、點擊事件可以分群處理


工作流程：

1. CRM定期同步聯絡人欄位到Sendgrid(聯絡人名稱、個人電話、Email、標籤、公司名稱)
2. 行銷設定好分眾條件，可透過Automation或是Single Send在Sendgrid發送EDM，透過Webhook打回CRM
3. CRM根據Webhook事件，建立EDM Campaign, 建立名片、更新聯絡人與客戶關係，更新聯絡人與客戶資訊，更新潛客名單，建立活動紀錄。
4. 撈取發送信件失敗紀錄，顯示查無用戶：回CRM將聯絡人標記為「離職」
5. 活動通知：活動後台->同步CRM及標籤->行銷在SendGrid設定Segment->發送活動通知->沒有開信續發第二次通知->續發簡訊
6. 直接上傳名單到sendgrid發信，透過Webhook通知CRM發信事件，因為只能收到email，CRM嘗試透過Email歸戶，既有聯絡人，新增Email活動紀錄，不建立新的聯絡人(只有名片)。

Webhook 參數整理


|參數|數值說明|CRM處理方式|
|--|--|--|
|email|實際發送的email地址，Contact Key|建立Email事件，活動紀錄，活動紀錄Mapping對應到的聯絡人(複數)|
|mc_stats|判斷發信事件來源，automation 主要是腳本式的發送活動，無法貼標(需要配合Webhook，由CRM貼標回去)，singlesend作為有轉換目標性的發送事件，可以貼標|紀錄即可，影響後面取資料的規則|
|event|delivered: 發送成功<br>open: 開信<br>click: 點擊連結<br>group_unsubscribe:取消訂閱<br>group_resubscribe: 重新訂閱|delivered: 建立EDM活動<br>open: 建立開啟EDM活動<br>click: 建立EDM點擊活動<br>group_unsubscribe: 更新聯絡人取消訂閱時間<br>group_resubscribe: 更新聯絡人訂閱時間|
|category|類似標籤|確認何種情形，加上「EDM_標籤」貼在聯絡人身上|
|asm_group_id|取消訂閱名單ID|應該不用|
|mc_auto_id|Automation ID|作為 Email Event Object ID|
|mc_auto_name|Automation名稱|
|mc_auto_msg_id|信件ID，有版號關係|可以反查automation信件內容，但要錢|
|mc_auto_step_id|屬於Automation的Step ID|
|mc_auto_unique_id|實際上信件的id，每封信不同||
|singlesend_id|Single Send ID|可透過 https://mc.sendgrid.com/single-sends/{{single_send_id}}/stats/preview 連結到SendGrid查看EDM版型，但需要有SG權限。|
|singlesend_name|事件名稱|存在Campaign|
|sg_event_id||
|sg_message_id||(要錢)透過message_id取得信件標題
|template_id|Template ID |https://api.sendgrid.com/v3/templates/{{template_id}} 取回樣板內容，存在Campaign中|
|timestamp|事件時間|用來標註每個事件的時間(GMT+0)，需要轉換成GMT+8|
|bounce|待確認

透過Webhook收取信件發送資訊(Single Send)
```json

[
   {
      "asm_group_id":27632,                    // unsubscribe id
      "category":[                             // 信件標籤
         "Newsletter",
         "Hospitality",
         "Restaraunt",
         "Seasonal",
         "ESG"
      ],
      "email":"jeanc@cw.com.tw",               // Contact PK
      "event":"delivered",                     // 信件事件
      "ip":"149.72.255.128",
      "mc_pod_id":"1",
      "mc_stats":"singlesend",
      "phase_id":"send",
      "response":"250 2.0.0 OK  1717383976 6a1803df08f44-6ae4b43dac6si75518376d6.583 - gsmtp",
      "send_at":"1717383920",                  // 事件時間
      "sg_event_id":"ZGVsaXZlcmVkLTAtNDAyNDk4NzUtVGo4UTV3ZXZUT1cwYUpSTWIzNE1jZy0y",                                             // SendGrid 事件ID
      "sg_message_id":"Tj8Q5wevTOW0aJRMb34Mcg.recvd-6c74bc6469-zhd74-1-665D3328-2.2",                                 // SendGrid Message ID
      "sg_template_id":"d-afdbf83cc4524a54a7478b7804177489",  // Email ID
      "sg_template_name":"Version 2024-06-03T02:26:36.747Z",  // Email 版號
      "singlesend_id":"b735b90f-2150-11ef-aff1-12c635daab1c", // 發送 ID 
      "singlesend_name":"20240602 Single Send-2",             // Email 標題
      "smtp-id":"<Tj8Q5wevTOW0aJRMb34Mcg@geopod-ismtpd-1>",
      "template_hash":"e4f0475cdfa3ad19a1e3a61286b0638e7f42d856cf0dab2b33c0b48cb2bf63ec",
      "template_id":"d-afdbf83cc4524a54a7478b7804177489",
      "template_version_id":"a24885c8-4e90-4bb2-a921-cd13b2ee930c",
      "timestamp":1717383976, // 事件時間戳記
      "tls":1
   },
   {
      "asm_group_id":27632,
      "category":[
         "Newsletter",
         "Hospitality",
         "Restaraunt",
         "Seasonal",
         "ESG"
      ],
      "email":"aman1022@yahoo.com.tw",
      "event":"delivered",
      "ip":"149.72.70.15",
      "mc_pod_id":"1",
      "mc_stats":"singlesend",
      "phase_id":"send",
      "response":"250 ok dirdel",
      "send_at":"1717383920",
      "sg_event_id":"ZGVsaXZlcmVkLTAtNDAyNDk4NzUtVGo4UTV3ZXZUT1cwYUpSTWIzNE1jZy0w",
      "sg_message_id":"Tj8Q5wevTOW0aJRMb34Mcg.recvd-6c74bc6469-zhd74-1-665D3328-2.0",
      "sg_template_id":"d-afdbf83cc4524a54a7478b7804177489",
      "sg_template_name":"Version 2024-06-03T02:26:36.747Z",
      "singlesend_id":"b735b90f-2150-11ef-aff1-12c635daab1c",
      "singlesend_name":"20240602 Single Send-2",
      "smtp-id":"<Tj8Q5wevTOW0aJRMb34Mcg@geopod-ismtpd-1>",
      "template_hash":"e4f0475cdfa3ad19a1e3a61286b0638e7f42d856cf0dab2b33c0b48cb2bf63ec",
      "template_id":"d-afdbf83cc4524a54a7478b7804177489",
      "template_version_id":"a24885c8-4e90-4bb2-a921-cd13b2ee930c",
      "timestamp":1717383979,
      "tls":1
   },
   {
      "asm_group_id":27632,
      "category":[
         "Newsletter",
         "Hospitality",
         "Restaraunt",
         "Seasonal",
         "ESG"
      ],
      "email":"jeanc@cw.com.tw",
      "event":"processed",
      "mc_pod_id":"1",
      "mc_stats":"singlesend",
      "phase_id":"send",
      "send_at":0,
      "sg_event_id":"cHJvY2Vzc2VkLTQwMjQ5ODc1LVRqOFE1d2V2VE9XMGFKUk1iMzRNY2ctMg",
      "sg_message_id":"Tj8Q5wevTOW0aJRMb34Mcg.recvd-6c74bc6469-zhd74-1-665D3328-2.2",
      "sg_template_id":"d-afdbf83cc4524a54a7478b7804177489",
      "sg_template_name":"Version 2024-06-03T02:26:36.747Z",
      "singlesend_id":"b735b90f-2150-11ef-aff1-12c635daab1c",
      "singlesend_name":"20240602 Single Send-2",
      "smtp-id":"<Tj8Q5wevTOW0aJRMb34Mcg@geopod-ismtpd-1>",
      "template_hash":"e4f0475cdfa3ad19a1e3a61286b0638e7f42d856cf0dab2b33c0b48cb2bf63ec",
      "template_id":"d-afdbf83cc4524a54a7478b7804177489",
      "template_version_id":"a24885c8-4e90-4bb2-a921-cd13b2ee930c",
      "timestamp":1717383976
   }
]

```


```json
[
   {
      "asm_group_id":27632,
      "email":"sun1229@gmail.com",
      "event":"open",
      "ip":"74.125.209.5",
      "mc_auto_id":"dfb5cd6b-9851-4c59-b0a3-b319077945ff",
      "mc_auto_msg_id":"25323aa0-6742-4ed5-9d71-6e0da9d11f54",
      "mc_auto_name":"創新學院申請試用 旅程信(New)",
      "mc_auto_step_id":"3b8cba40-8db3-4d85-b26c-d8eb877c7405",
      "mc_auto_unique_id":"8768032dec7fa495",
      "mc_pod_id":"1",
      "mc_stats":"automation",
      "sg_content_type":"html",
      "sg_event_id":"bnkUZjWCS0aHhOxjQ6QLrg",
      "sg_machine_open":false,
      "sg_message_id":"AHGffTkKQi-4XHn7aiwJyg.filterdrecv-698cc84895-8vlbq-1-665D602B-C.0",
      "sg_template_id":"d-4ea6528ec14e4721bc4c9e31caa26bb4",
      "sg_template_name":"Clone: Version 2024-06-03T03:24:52.787Z 2024-06-03T03:50:51.287Z",
      "template_hash":"61de6c6994f20dde07fc5a676357bbc2cd2ca570422c8776d5f09f307cb060c3",
      "template_id":"d-4ea6528ec14e4721bc4c9e31caa26bb4",
      "template_version_id":"1707d1ef-aeda-48a7-9104-20d3e9d94180",
      "timestamp":1717395534,
      "useragent":"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)"
   }
]
```

![image](https://hackmd.io/_uploads/rkVnGloNR.png)


```
// Webhook 資訊



{
    "asm_group_id": 27632,                     // Unsubscribe Group ID
    "email": "shihyen@cw.com.tw",              // Contact Key
    "event": "click",                          // Webhook 事件
    "ip": "59.124.244.160",
    "mc_pod_id": "1",
    "mc_stats": "sendtest",
    "sendtest_id":  "sendtest:40249875:1717381707271665993", 
    "sg_event_id": "Vq_5tlzlQcq-po2LJ8jtWA",
    "sg_message_id": "TosQVJqfTM-SL7UZSjmvWg.recvd-6d78dbc954-ws6bq-1-665D2A4B-9.0",
    "sg_template_id": "d-afdbf83cc4524a54a7478b7804177489",
    "sg_template_name": "Version 2024-06-03T02:26:36.747Z",
    "template_id": "d-afdbf83cc4524a54a7478b7804177489",
    "timestamp": 1717381719,
    "url": "https://www.cw.com.tw",
    "url_offset": {
      "index": 0,
      "type": "html"
    },
    "useragent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
  }
```
