Customer service message
Customer service message
When a user interacts with a public account with a specific action (see the description below for the specific action list), WeChat will push the message data to the developer, and the developer can Call the customer service interface within a period of time (currently modified to 48 hours) and send a message to ordinary users by POSTing a JSON data packet. This interface is mainly used for functions such as customer service that require manual message processing, so that developers can provide users with better services.
The current list of allowed actions is as follows (the public platform will update the list according to the operation situation. After different actions are triggered, the number of messages allowed to be sent by the customer service interface is different. After the number of messages sent reaches the upper limit, you will encounter Error return code, please see the return code description page for details):
1、用户发送信息 2、点击自定义菜单(仅有点击推事件、扫码推事件、扫码推事件且弹出“消息接收中”提示框这3种菜单类型是会触发客服接口的) 3、关注公众号 4、扫描二维码 5、支付成功 6、用户维权
In order to help official accounts use different customer service identities to serve different user groups, the customer service interface has been upgraded. Developers can manage customer service accounts and set settings The avatar and nickname of the customer service account. This capability is open to all public accounts with customer service interface permissions.
In addition, developers please note that all places where media_id is used in this interface can now use the permanent material media_id in material management.
##Customer Service Account Management
After the developer completes the development according to the requirements of the development document, WeChat users using version 6.0.2 and above communicate with the customer service of the official account. After the official account uses different customer service accounts to reply, the user can see the corresponding customer service Avatar and nickname. Please note that you must first set up a WeChat ID for the public account on the official website of the public platform before you can use this capability.
Add customer service account
# Developers can add customer service accounts to public accounts through this interface. Each public account can add up to 10 customer service accounts. . The interface call request is as follows:
http请求方式: POST https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN
The POST data example is as follows:
{ "kf_account" : "test1@test", "nickname" : "客服1", "password" : "pswmd5", }
Return instructions (JSON return result when correct):
{ "errcode" : 0, "errmsg" : "ok", }
WeChat will return an error code when it is wrong and other information, please query the error information according to the error code
Modify customer service account
Developers can modify the customer service account for the public account through this interface. The interface call request is as follows:
http请求方式: POST https://api.weixin.qq.com/customservice/kfaccount/update?access_token=ACCESS_TOKEN
The POST data example is as follows:
{ "kf_account" : "test1@test", "nickname" : "客服1", "password" : "pswmd5", }
Return instructions (JSON return result when correct):
{ "errcode" : 0, "errmsg" : "ok", }
WeChat will return an error code when it is wrong and other information, please query the error information according to the error code
Delete customer service account
Developers can delete customer service accounts for public accounts through this interface. The interface call request is as follows:
http请求方式: GET https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN
The POST data example is as follows:
{ "kf_account" : "test1@test", "nickname" : "客服1", "password" : "pswmd5", }
Return instructions (JSON return result when correct):
{ "errcode" : 0, "errmsg" : "ok", }
WeChat will return an error code when it is wrong and other information, please query the error information according to the error code
Set the avatar of the customer service account
Developers can call this interface to upload a picture as the avatar of the customer service staff. The avatar image file must be jpg Format, it is recommended to use 640*640 size pictures to achieve the best effect. The interface call request is as follows:
http请求方式: POST/FORM http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT 调用示例:使用curl命令,用FORM表单方式上传一个多媒体文件,curl命令的具体用法请自行了解
Return instructions (JSON return result when correct):
{ "errcode" : 0, "errmsg" : "ok", }
In case of error, WeChat will return error code and other information, please query the error information based on the error code
Get all customer service accounts
# Developers can use this interface to obtain the basic customer service information set in the public account, including customer service ID number, Customer service nickname and customer service login account.
http请求方式: GET https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN
Return instructions (JSON return result when correct):
{ "kf_list": [ { "kf_account": "test1@test", "kf_nick": "ntest1", "kf_id": "1001" "kf_headimgurl": " http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjfUS8Ym0GSaLic0FD3vN0V8PILcibEGb2fPfEOmw/0" }, { "kf_account": "test2@test", "kf_nick": "ntest2", "kf_id": "1002" "kf_headimgurl": " http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjfUS8Ym0GSaLic0FD3vN0V8PILcibEGb2fPfEOmw /0" }, { "kf_account": "test3@test", "kf_nick": "ntest3", "kf_id": "1003" "kf_headimgurl": " http://mmbiz.qpic.cn/mmbiz/4whpV1VZl2iccsvYbHvnphkyGtnvjfUS8Ym0GSaLic0FD3vN0V8PILcibEGb2fPfEOmw /0" } ] }
In case of error, WeChat will return error code and other information, please query the error information according to the error code
Uniform parameter description of interface
Parameter | Is it necessary | Description |
---|---|---|
access_token | It is | calling interface credential |
kf_account | is | complete customer service account, the format is: account prefix @ official account WeChat ID |
kf_nick | is | Customer service nickname |
kf_id | is | Customer Service ID |
nickname | is the | customer service nickname, up to 6 Chinese characters or 12 English characters |
password | No | Customer service account login password, the format is a 32-bit encrypted MD5 value of password plain text.This password is only used in the multi-customer service function of the official website of the public platform. If you do not use the multi-customer service function, you do not need to set a password |
media | is | This parameter only appears when setting the customer service avatar. It is the media file identifier in form-data, including filename, filelength, content-type and other information |
##Customer Service Interface-Send Message
Interface call request description
http请求方式: POST https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKENThe JSON data packets required for each message type are as follows: Send text message
{ "touser":"OPENID", "msgtype":"text", "text": { "content":"Hello World" } }Send picture message
{ "touser":"OPENID", "msgtype":"image", "image": { "media_id":"MEDIA_ID" } }Send voice message
{ "touser":"OPENID", "msgtype":"voice", "voice": { "media_id":"MEDIA_ID" } }Send video message
{ "touser":"OPENID", "msgtype":"video", "video": { "media_id":"MEDIA_ID", "thumb_media_id":"MEDIA_ID", "title":"TITLE", "description":"DESCRIPTION" } }
Send music messages
{ "touser":"OPENID", "msgtype":"music", "music": { "title":"MUSIC_TITLE", "description":"MUSIC_DESCRIPTION", "musicurl":"MUSIC_URL", "hqmusicurl":"HQ_MUSIC_URL", "thumb_media_id":"THUMB_MEDIA_ID" } }
Send graphic messages (click to jump to the external link) The number of graphic messages is limited to 8. Note that if the number of graphic messages exceeds 8, there will be no response.
{ "touser":"OPENID", "msgtype":"news", "news":{ "articles": [ { "title":"Happy Day", "description":"Is Really A Happy Day", "url":"URL", "picurl":"PIC_URL" }, { "title":"Happy Day", "description":"Is Really A Happy Day", "url":"URL", "picurl":"PIC_URL" } ] } }
Send graphic messages (click to jump to the graphic message page) The number of graphic messages is limited to 8. Note that if the number of graphic messages exceeds 8, there will be no response.
{ "touser":"OPENID", "msgtype":"mpnews", "mpnews": { "media_id":"MEDIA_ID" } }
Send cards and coupons
{ "touser":"OPENID", "msgtype":"wxcard", "wxcard":{ "card_id":"123dsdajkasd231jhksad" }, }
Specially note that the customer service message interface only supports cards and coupons with non-custom code codes and imported code mode cards.
Please note that if you need to send a message with a certain customer service account (to display a custom avatar in WeChat 6.0.2 and above), you need to add customservice to the second half of the JSON data packet Parameters, for example, when sending a text message, change it to:
{ "touser":"OPENID", "msgtype":"text", "text": { "content":"Hello World" }, "customservice": { "kf_account": "test1@kftest" } }
Parameter | Is it necessary | Description |
---|---|---|
access_token | Yes | Call interface credentials |
touser | is | ordinary user openid |
is the | message type, the text is text, the picture is image, the voice is voice, the video message is video, the music message is music, the graphic message (click to jump to the external link) is news, the graphic message (click to jump to the graphic message page) is mpnews, the card coupon is wxcard | |
is the | text message Content | |
is the media of the picture/voice/video/graphic message sent by | (click to jump to the graphic message page) ID | |
thumb_media_id | Yes the media ID of the | thumbnail |
title | No | Title of graphic message/video message/music message |
description | No | Description of graphic message/video message/music message |
musicurl | 是 | Music link |
hqmusicurl | 是 | High-quality music link, wifi environment gives priority to using this link to play music |
url | No | The graphic message will jump after being clicked Link |
picurl | No | Picture link of graphic message, supports JPG and PNG formats, the best effect is large picture 640* 320, small picture 80*80 |
Interface return description
Return data example (JSON return result when correct):