# 客服消息事件

本文档描述服务器端接收的消息或事件,详细说明参见消息推送

事件英文名:commkf_send_msg_to_kf

当微信客户、接待人员发消息或有行为动作时,商家客服后台会将事件的回调数据包发送到指定URL。

相关 API 接口:

相关开发指南:

# 1. 消息参数

# 请求体 Request Payload

参数名类型说明
ToUserNamestring小店UserName
FromUserNamestring小店用户的OpenID
CreateTimenumber事件时间,Unix时间戳,即格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数
MsgTypestring消息类型,固定为 event
Eventstring事件类型,本接口固定为 commkf_send_msg_to_kf
msg_idstring用户发送该条消息的所捆绑的单调自增msg_id
msg_typeobject消息类型, 参考发送消息中的消息类型
msg_eventobject事件类型
textobject当msg_type为text时,则会返回text对应消息结构体
videoobject当msg_type为video时,则会返回video对应消息结构体
imageobject当msg_type为image时,则会返回image对应消息结构体
fileobject当msg_type为file时,则会返回file对应消息结构体
product_shareobject当msg_type为product_share时,则会返回product_share对应消息结构体
order_shareobject当msg_type为order_share时,则会返回order_share对应消息结构体
voiceobject当msg_type为voice时,则会返回voice对应消息结构体

# Body.msg_type Object Payload

消息类型, 参考发送消息中的消息类型

参数名类型说明
textobjectmsg_type为text
videoobjectmsg_type为video
imageobjectmsg_type为image
fileobjectmsg_type为file
product_shareobjectmsg_type为product_share
order_shareobjectmsg_type为order_share
voiceobjectmsg_type为voice

# Body.msg_event Object Payload

事件类型

参数名类型说明
EVENT_TYPE_SEND_MSGobject用户发送消息时的回调行为

# Body.text Object Payload

当msg_type为text时,则会返回text对应消息结构体

参数名类型示例说明
contentstring测试消息123msg_type为text时,必返回的回报消息

# Body.video Object Payload

当msg_type为video时,则会返回video对应消息结构体

参数名类型示例说明
play_lengthuint3224msg_type为video时,表示返回视频秒数
cos_urlstringhttps://channels.weixin.qq.com/shop/commkf/downloadmedia?encrypted_param=xxxxx×tamp=xxxxx&openid=xxxxxxxxx&msg_type=7msg_type为video时,表示返回视频的可下载cos_url
ld_img_urlstringhttps://channels.weixin.qq.com/shop/commkf/downloadmedia?encrypted_param=xxxxx×tamp=xxxxx&openid=xxxxxxxxx&msg_type=2msg_type为video时,表示返回视频的封面图

# Body.image Object Payload

当msg_type为image时,则会返回image对应消息结构体

参数名类型示例说明
cos_urlstringhttps://channels.weixin.qq.com/shop/commkf/downloadmedia?encrypted_param=xxxxx×tamp=xxxxx&openid=xxxxxxxxx&msg_type=2msg_type为image时,表示返回图片的可下载cos_url

# Body.file Object Payload

当msg_type为file时,则会返回file对应消息结构体

参数名类型示例说明
cos_urlstringhttps://channels.weixin.qq.com/shop/commkf/downloadmedia?encrypted_param=xxxxx×tamp=xxxxx&openid=xxxxxxxxx&msg_type=8msg_type为file时,表示返回文件的可下载cos_url

# Body.product_share Object Payload

当msg_type为product_share时,则会返回product_share对应消息结构体

参数名类型示例说明
product_idstring1000018045xxxxxmsg_type为product_share时,表示当前用户发送的卡片商品Id

# Body.order_share Object Payload

当msg_type为order_share时,则会返回order_share对应消息结构体

参数名类型示例说明
order_idstring37265222601xxxxxxxxxmsg_type为order_share时,表示当前用户发送的卡片订单Id

# Body.voice Object Payload

当msg_type为voice时,则会返回voice对应消息结构体

参数名类型示例说明
translated_msgstring您好,问一下这个商品如何下单msg_type为voice时,表示当前用户发送语音翻译成功后的文本
play_lengthnumber2287msg_type为voice时,表示当前用户发送语音的语音长度,单位为毫秒(ms)
translation_succbooltruemsg_type为voice时,表示当前用户发送语音文本是否翻译成功

# 2. 消息返回

# 返回体 Response Payload

回复 success 或空字符串(无需加密)

# 3. 注意事项

  • 回调url设置和消息推送规则需参考消息推送文档 ,如果设置的回调url无法访问,商户将无法收微信小店发送的通知;
  • 如果已切换API模式,但是没有设置指定URL,事件消息则会丢弃。设置指定URL后,需确保接收消息的服务器是可接收数据的。
  • 如果服务器回包数据不符合预期,商家客服后台则会进行消息的重试推送,总重试约3.5小时,共会进行10次消息重试推送。

# 4. 代码示例

本事件无代码示例

文档变更日志(1条)
2025 年 10 月 31 日
优化格式