# Third-Party Customer Service System Access - Receive user and bot messages

# Configuration information

For example:

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

# Configure the human customer service callback interface:

Please configure the human customer service callback interface according to the following path

Release Management -> Application binding -> Open API -> Callback address

authentication

Note: When the customer service access status is1When connected, the third party customer service system will not receive the data reported by the robot.

Interface type:

POST request

Content-type: application/json of json request

Dxplaination of parameters:

field type Yes Required describe
encrypted string yes Conversation content encrypted character string

Please refer to Message encryption and decryption access guidelines Decrypt the message

Note that in the process of using message decryption,MsgSignature,TimeStamp,Nuncio 3 To fill in the empty character string, Only decryption can be performed without signature verification, And then use the official decryption demo Note that it cannot be used directly because the returned data result is not in the package xml to hit the target

<xml>
    <Encrypt>
    <![CDATA[LDFAmKFr7U/RMmwRbsR676wjym90byw7+hhh226e8bu6KVYy00HheIsVER4eMgz/VBtofSaeXXQBz6fVdkN2CzBUaTtjJeTCXEIDfTBNxpw/QRLGLq
    qMZHA3I+JiBxrrSzd2yXuXst7TdkVgY4lZEHQcWk85x1niT79XLaWQog+OnBV31eZbXGPPv8dZciKqGo0meTYi+fkMEJdyS8OE7NjO79vpIyIw7hMBtEXPBK/tJGN5m5SoAS
    6I4rRZ8Zl8umKxXqgr7N8ZOs6DB9tokpvSl9wT9T3E62rufaKP5EL1imJUd1pngxy09EP24O8Th4bCrdUcZpJio2l11vE6bWK2s5WrLuO0cKY2GP2unQ4fDxh0L4ePmNOVFJ
    wp9Hyvd0BAsleXA4jWeOMw5nH3Vn49/Q/ZAQ2HN3dB0bMA+6KJYLvIzTz/Iz6vEjk8ZkK+AbhW5eldnyRDXP/OWfZH2P3WQZUwc/G/LGmS3ekqMwQThhS2Eg5t4yHv0mAIei
    07Lknip8nnwgEeF4R9hOGutE9ETsGG4CP1LHTQ4fgYchOMfB3wANOjIt9xendbhHbu51Z4OKnA0F+MlgZomiqweT1v/+LUxcsFAZ1J+Vtt0FQXElDKg+YyQnRCiLl3I+GJ/c
    xSj86XwClZC3NNhAkVU11SvxcXEYh9smckV/qRP2Acsvdls0UqZVWnPtzgx8hc8QBZaeH+JeiaPQD88frNvA==]]> </Encrypt>
    <MsgSignature></MsgSignature>
    <TimeStamp>1411034505</TimeStamp>
    <Nuncio></Nuncio>
</xml>

But directly.Encrypt Returns in the JSON Call the official directly. Demo In the exampledecryptMethod on it Instead of decryptMsg

The decrypted data format is as follows:


<xml>
  <userid>User's unique ID (usually the user's openid in weixin)</userid>
  <appid>Appid for application</appid>
  <content>
    <msg>Content of a robot or user</msg>
  </content>
  <event>userEnter</event>
  <from>Dialogue Source ID 0/1/2</from>
  <kfstate>Customer Service Access Status 0/1/2/3</kfstate>
  <channel>Channel id 0</channel>
  <assessment>User evaluation0/1/2/3/4/5</assessment>
  <createtime>Unix time stamp</createtime>
</xml>

content Field is a composite data structure , when from === 0 Questions sent to customers, May be forPlain or rich text, when from === 1 Time forContent that robots automatically reply to, When from === 2 When the content of the human customer service reply

# Return value:

field type Yes Required describe
userid string yes The user's weixin openid
appid string yes Official Account message template Or Mini Program. appid
content object yes Robot Response or Customer Questions
channel number yes channel ID, see channel map for details
from number yes Sources of Dialogue
event string no User-triggered event
kfstate number no Customer Service Access Status
assessment number no Client evaluation

# Customer Service Access Status(kfstate):

state ID describe
0 Intelligent Customer Service -- Pending access (asking)
1 Artificial customer service -- Accessed (personserving)
2 End Artificial Customer Service(dialogue) -- Dialogue Closed (complete)
3 Pending manual access -- Manual to be transferred (needperson)

# Sources of Dialogue(from):

source ID describe
0 Content sent by users
1 The robot replied.
2 The content of the customer service reply on the weixin dialogue open platform

# Channel explaination(channel):

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.
6 The access mode is that the Mini Program plug-in connects to the channel of intelligent dialogue.
7 Access to the web page. H5 Channels for Intelligent Robot Conversations

# Customer Service Trigger Event(event):

event Key describe Channels of support
userEnter The user enters H5 Robot
userQuit The user leaves. H5 Robot
customerStuffEnter Customer Service Staff Begins Access All channels
customerStuffQuit Customer Service Staff Closed Leave All channels

event customerStuffEnter/customerStuffQuit When it appears Will add an extra field customerInfo

Field name describe
customerInfo.name Customer service staff weixin nickname
customerInfo.avatar Head of the customer service staff
customerInfo.openid Customer service staff weixin openid

# Client evaluation(assessment):

assessment describe
0 Non-Client Evaluation Message
1 Disgruntled.
2 Dissatisfaction
3 general
4 satisfied
5 Very pleased.

# Error code:

{
    errcode: 1001,
    errmsg: "TOKEN is not valid"
}
Error code describe
1001 Token invalid
1002 The robot failed the audit.
1003 Lack of signature userid field
1004 Signature field is empty
1005 Signature expired or invalid
1006 Signature verification failed, missing userid field