客服消息接口#

class wechatpy.client.api.WeChatCustomService(client=None)[源代码]#
add_account(account, nickname, password)[源代码]#

添加客服账号 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#%E6%B7%BB%E5%8A%A0%E5%AE%A2%E6%9C%8D%E5%B8%90%E5%8F%B7

参数
  • account – 完整客服账号,格式为:账号前缀@公众号微信号

  • nickname – 客服昵称,最长6个汉字或12个英文字符

  • password – 客服账号登录密码

返回

返回的 JSON 数据包

close_session(openid, account, text=None)[源代码]#

多客服关闭会话 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Session_control.html

参数
  • openid – 客户 openid

  • account – 完整客服帐号,格式为:帐号前缀@公众号微信号

  • text – 附加信息,可选

返回

返回的 JSON 数据包

create_session(openid, account, text=None)[源代码]#

多客服创建会话 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Session_control.html

参数
  • openid – 客户 openid

  • account – 完整客服帐号,格式为:帐号前缀@公众号微信号

  • text – 附加信息,可选

返回

返回的 JSON 数据包

delete_account(account)[源代码]#

删除客服账号 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#%E5%88%A0%E9%99%A4%E5%AE%A2%E6%9C%8D%E5%B8%90%E5%8F%B7

参数

account – 完整客服账号,格式为:账号前缀@公众号微信号

返回

返回的 JSON 数据包

get_accounts()[源代码]#

获取所有客服账号 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#%E8%8E%B7%E5%8F%96%E6%89%80%E6%9C%89%E5%AE%A2%E6%9C%8D%E8%B4%A6%E5%8F%B7

返回

客服账号列表

get_online_accounts()[源代码]#

获取在线客服接待信息 详情请参考 http://mp.weixin.qq.com/wiki/9/6fff6f191ef92c126b043ada035cc935.html

返回

客服接待信息列表

get_records(start_time, end_time, msgid=1, number=10000)[源代码]#

获取客服聊天记录 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Obtain_chat_transcript.html

参数
  • start_time – 查询开始时间,UNIX 时间戳

  • end_time – 查询结束时间,UNIX 时间戳,每次查询不能跨日查询

  • msgid – 消息id顺序从小到大,从1开始

  • number – 每次获取条数,最多10000条

返回

返回的 JSON 数据包

get_session(openid)[源代码]#

获取客户的会话状态,如果不存在,则 kf_account 为空 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Session_control.html

参数

openid – 粉丝的 openid

返回

返回的 JSON 数据包

get_session_list(account)[源代码]#

获取客服的会话列表 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Session_control.html

参数

account – 完整客服帐号,格式为:帐号前缀@公众号微信号

返回

客服的会话列表

get_wait_case()[源代码]#

获取未接入会话列表 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Customer_Service/Session_control.html

返回

返回的 JSON 数据包

update_account(account, nickname, password)[源代码]#

修改客服账号 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#%E4%BF%AE%E6%94%B9%E5%AE%A2%E6%9C%8D%E5%B8%90%E5%8F%B7

参数
  • account – 完整客服账号,格式为:账号前缀@公众号微信号

  • nickname – 客服昵称,最长6个汉字或12个英文字符

  • password – 客服账号登录密码

返回

返回的 JSON 数据包

upload_headimg(account, media_file)[源代码]#

设置客服帐号的头像 详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#%E8%AE%BE%E7%BD%AE%E5%AE%A2%E6%9C%8D%E5%B8%90%E5%8F%B7%E7%9A%84%E5%A4%B4%E5%83%8F

参数
  • account – 完整客服帐号,格式为:帐号前缀@公众号微信号

  • media_file – 要上传的头像文件,一个 File-Object

返回

返回的 JSON 数据包