微信小店API /商家客服API /接收消息与事件 /接口定义 /
接收消息和事件
接口说明
当微信客户、接待人员发消息或有行为动作时,商家客服后台会将事件的回调数据包发送到指定URL。
注意事项
- 回调url设置和消息推送规则需参考消息推送文档 ,如果设置的回调url无法访问,商户将无法收微信小店发送的通知;
- 如果已切换API模式,但是没有设置指定URL,事件消息则会丢弃。设置指定URL后,需确保接收消息的服务器是可接收数据的。
- 如果服务器回包数据不符合预期,商家客服后台则会进行消息的重试推送,总重试约3.5小时,共会进行10次消息重试推送。
回调数据说明
参数 | 类型 | 描述 |
ToUserName | string | 小店UserName |
FromUserName | string | 小店用户的OpenID |
CreateTime | number | 事件时间,Unix时间戳,即格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数 |
MsgType | string | 消息类型,固定为 event |
Event | string | 事件类型,本接口固定为 commkf_send_msg_to_kf |
msg_id | string | 用户发送该条消息的所捆绑的单调自增msg_id |
msg_type | string | 消息类型, 参考发送消息中的消息类型 |
msg_event | string | 事件类型 |
text | object | 当 msg_type 为 text时,则会返回text对应消息结构体 |
video | object | 当 msg_type 为 video时,则会返回video对应消息结构体 |
image | object | 当 msg_type 为 image时,则会返回image对应消息结构体 |
file | object | 当 msg_type 为 file时,则会返回file对应消息结构体 |
product_share | object | 当 msg_type 为 product_share时,则会返回product_share对应消息结构体 |
order_share | object | 当 msg_type 为 order_share时,则会返回order_share对应消息结构体 |
支持的消息类型 & 事件类型
消息类型
参数 | 类型 | 描述 |
text | object | msg_type 为 text |
video | object | msg_type 为 video |
image | object | msg_type 为 image |
file | object | msg_type 为 file |
product_share | object | msg_type 为 product_share |
order_share | object | msg_type 为 order_share |
事件类型
参数 | 类型 | 描述 |
EVENT_TYPE_SEND_MSG | object | 用户发送消息时的回调行为 |
结构体
text
参数 | 类型 | 描述 | 字段示例 |
content | string | msg_type 为 text 时,必返回的回报消息 | 测试消息123 |
video
参数 | 类型 | 描述 | 字段示例 |
play_length | uint32 | msg_type 为 video 时,表示返回视频秒数 | 24 |
cos_url | string | msg_type 为 video 时,表示返回视频的可下载cos_url | https://channels.weixin.qq.com/shop/commkf/downloadmedia?encrypted_param=xxxxx×tamp=xxxxx&openid=xxxxxxxxx&msg_type=7 |
ld_img_url | string | msg_type 为 video 时,表示返回视频的封面图 | https://channels.weixin.qq.com/shop/commkf/downloadmedia?encrypted_param=xxxxx×tamp=xxxxx&openid=xxxxxxxxx&msg_type=2 |
image
参数 | 类型 | 描述 | 字段示例 |
cos_url | string | msg_type 为 image 时,表示返回图片的可下载cos_url | https://channels.weixin.qq.com/shop/commkf/downloadmedia?encrypted_param=xxxxx×tamp=xxxxx&openid=xxxxxxxxx&msg_type=2 |
file
参数 | 类型 | 描述 | 字段示例 |
cos_url | string | msg_type 为 file 时,表示返回文件的可下载cos_url | https://channels.weixin.qq.com/shop/commkf/downloadmedia?encrypted_param=xxxxx×tamp=xxxxx&openid=xxxxxxxxx&msg_type=8 |
product_share
参数 | 类型 | 描述 | 字段示例 |
product_id | string | msg_type 为 product_share 时,表示当前用户发送的卡片商品Id | 1000018045xxxx |
order_share
参数 | 类型 | 描述 | 字段示例 |
order_id | string | msg_type 为 order_share 时,表示当前用户发送的卡片订单Id | 3726522601xxxxxxxx |
The translations are provided by WeChat Translation and are for reference only. In case of any inconsistency and discrepancy between the Chinese version and the English version, the Chinese version shall prevail.Incorrect translation. Tap to report.