# Third Party Service System Access - Send Customer Service Message

Only applicable to the following account types that have been authorized to the platform 1. Certified Service Number 2. Authenticated subscription number 3. Mini Program 4. h5 5. Mini Program plugin

# Configuration information

For example:

  • APPID: xxxxxxxxxxxxxxx
  • TOKEN: xxxxxxxxxxxxxxx
  • EncodingAESKey: xxxxxxxxxxxxxxx

# Send Customer Service Message Interface:

https://chatbot.weixin.qq.com/openapi/sendmsg/{TOKEN}

Interface type:

POST request

Dxplaination of parameters:

field type Yes Required describe
appid string no When the channel is 0, 5, 6, please pass the Official Account message template or Mini Program appid, channel is 7, non-required or pass token
openid string yes User's weixin openid
msg string yes Message content
channel number yes Channel ID, see Channel Mapping Table
event string no Events, See List of Events
kefuname string no Nickname for Customer Service Staff
kefuavatar string no Head of the customer service staff
ans_node_name string no classification/Name of Skill

Channel explaination:

Channel ID Channel description
0 Access mode is, scan code bound Official Account message template、 Mini Program access to intelligent dialogue channels
2 The access mode is to access the channel of intelligent dialogue through open interface. (Not yet open)
3 Access mode is, WeCom group chat robot (not yet open)
4 The access method is WeCom (for employees within the enterprise) customer service robot (not yet open)
5 Access mode is, Official Account message template Menu H5 Machine Man
6 The access mode is that the Mini Program plug-in connects to the channel of intelligent dialogue.
7 The access mode is the channel of intelligent dialogue of web H5 robot.

Dxplaination of the incident:

Event ID describe
waiterQualityEvaluate Ask the user to evaluate it.
waiterEnter Customer Service Access
waiterSwitch Customer Service Transfer
waiterQuit Customer Service Leave

Message encryption and decryption access guidelines

For example, the parameters are

<xml>
    <appid><![CDATA[wxxxxx]]></appid>
    <openid><![CDATA[xxxxx]]></openid>
    <msg><![CDATA[Hello. How can I help you?]]></msg>
    <channel>0</channel>
    <kefuname><![CDATA[Customer Service Nickname]]></kefuname>
    <kefuavatar><![CDATA[Customer Service Profile Picture URL Address]]></kefuavatar>
    <ans_node_name><![CDATA[Category or Skill Name]]></ans_node_name>
</xml>

Encrypt the data to the field encrypt Into the body.

var cryptor = new WXBizMsgCrypt(TOKEN, EncodingAESKey, APPID)

var data = `<xml>
    <appid><![CDATA[wxxxxx]]></appid>
    <openid><![CDATA[xxxxx]]></openid>
    <msg><![CDATA[Hello. How can I help you?]]></msg>
    <channel>0</channel>
    <kefuname><![CDATA[Customer Service Nickname: Little Red]]></kefuname>
    <kefuavatar><![CDATA[Customer Service Head Image Address: https://xxx]]></kefuavatar>
</xml>`

var encrypted = cryptor.encrypt(data)

curl -X post -d '{"encrypt": encrypted}' -H "content-type:application/json" "https://chatbot.weixin.qq.com/openapi/sendmsg/{TOKEN}"

Note: When sending a request for a post, you need to specify content-type: "application/json"

Return value:

field type describe
code number Error code
msg array Interface Call Information

Return format:

{
  "errcode": 0,
  "msg": "Success"
}

# Rich text support

  1. Plain text
    const msg = " Hello, may I help you? "
  1. Text Type (with Recommended Questions)
    const msg = " We have not found the corresponding answer, we will deal with it as soon as possible. Official Official Account message template: weixin Dialogue Open Platform <a href="weixin://bizmsgmenu? msgmenucontent=How many degrees in Beijing today&msgmenuid=How much degree in Beijing Today">How much is Beijing today?</a>"
  1. Text type (including hyperlinks)
    const msg = " Please go to<a href="https://chatbot.weixin.qq.com/">openai</a>To configure "
  1. H5

  const msg = {
    "news": {
      "articles": [{
        "title": "Real Time Update: New Pneumonia Epidemic Update,"
        "description": "Tencent News synchronized the national new pneumonia epidemic situation in the first time, welcome attention, forward,"
        "url": "https://news.qq.com/zt2020/page/feiyan.htm",
        "picurl": "http://mmbiz.qpic.cn/mmbiz_jpg/W3gQtpV3j8D8kZRqfpTJlfVqubwgFQf47H0GWlGV6leaDF80ZpdtuFhQVsCsM3YKmwkujXzdjR2k6aWfA41ic7Q/0?wx_fmt=jpeg",
        "type": "h5"
      }]
    }
  }

The fields for each item in the news.articles array are described as:

field type describe
title string Title of article
description string Article Description
url string Article Links
picurl string Photo Links
type string Represents the type of the article, there are 'h5' and 'mp' two, mp represents the Official Account message template article, h5 represents the h5 configuration in the dialogue open platform
  1. Official Account message template picture
  const msg = {
    "image": {
      "media_id": "KegpipQG9t-klMo25My4e4BCZFcmKvgMcpMFAkC-VFE",
      "url": "http://mmbiz.qpic.cn/mmbiz_jpg/W3gQtpV3j8Bax22dhRiccWAb2AtVjal28XmqnhDW22dMn3RA5EoGkpolMO3tD9kQC1Hf9AjEJI66K40xQsNtXgQ/0?wx_fmt=jpeg"
    }
  }

Each field in the image is described as:

field type describe
media_id string Official Account message template Stock ID
url string Official Account message template Image url
  1. Mini Program
  const msg ={
    "miniprogrampage": {
      "title": "OpenAI Dialogue Plugin,"
      "appid": "wx8c631f7e9f2465e1",
      "pagepath": "pages/index/index",
      "thumb_media_id": "KegpipQG9t-klMo25My4e8zpBjhjg3JMrMSpgjikB4U",
      "thumb_url": "http://mmbiz.qpic.cn/mmbiz_png/W3gQtpV3j8BYhWgfHT5Hfg6auN94c2ec4BBhDOMtPQrx6vEMc1rR4iaDKxDLOfZ1jBUqIEEY4YpvEj6ktSyXT7g/0?wx_fmt=png"
    }
  }

Each field in miniprogrampage is described as:

field type describe
title string Small Program Title
appid string appid
pagepath string Mini Program Jump Page Path
thumb_media_id string Official Account message template Stock ID
thumb_url string Official Account message template Image url
  1. Combined answer
  {
    "multimsg": ["Hello," {
        "image": {
          "media_id": "KegpipQG9t-klMo25My4e4BCZFcmKvgMcpMFAkC-VFE",
          "url": "http://mmbiz.qpic.cn/mmbiz_jpg/W3gQtpV3j8Bax22dhRiccWAb2AtVjal28XmqnhDW22dMn3RA5EoGkpolMO3tD9kQC1Hf9AjEJI66K40xQsNtXgQ/0?wx_fmt=jpeg"
        }
    }, {
    "miniprogrampage": {
      "title": "OpenAI Dialogue Plugin,"
      "appid": "wx8c631f7e9f2465e1",
      "pagepath": "pages/index/index",
      "thumb_media_id": "KegpipQG9t-klMo25My4e8zpBjhjg3JMrMSpgjikB4U",
      "thumb_url": "http://mmbiz.qpic.cn/mmbiz_png/W3gQtpV3j8BYhWgfHT5Hfg6auN94c2ec4BBhDOMtPQrx6vEMc1rR4iaDKxDLOfZ1jBUqIEEY4YpvEj6ktSyXT7g/0?wx_fmt=png"
    }]
  }
field type describe
multimsg array The answer list is merged, each entry is a collection of single types, each type refers to its corresponding data structure

# Error code:

{
    errcode: 1001,
    errmsg: "TOKEN is not valid"
}
Error code describe
1001 Token invalid
1002 The robot failed the audit.
1003 Signature missing userid field
1004 Signature field is empty
1005 Signature expired or invalid
1006 Signature check failed, userid field missing
1007 appid, category,label, desc Field cannot be empty
1008 appid, openid,msg, Field cannot be empty