Azure 通訊服務 - 進階傳訊事件
本文提供通訊服務進階傳訊事件的屬性和結構描述。 如需事件結構描述的簡介,請參閱 Azure Event Grid 事件結構描述。
事件類型
Azure 通訊服務會發出下列進階傳訊事件類型:
事件回應
觸發事件時,事件方格服務會將該事件的相關資料傳送至訂閱端點。
本節包含每個事件該數據外觀的範例。
Microsoft.Communication.AdvancedMessageReceived event
當通訊服務進階傳訊收到訊息時發佈。
範例案例:WhatsApp 使用者會將 WhatsApp 訊息傳送至 WhatsApp Business 號碼,該號碼會連線到通訊服務資源中的作用中進階傳訊通道。 因此,會發佈含有使用者的 WhatsApp 訊息內容的 Microsoft.Communication.AdvancedMessageReceived
。
屬性清單
Microsoft.Communication.AdvancedMessageReceived
事件特有的屬性詳細資料。
屬性 |
類型 |
Nullable |
描述 |
channelType |
string |
❌ |
用於傳送訊息之通道的通道類型。 例如: "whatsapp" 。 |
messageId |
string |
❌ |
訊息接收事件的訊息標識碼作為 GUID。 |
messageType |
string |
❌ |
訊息接收事件的訊息類型。 例如: "interactive" 、 "sticker" 、 "reaction" 。 |
寄件者 |
string |
❌ |
傳送訊息的傳送者識別碼。 |
打給 |
string |
❌ |
接收訊息的通道識別碼,其格式為 GUID。 |
receivedTimestamp |
DateTimeOffset |
❌ |
收到訊息時的時間戳。 |
content |
string |
✔️ |
訊息中的文字內容。 |
媒體 |
MediaContent |
✔️ |
包含所接收 媒體的詳細數據。 |
內容 |
MessageContext |
✔️ |
包含使用者回復至商務訊息時,回復 訊息內容 的詳細數據。 |
按鈕 |
ButtonContent |
✔️ |
包含針對範本訊息選取之回復按鈕內容使用者的詳細數據。 |
互動式 |
InteractiveContent |
✔️ |
包含互動式訊息回應的詳細數據,例如 buttonReply 或 listReply |
反應 |
ReactionContent |
✔️ |
包含有關透過商務傳送訊息接收 之回應 的詳細數據。 |
MediaContent
屬性 |
類型 |
Nullable |
描述 |
mimeType |
string |
❌ |
媒體的 MIME 類型。 用於判斷媒體下載的正確檔案類型。 |
識別碼 |
string |
❌ |
媒體識別碼。 用於擷取媒體進行下載,其格式為 GUID。 |
fileName |
string |
✔️ |
上傳時所指定之基礎媒體檔案的檔名。 |
標題 |
string |
✔️ |
媒體物件的字幕文字 (如果支援並提供)。 |
動畫 |
string |
✔️ |
如果貼紙為動畫,則設定為 true;否則為 false。 |
MessageContext
屬性 |
類型 |
Nullable |
描述 |
from |
string |
✔️ |
回覆內送訊息之客戶的 WhatsApp 識別碼。 |
識別碼 |
string |
✔️ |
針對內送回覆所傳送訊息的訊息識別碼。 |
ButtonContent
屬性 |
類型 |
Nullable |
描述 |
text |
string |
✔️ |
按鈕的文字。 |
承載 |
string |
✔️ |
使用者所選取按鈕的承載 (由企業設定)。 |
InteractiveContent
InteractiveReplyType
值 |
Description |
buttonReply |
此互動式內容是一個按鈕。 |
listReply |
此互動式內容是一個清單。 |
未知 |
此互動式內容不明。 |
InteractiveButtonReplyContent
屬性 |
類型 |
Nullable |
描述 |
識別碼 |
string |
✔️ |
按鈕的識別碼。 |
title |
string |
✔️ |
按鈕的標題。 |
InteractiveListReplyContent
屬性 |
類型 |
Nullable |
描述 |
識別碼 |
string |
✔️ |
所選清單項目的識別碼。 |
title |
string |
✔️ |
所選清單項目的標題。 |
description |
string |
✔️ |
所選資料列的描述。 |
ReactionContent
屬性 |
類型 |
Nullable |
描述 |
messageId |
string |
❌ |
使用者回復的訊息識別碼。 |
emoji |
string |
✔️ |
字串,表示 emoji 的 Unicode 逸出序列。 |
範例
收到的文字訊息
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
"subject": "advancedMessage/sender/{sender@id}/recipient/11111111-1111-1111-1111-111111111111",
"data": {
"content": "Hello",
"channelType": "whatsapp",
"messageType": "text",
"from": "{sender@id}",
"to": "{channel-id}",
"receivedTimestamp": "2023-07-06T18:30:19+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageReceived",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2023-07-06T18:30:22.1921716Z"
}]
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
"subject": "advancedMessage/sender/{sender@id}/recipient/11111111-1111-1111-1111-111111111111",
"data": {
"channelType": "whatsapp",
"messageType": "image",
"media": {
"mimeType": "image/jpeg",
"id": "00000000-0000-0000-0000-000000000000",
"caption": "This is a media caption"
},
"from": "{sender@id}",
"to": "{channel-id}",
"receivedTimestamp": "2023-07-06T18:30:19+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageReceived",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2023-07-06T18:30:22.1921716Z"
}]
{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/acs-cpm-ppe-resources/providers/microsoft.communication/communicationservices/acscpm-whatsup-pperesource",
"subject": "advancedMessage/sender/14254360097/recipient/75476a19-a68d-4e10-806c-3680f099e069",
"data": {
"channelType": "whatsapp",
"messageType": "document",
"media": {
"mimeType": "application/pdf",
"id": "00000000-0000-0000-0000-000000000000",
"fileName": "UTSAV Mela 2024 India's Independence Day Kids Out and About Seattle.pdf"
},
"from": "14254360097",
"to": "{channel-id}",
"receivedTimestamp": "2024-12-24T06:41:56+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageReceived",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2024-12-24T06:41:59.1218953Z"
}
列出使用 InteractiveListReplyContent 接收的回覆訊息
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
"subject": "advancedMessage/sender/{sender@id}/recipient/00000000-0000-0000-0000-000000000000",
"data": {
"channelType": "whatsapp",
"messageType": "interactive",
"context": {
"from": "{receiverphonenumber@id}",
"id": "{reply-message-id}"
},
"interactive": {
"type": "listReply",
"listReply": {
"id": "priority_mail",
"title": "Priority Mail",
"description": "1–3 Days"
}
},
"from": "{sender@id}",
"to": "{channel-id}",
"receivedTimestamp": "2024-12-04T23:53:28+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageReceived",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2024-12-04T23:53:29.3079089Z"
}]
使用 InteractiveButtonReplyContent 接收的回覆按鈕訊息
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
"subject": "advancedMessage/sender/{sender@id}/recipient/00000000-0000-0000-0000-000000000000",
"data": {
"channelType": "whatsapp",
"messageType": "interactive",
"context": {
"from": "{receiverphonenumber@id}",
"id": "{reply-message-id}"
},
"interactive": {
"type": "buttonReply",
"buttonReply": {
"id": "agree",
"title": "Agree"
}
},
"from": "{sender@id}",
"to": "{channel-id}",
"receivedTimestamp": "2024-12-04T23:57:04+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageReceived",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2024-12-04T23:57:04.9459858Z"
}]
已接收回復貼紙訊息
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
"subject": "advancedMessage/sender/{sender@id}/recipient/00000000-0000-0000-0000-000000000000",
"data": {
"channelType": "whatsapp",
"messageType": "sticker",
"media": {
"mimeType": "image/webp",
"id": "00000000-0000-0000-0000-000000000000",
"animated": false
},
"from": "{sender@id}",
"to": "{channel-id}",
"receivedTimestamp": "2024-12-04T23:57:04+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageReceived",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2024-12-04T23:57:04.9459858Z"
}]
已接收回復反應訊息
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
"subject": "advancedMessage/sender/{sender@id}/recipient/00000000-0000-0000-0000-000000000000",
"data": {
"channelType": "whatsapp",
"messageType": "reaction",
"reaction": {
"messageId": "{reply-message-id}",
"emoji": "👍"
},
"from": "{sender@id}",
"to": "{channel-id}",
"receivedTimestamp": "2024-12-04T23:57:04+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageReceived",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2024-12-04T23:57:04.9459858Z"
}]
已接收 ButtonContent 訊息
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
"subject": "advancedMessage/sender/{sender@id}/recipient/00000000-0000-0000-0000-000000000000",
"data": {
"channelType": "whatsapp",
"messageType": "button",
"context": {
"from": "{receiverphonenumber@id}",
"id": "{reply-message-id}"
},
"button": {
"text": "Yes",
"payload": "Kat said yes"
},
"from": "{sender@id}",
"to": "{channel-id}",
"receivedTimestamp": "2024-12-20T04:03:22+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageReceived",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2024-12-20T04:03:22.7978135Z"
}]
Microsoft.Communication.AdvancedMessageDeliveryStatusUpdated event
當通訊服務進階傳訊收到先前所傳送訊息通知的狀態更新時發佈。
範例案例:Contoso 使用連線至 WhatsApp Business 帳戶的作用中進階傳訊通道,將 WhatsApp 訊息傳送給 WhatsApp 使用者。 WhatsApp 接著會以先前所傳送訊息的狀態回覆 Contoso 的進階傳訊通道。 因此,會發佈含有訊息狀態的 Microsoft.Communication.AdvancedMessageDeliveryStatusUpdated
事件。
屬性清單
Microsoft.Communication.AdvancedMessageReceived
事件特有的屬性詳細資料。
屬性 |
類型 |
Nullable |
描述 |
channelType |
string |
❌ |
用於傳送訊息之通道的通道類型。 |
寄件者 |
string |
❌ |
傳送訊息的通道識別碼,其格式為 GUID。 |
打給 |
string |
❌ |
訊息傳送至的收件者識別碼。 |
receivedTimestamp |
DateTimeOffset |
❌ |
訊息的時間戳。 |
messageId |
string |
✔️ |
訊息的識別碼,其格式為 GUID。 |
status |
string |
✔️ |
訊息狀態。 可能的值包括:Sent 、Delivered 、Read 和 Failed 。 如需詳細資訊,請參閱狀態。 |
error |
ChannelEventError |
✔️ |
包含錯誤的詳細資料。 |
ChannelEventError
屬性 |
類型 |
Nullable |
描述 |
channelCode |
string |
✔️ |
在此通道上收到的錯誤碼。 |
channelMessage |
string |
✔️ |
在此通道上收到的錯誤訊息。 |
狀態
值 |
Description |
寄件備份 |
傳訊服務會將訊息傳送給收件者 |
已送達 |
訊息收件者收到訊息 |
參閱 |
訊息收件者讀取訊息 |
失敗 |
訊息無法正確傳送 |
範例
訊息傳遞的更新
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/{communication-services-resource-name}",
"subject": "advancedMessage/22222222-2222-2222-2222-222222222222/status/Sent",
"data": {
"messageId": "22222222-2222-2222-2222-222222222222",
"status": "Sent",
"channelType": "whatsapp",
"from": "{sender@id}",
"to": "{receiver@id}",
"receivedTimestamp": "2023-07-06T18:42:28+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageDeliveryStatusUpdated",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2023-07-06T18:42:28.8454662Z"
}]
訊息傳遞失敗的更新
[{
"id": "00000000-0000-0000-0000-000000000000",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/acsxplatmsg-test",
"subject": "advancedMessage/22222222-2222-2222-2222-222222222222/status/Failed",
"data": {
"messageId": "22222222-2222-2222-2222-222222222222",
"status": "Failed",
"channelType": "whatsapp",
"from": "{sender@id}",
"to": "{receiver@id}",
"receivedTimestamp": "2023-07-06T18:42:28+00:00",
"error": {
"channelCode": "131026",
"channelMessage": "Message Undeliverable."
}
},
"eventType": "Microsoft.Communication.AdvancedMessageDeliveryStatusUpdated",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2023-07-06T18:42:28.8454662Z"
}]
Microsoft.Communication.AdvancedMessageAnalysisCompleted(預覽) 事件
當通訊服務使用客戶訊息完成 AI 分析時發布。
範例案例:WhatsApp 使用者會將訊息傳送至連線至通訊服務資源中主動式進階傳訊通道的 WhatsApp Business Number,該通道選擇加入訊息分析功能。 因此,系統會使用使用者的 WhatsApp 訊息分析來發佈 Microsoft.Communication.AdvancedMessageAnalysisCompleted
。
屬性清單
Microsoft.Communication.AdvancedMessageAnalysisCompleted
事件特有的屬性詳細資料。
屬性 |
類型 |
Nullable |
描述 |
channelType |
string |
✔️ |
用於傳送訊息之通道的通道類型。 |
寄件者 |
string |
✔️ |
傳送訊息的通道識別碼,其格式為 GUID。 |
打給 |
string |
✔️ |
訊息傳送至的收件者識別碼。 |
receivedTimestamp |
DateTimeOffset |
✔️ |
訊息的時間戳。 |
originalMessage |
string |
✔️ |
原始使用者訊息。 |
intentAnalysis |
string |
✔️ |
已接收使用者訊息的意圖分析。 |
languageDetection |
LanguageDetection |
✔️ |
包含所接收使用者訊息的語言偵測。 |
extractedKeyPhrases |
List<string> |
✔️ |
包含已接收使用者訊息的關鍵片語。 |
LanguageDetection
屬性 |
類型 |
Nullable |
描述 |
語言 |
string |
✔️ |
偵測到的語言。 |
confidenceScore |
float |
✔️ |
偵測到之語言的信賴分數。 |
翻譯 |
string |
✔️ |
訊息轉譯。 |
範例
訊息分析已完成
[{
"id": "df1c2d92-6155-4ad7-a865-cb8497106c52",
"topic": "/subscriptions/{subscription-id}/resourcegroups/{resourcegroup-name}/providers/microsoft.communication/communicationservices/acsxplatmsg-test",
"subject": "advancedMessage/sender/{sender@id}/recipient/00000000-0000-0000-0000-000000000000",
"data": {
"originalMessage": "Hello, could u help me order some flowers for Mother’s Day?",
"channelType": "whatsapp",
"languageDetection": {
"language": "English",
"confidenceScore": 0.99
},
"intentAnalysis": "Order request: The customer is contacting customer service to request assistance with ordering flowers for Mother's Day.",
"extractedKeyPhrases": [
"order",
"flowers",
"Mother's Day"
],
"from": "{sender@id}",
"to": "00000000-0000-0000-0000-000000000000",
"receivedTimestamp": "2024-07-05T19:10:35.28+00:00"
},
"eventType": "Microsoft.Communication.AdvancedMessageAnalysisCompleted",
"dataVersion": "1.0",
"metadataVersion": "1",
"eventTime": "2024-07-05T19:10:35.2806524Z"
}]
快速入門
如需快速入門,了解如何使用 Webhook 訂閱進階傳訊事件,請參閱快速入門:處理進階傳訊事件。