你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Azure 通信服务 - 高级消息事件
本文提供了通信服务高级消息传递事件的属性和架构。 有关事件架构的简介,请参阅 Azure 事件网格事件架构。
事件类型
Azure 通信服务可发出以下高级消息事件类型:
事件类型 | 说明 |
---|---|
Microsoft.Communication.AdvancedMessageReceived | 当通信服务高级消息传递收到消息时发布。 |
Microsoft.Communication.AdvancedMessageDeliveryStatusUpdated | 当通信服务高级消息传递收到以前发送的消息通知的状态更新时发布。 |
Microsoft.Communication.AdvancedMessageAnalysisCompleted(Preview) | 在通信服务完成 AI 分析时与客户消息一起发布。 |
事件响应
触发某个事件后,事件网格服务会将有关该事件的数据发送到订阅终结点。
本部分包含每个事件的数据外观示例。
Microsoft.Communication.AdvancedMessageReceived 事件
当通信服务高级消息传递收到消息时发布。
示例应用场景:WhatsApp 用户向一个 WhatsApp Business 号码发送了一条 WhatsApp 消息,该号码连接到通信服务资源中的活动高级消息传递通道。 因此,将发布 Microsoft.Communication.AdvancedMessageReceived
以及用户的 WhatsApp 消息内容。
属性列表
特定于 Microsoft.Communication.AdvancedMessageReceived
事件的属性的详细信息。
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
channelType | string |
❌ | 发送消息的通道的通道类型。 例如:"whatsapp" 。 |
messageId | string |
❌ | 消息接收事件的消息 ID (GUID)。 |
messageType | string |
❌ | 消息接收事件的消息类型。 例如:"interactive" 、"sticker" 、"reaction" 。 |
发件人 | string |
❌ | 发送消息的发送方 ID。 |
接收方 | string |
❌ | 接收消息的通道 ID,格式为 GUID。 |
receivedTimestamp | DateTimeOffset |
❌ | 收到消息时的时间戳。 |
content | string |
✔️ | 消息中的文本内容。 |
媒体 | MediaContent |
✔️ | 包含有关所接收媒体的详细信息。 |
上下文 | MessageContext |
✔️ | 包含有关回复消息上下文的详细信息,以防用户回复业务消息。 |
按钮 | ButtonContent |
✔️ | 包含用户为模板消息选择的回复按钮内容的详细信息。 |
交互 | InteractiveContent |
✔️ | 包含有关交互式消息响应的详细信息,例如 buttonReply 或 listReply |
回应 | ReactionContent |
✔️ | 包含有关通过业务发送消息收到的回应的详细信息。 |
MediaContent
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
mimeType | string |
❌ | 媒体的 MIME 类型。 用于确定媒体下载的正确文件类型。 |
ID | string |
❌ | 媒体 ID。 用于检索要下载的媒体,格式为 GUID。 |
fileName | string |
✔️ | 上传时指定的基础媒体文件的文件名。 |
caption | string |
✔️ | 媒体对象的描述文字(如果受支持并提供)。 |
动画 | string |
✔️ | 如果贴纸是动画,则设置为 true;否则设置为 false。 |
MessageContext
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
from | string |
✔️ | 回复入站消息的客户的 WhatsApp ID。 |
ID | string |
✔️ | 入站回复的已发送消息的消息 ID。 |
ButtonContent
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
text | string |
✔️ | 按钮的文本。 |
payload | string |
✔️ | 用户选择的按钮的有效负载,由企业设置。 |
InteractiveContent
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
type | InteractiveReplyType |
✔️ | 交互式内容的类型。 |
buttonReply | InteractiveButtonReplyContent |
✔️ | 当客户选择按钮时发送。 |
listReply | InteractiveListReplyContent |
✔️ | 当客户从列表中选择项目时发送。 |
InteractiveReplyType
值 | 说明 |
---|---|
buttonReply | 交互式内容是一个按钮。 |
listReply | 交互式内容是一个列表。 |
未知 | 交互式内容未知。 |
InteractiveButtonReplyContent
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
ID | string |
✔️ | 按钮的 ID。 |
title | string |
✔️ | 按钮的标题。 |
InteractiveListReplyContent
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
ID | string |
✔️ | 所选列表项的 ID。 |
title | string |
✔️ | 所选列表项的标题。 |
description | string |
✔️ | 所选行的说明。 |
ReactionContent
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
messageId | string |
❌ | 用户回复的消息 ID。 |
表情符号 | string |
✔️ | 表示表情符号的 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 事件
当通信服务高级消息传递收到以前发送的消息通知的状态更新时发布。
示例应用场景:Contoso 使用连接到 WhatsApp Business 帐户的活动高级消息传递通道向 WhatsApp 用户发送了一条 WhatsApp 消息。 然后,WhatsApp 回复 Contoso 的高级消息传递通道,其中包含以前发送的消息的状态。 因此,将发布包含消息状态的 Microsoft.Communication.AdvancedMessageDeliveryStatusUpdated
事件。
属性列表
特定于 Microsoft.Communication.AdvancedMessageReceived
事件的属性的详细信息。
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
channelType | string |
❌ | 发送消息的通道的通道类型。 |
发件人 | string |
❌ | 发送消息的通道 ID,格式为 GUID。 |
接收方 | string |
❌ | 消息发送到的接收方 ID。 |
receivedTimestamp | DateTimeOffset |
❌ | 消息的时间戳。 |
messageId | string |
✔️ | 消息的 ID,格式为 GUID。 |
status | string |
✔️ | 消息的状态。 可能的值包括 Sent 、Delivered 、Read 和 Failed 。 有关详细信息,请参阅 Status。 |
error | ChannelEventError |
✔️ | 包含错误的详细信息。 |
ChannelEventError
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
channelCode | string |
✔️ | 在此通道上收到的错误代码。 |
channelMessage | string |
✔️ | 在此通道上收到的错误消息。 |
Status
值 | 说明 |
---|---|
已发送 | 消息传送服务已将消息发送给接收方 |
已交货 | 消息接收方已收到消息 |
读取 | 消息接收方已阅读消息 |
已失败 | 消息无法正确发送 |
示例
消息传递更新
[{
"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(Preview) 事件
在通信服务完成 AI 分析时与客户消息一起发布。
示例场景:WhatsApp 用户向一个 WhatsApp Business 号码发送了一条消息,该号码连接到已选择启用消息分析功能的通信服务资源中的活动高级消息传递通道。 因此,系统发布 Microsoft.Communication.AdvancedMessageAnalysisCompleted
以及对用户 WhatsApp 消息的分析。
属性列表
特定于 Microsoft.Communication.AdvancedMessageAnalysisCompleted
事件的属性的详细信息。
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
channelType | string |
✔️ | 发送消息的通道的通道类型。 |
发件人 | string |
✔️ | 发送消息的通道 ID,格式为 GUID。 |
接收方 | string |
✔️ | 消息发送到的接收方 ID。 |
receivedTimestamp | DateTimeOffset |
✔️ | 消息的时间戳。 |
originalMessage | string |
✔️ | 原始用户消息。 |
intentAnalysis | string |
✔️ | 接收的用户消息的意向分析。 |
languageDetection | LanguageDetection |
✔️ | 包含接收的用户消息的语言检测。 |
extractedKeyPhrases | List<string> |
✔️ | 包含接收的用户消息的关键短语。 |
LanguageDetection
属性 | 类型 | 可为空值 | 说明 |
---|---|---|---|
语言 | 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 订阅高级消息事件的快速入门,请参阅《快速入门:处理高级消息事件》。