5G消息格式
# 简介
消息分为上行消息与下行消息,上行消息指终端到chatbot的消息,下行消息指chatbot到终端的消息。
下行消息可发送 文本消息,地理信息回落,文件消息,单/多卡片消息。每类消息均可与建议回复消息组合
如:文本消息 + 建议回复
```json
[
{
"contentType": "text/plain",
"contentText": "你好"
},
{
"contentType": "application/vnd.gsma.botsuggestion.v1.0+json",
"contentEncoding": "utf8",
"contentText": {
"suggestions": [
{
"reply": {
"displayText": "建议回复1",
"postback": {
"data": "r1"
}
}
},
{
"reply": {
"displayText": "建议回复2",
"postback": {
"data": "r2"
}
}
},
{
"reply": {
"displayText": "建议回复3",
"postback": {
"data": "r3"
}
}
}
]
}
}
]
```
# 消息类型
- text/plain 文本/地理信息回落消息
- application/vnd.gsma.rcs-ft-http 文件消息
- application/vnd.gsma.botmessage.v1.0+json 卡片消息
- application/vnd.gsma.botsuggestion.v1.0+json 建议回复消息
- application/vnd.gsma.botsuggestion.response.v1.0+json 建议回复上行消息
- application/vnd.gsma.botsharedclientdata.v1.0+json 终端共享信息消息
# 规范
JSON schema 详情可参照RCC.07
[RCC07](https://www.gsma.com/newsroom/wp-content/uploads//RCC.07-v12.0-5.pdf)
# 各消息样例
## 1. 文本消息
样例:
```json
{
"contentType": "text/plain",
"contentText": "你好"
}
```
## 2. 地理信息回落
样例:
```json
{
"contentType": "text/plain",
"contentEncoding": "utf8",
"contentText": "geo:22.5385,114.0572;crs=gcj02;rcs-l=%E7%A6%8F%E7"
}
```
## 3. 文件消息
样例
```json
{
"contentType": "application/vnd.gsma.rcs-ft-http",
"contentText": [
{
"url": "https://httpserver01.ct5g.cn:10001/s/03261650151121410080100038FD.jpg",
"type": "file",
"contentType": "image/jpeg",
"until": "2021-03-29T16:50:16.000+08:00",
"fileSize": 916755
},
{
"url": "https://httpserver01.ct5g.cn:10001/s/03261650151121410080100038TD",
"type": "thumbnail",
"contentType": "image/jpeg",
"until": "2021-03-29T16:50:16.000+08:00",
"fileSize": 6309
}
]
}
```
## 4. 单卡片消息
样例
```json
{
"contentType": "application/vnd.gsma.botmessage.v1.0+json",
"contentEncoding": "utf8",
"contentText": {
"message": {
"generalPurposeCard": {
"layout": {
"cardOrientation": "VERTICAL"
},
"content": {
"media": {
"mediaUrl": "https://xx.png",
"mediaContentType": "image/png",
"mediaFileSize": 1895,
"height": "MEDIUM_HEIGHT",
"thumbnailUrl": "https://xx.png",
"thumbnailContentType": "image/png",
"thumbnailFileSize": 3020,
"contentDescription": "电费.png"
},
"title": "标题",
"description": "内容",
"suggestions": [
{
"reply": {
"displayText": "建议回复",
"postback": {
"data": "reply"
}
}
}
]
}
}
}
}
}
```
## 5. 多卡片消息
样例
```json
{
"contentType": "application/vnd.gsma.botmessage.v1.0+json",
"contentEncoding": "utf8",
"contentText": {
"message": {
"generalPurposeCardCarousel": {
"layout": {
"cardWidth": "MEDIUM_WIDTH"
},
"content": [
{
"media": {
"mediaUrl": "https://maap.png",
"mediaContentType": "image/png",
"mediaFileSize": 1782,
"height": "MEDIUM_HEIGHT",
"thumbnailUrl": "https://maap4.png",
"thumbnailContentType": "image/png",
"thumbnailFileSize": 3213,
"contentDescription": "m.png"
},
"title": "标题1",
"description": "内容1",
"suggestions": [
{
"action": {
"urlAction": {
"openUrl": {
"url": "",
"application": "browser"
}
},
"displayText": "建议回复",
"postback": {
"data": "reply"
}
}
}
]
},
{
"media": {
"mediaUrl": "https://maap488.png",
"mediaContentType": "image/png",
"mediaFileSize": 1782,
"height": "MEDIUM_HEIGHT",
"thumbnailUrl": "https://m04.png",
"thumbnailContentType": "image/png",
"thumbnailFileSize": 3213,
"contentDescription": "m.png"
},
"title": "标题2",
"description": "内容2",
"suggestions": [
{
"reply": {
"displayText": "建议回复",
"postback": {
"data": "reply"
}
}
}
]
},
{
"media": {
"mediaUrl": "https://maa8.png",
"mediaContentType": "image/png",
"mediaFileSize": 1782,
"height": "MEDIUM_HEIGHT",
"thumbnailUrl": "https://maa04.png",
"thumbnailContentType": "image/png",
"thumbnailFileSize": 3213,
"contentDescription": "x.png"
},
"title": "标题2",
"description": "内容2",
"suggestions": [
{
"reply": {
"displayText": "建议回复",
"postback": {
"data": "reply"
}
}
}
]
}
]
}
}
}
}
```
## 6. 建议回复消息
样例
```json
{
"contentType": "application/vnd.gsma.botsuggestion.v1.0+json",
"contentEncoding": "utf8",
"contentText": {
"suggestions": [
{
"reply": {
"displayText": "建议回复1",
"postback": {
"data": "r1"
}
}
},
{
"reply": {
"displayText": "建议回复2",
"postback": {
"data": "r2"
}
}
},
{
"reply": {
"displayText": "建议回复3",
"postback": {
"data": "r3"
}
}
}
]
}
}
```
## 7. 建议回复消息回传
样例
```json
{
"contentType": "application/vnd.gsma.botsuggestion.response.v1.0+json",
"contentText": {
"response": {
"reply": {
"displayText": "主页",
"postback": {
"data": "reply_home"
}
}
}
}
}
```
## 8. 终端共享信息回传
样例
```json
```