用户向客服发送文本消息
POST https://webapi.kf5.com/kchat/message
Body 参数:
| Name | Required | Type | Comment |
|---|---|---|---|
| action | 是 | string | 操作名称,chat |
| message | 是 | object | 消息信息 |
| message.id | 否 | string|integer | 消息在客户自己系统中的 id |
| message.type | 是 | string | 消息的类型,文本消息为 text |
| message.to_user | 否 | integer | 接收消息的客服 id |
| message.from_user | 是 | string|integer | 用户在客户自己系统或第三方系统中的用户 id,即用户 openid |
| message.is_robot | 否 | boolean | 是否发送和机器人的对话消息 |
| message.content | 是 | string | 消息的文本内容 |
| message.create_time | 是 | integer | 消息的发送时间,秒级别时间戳 |
备注:发送消息给客服需要先创建对话,发送和机器人的对话消息则不需要创建对话,带上用户信息直接发送即可,如果确定用户已存在则不必每次都带上用户信息。
请求示例:
// 发送消息给客服
{
"action": "chat",
"message": {
"id": 181578717,
"type": "text",
"to_user": 6452832,
"from_user": "e4d8c2abfc783e0b8f0d7b4eb93812e5",
"content": "你好,有个问题需要咨询一下",
"create_time": 1480433249
}
}
// 发送机器人对话消息
{
"action": "chat",
"user": {
"name": "小刘",
"openid": "e4d8c2abfc783e0b8f0d7b4eb93812e5"
},
"message": {
"id": 181578717,
"type": "text",
"from_user": "e4d8c2abfc783e0b8f0d7b4eb93812e5",
"is_robot": true,
"content": "文档",
"create_time": 1480433249
}
}返回示例:
{
"error_code": 0,
"message": "请求成功"
} 