本文介绍AIMPaaS支持的消息类型,及其字段说明。
消息类型
AIMPaaS支持如下消息类型。
类型 | ContentType参数取值 | 字段说明 |
---|---|---|
文本 | 1 | 文本 |
图片 | 2 | 图片 |
语音 | 3 | 语音 |
短视频 | 4 | 短视频 |
地理位置 | 5 | 地理位置 |
结构化消息(@消息用该类型实现) | 8 | 结构化消息 |
文件 | 9 | 文件 |
引用回复 | 10 | 引用回复 |
合并转发 | 11 | 合并转发 |
自定义 | 101 | 自定义 |
文本
- 字段说明
名称 类型 是否必填 描述 text String 是 文本内容。 - 示例
{ "text": "hello AIMPaaS!" }
图片
- 字段说明
名称 类型 是否必填 描述 mediaId String 是 文件资源ID。 fileType Integer 是 图片类型。取值: - 1:WebP。
- 2:PNG。
- 3:JPG。
- 4:GIF。
orientation Integer 是 图片方向。取值: - 1:normal。
- 2:flip_horizontal。
- 3:rotate_180。
- 4:flip_vertical。
- 5:transpose。
- 6:rotate_90。
- 7:transverse。
- 8:rotate_270。
- 示例
{ "mediaId": "5fcd9defc9bde64a74fe03a194f7****", "fileType": 1, "orientation": 1 }
语音
- 字段说明
名称 类型 是否必填 描述 mediaId String 是 文件资源ID。 duration Integer 是 语音持续时间。单位:秒。 - 示例
{ "mediaId": "5fcd9defc9bde64a74fe03a194f7****", "duration": 8 }
短视频
- 字段说明
名称 类型 是否必填 描述 videoMediaId String 是 视频文件资源ID。 coverMediaId String 是 视频封面图片资源ID。 fileType String 是 文件类型。取文件后缀。 duration Integer 是 视频播放时间。单位:秒。 size Integer 是 视频大小。单位:Byte。 - 示例
{ "videoMediaId": "5fcd9defc9bde64a74fe03a194f7****", "coverMediaId": "38ab0a937884aff569ad92b20fd6****", "duration": 8, "fileType": "avi", "size": 8, }
地理位置
- 字段说明
名称 类型 是否必填 描述 latitude String 是 纬度。 longitude String 是 经度。 mediaId String 否 地理位置封面图片ID。 locationName String 否 位置名称。 - 示例
{ "mediaId": "5fcd9defc9bde64a74fe03a194f7****", "latitude": "123.56", "longitude": "89.78", "locationName":"阿里巴巴西溪园区", }
结构化消息
- 字段说明
名称 类型 是否必填 描述 elements List<Element> 是 信息列表。至少有一个。 elementType Integer 是 信息类型。取值: - 1:文本节点。
- 3:@节点。
elementContent String 是 消息详情。 - 示例
{ "elements": [ { "elementType": 1, //TEXT "elementContent": "{"text":"attext"}" }, { "elementType": 3, //@消息 "elementContent": "{"atAll":false,"appUid":"3687519762"}" } ] }
文件
- 字段说明
名称 类型 是否必填 描述 mediaId String 是 文件资源ID。 fileName String 是 文件名。 fileType String 否 文件类型。 fileSize Integer 是 文件大小。单位:Byte。 - 示例
{ "fileName": "test.txt", "fileSize": 100, "fileType": "txt", "mediaId": "mediaId****" }
引用回复
引用回复消息包括被引用的消息和回复的消息内容。
- 字段说明
名称 类型 是否必填 描述 referenceMessage Object 是 消息的基础信息。 senderId String 是 发送者用户ID。 appCid String 是 会话ID。 createTime Long 是 消息发送时间。时间戳,单位:毫秒。 msgId String 是 消息ID。 referenceContent Json 是 引用的内容。 contentType Integer 是 引用的消息内容类型。支持如下类型:
- 1:文本。
- 2:图片。
- 3:语音。
- 4:短视频。
- 5:地理位置。
- 8:结构化消息。
- 9:文件。
- 101:自定义。
textContent Json 否 引用消息的内容。当contentType为文本,需要填充textContent字段。 imageContent Json 否 引用消息的内容。当contentType为图片,需要填充imageContent字段。 audioContent Json 否 引用消息的内容。当contentType为语音,需要填充audioContent字段。 videoContent Json 否 引用消息的内容。当contentType为视频,需要填充videoContent字段 geoContent Json 否 引用消息的内容。当contentType为地理位置,需要填充geoContent字段 structContent Json 否 引用消息的内容。当contentType为结构化消息,需要填充structContent字段 fileContent Json 否 引用消息的内容。当contentType为文件类型,需要填充fileContent字段 customContent Json 否 引用消息的内容。当contentType为自定义消息,需要填充customContent字段 extensions Map 否 引用消息扩展字段。 String 否 扩展字段内容。{"key": "value"}。 replyContent Object 是 回复消息的内容。 contentType Integer 是 回复的消息内容类型。支持如下类型: - 1:文本。
- 2:图片。
- 3:语音。
- 4:短视频。
- 5:地理位置。
- 8:结构化消息。
- 9:文件。
- 101:自定义。
textContent Json 否 回复消息的内容。当contentType为文本,需要填充textContent字段。 imageContent Json 否 回复消息的内容。当contentType为图片,需要填充imageContent字段。 audioContent Json 否 回复消息的内容。当contentType为语音,需要填充audioContent字段。 videoContent Json 否 回复消息的内容。当contentType为视频,需要填充videoContent字段。 geoContent Json 否 回复消息的内容。当contentType为地理位置,需要填充geoContent字段。 structContent Json 否 回复消息的内容。当contentType为结构化消息,需要填充structContent字段。 fileContent Json 否 回复消息的内容。当contentType为文件类型,需要填充fileContent字段。 customContent Json 否 回复消息的内容。当contentType为自定义消息,需要填充customContent字段 - 示例
{ "referenceMessage": { //引用的消息 "senderId": "950000010", "appCid": "950000010:950000011", "createTime": 1611633529910, "msgId": "28016557510.center_daily****", "referenceContent": { //引用消息的内容,contentType不能为引用回复和合并转发类型 "contentType": 1, "textContent": { "text": "reference message" } }, "extensions": {"key": "value"} }, "replyContent": { //回复消息的内容,contentType不能为引用回复和合并转发类型 "contentType": 1, "textContent": { "text": "reply message" } } }
合并转发
- 字段说明
名称 类型 是否必填 描述 senderId String 是 发送者用户ID。 appCid String 是 会话ID。 createTime Long 是 消息发送时间。时间戳,单位:毫秒。 msgId String 是 消息ID。 combineForwardContent Object 是 合并转发的消息内容。 contentType Integer 是 转发的消息内容类型。支持如下类型:
- 1:文本。
- 2:图片。
- 3:语音。
- 4:短视频。
- 5:地理位置。
- 8:结构化消息。
- 9:文件。
- 101:自定义。
textContent Json 否 转发消息的内容。当contentType为文本,需要填充textContent字段。 imageContent Json 否 转发消息的内容。当contentType为图片,需要填充imageContent字段。 audioContent Json 否 转发消息的内容。当contentType为语音,需要填充audioContent字段。 videoContent Json 否 转发消息的内容。当contentType为视频,需要填充videoContent字段 geoContent Json 否 转发消息的内容。当contentType为地理位置,需要填充geoContent字段 structContent Json 否 转发消息的内容。当contentType为结构化消息,需要填充structContent字段 fileContent Json 否 转发消息的内容。当contentType为文件类型,需要填充fileContent字段 customContent Json 否 转发消息的内容。当contentType为自定义消息,需要填充customContent字段 extensions Map 否 转发消息扩展字段。 String 否 扩展字段内容。{"key": "value"}。 - 示例
{ "combineForwardMessages": [ { "senderId": "950000010", "appCid": "950000010:950000011", "msgId": "28016557516.center_daily", "createTime": 1611633930317, "combineForwardContent": { "contentType": 1, //contentType不能是合并转发 "textContent": { "text": "test combine forward" } }, "extensions": { "key": "value" } }, { "senderId": "950000010", "appCid": "950000010:950000011", "msgId": "28016557517.center_daily", "createTime": 1611633930984, "combineForwardContent": { "contentType": 2, "imageContent": { "fileType": 1, "mediaId": "mediaId", "orientation": 0 } }, "extensions": { "key": "value" } } ] }
自定义
- 字段说明
名称 类型 是否必填 描述 type Integer 是 自定义消息子类型。 data String 是 自定义消息数据。 - 示例
{ "type": 123, "data": "{}" }