WeChat Mini Program
# WeChat Mini Program
# Permission Mode
Refer to:WeChat Mini Program Docking Guide (opens new window)
# Inquiry Button Configuration
# ● Get User's Nickname and Avatar Code in Mini Program
Note: be sure to embed the code, otherwise you cannot get the user's nickname and avatar!
Embed the code into the code of Mini Program (inquiry button style can be customized through the code).
<button
type="primary"
size="40"
session-from="sobot|{{userInfo.nickName}}|{{userInfo.avatarUrl}}|{{params}}"
open-type="contact"
>Contact agent</button>
2
3
4
5
6
Note:
1) To get nickname and avatar, you need to first get Mini Program userInfo;
2) Customize params field of the string type in the format: {"key":"value",……}.
# ● Designate Reception Docking Code in Mini Program
Param definition:
params: '{"name":"sobot","age":18}',
transfer_action: '[{"actionType":"to_group","deciId":"xxx","optionId":"3","spillId":"4"},{"actionType":"to_group","deciId":"xxx","optionId":"4"}]',
platform_action: '{"customerCode":"xxx","flowGroupId":"xxx"}',
partnerid:"xxx", // Docking ID
robotid:1, // Bot ID
unionid:"oJw8S1S0ZheoM2PnKbka3zJO-QyE", // WeChat User ID
customer_fields:'{"ddb35f065d4b44ec870f58b87c1a52db":"xx"}' // Custom Field
2
3
4
5
6
7
Param description:
Param | Type | Required | Description |
---|---|---|---|
params | String | No | User custom field |
transfer_action | String | No | Trans-to-agent designated skill group setting (support passing level-3 overflow setting, namely level 4 is not overflowing by default) |
platform_action | String | No | Docking param info of e-commerce platform Mini Program |
partnerid | String | No | User's unique ID in customer system, no more than 100 chars |
robotid | String | No | Bot ID |
unionid | String | No | WeChat User ID |
customer_fields | String | No | Custom Field |
transfer_action Parameter Value Description:
Param | Type | Required | Description |
---|---|---|---|
actionType | String | Yes | Execution action type: to_group: designated skill group; to_service: designated agent. |
deciId | String | Yes | Designated skill group or agent ID |
optionId | String | Yes | Overflow tag: When designating an agent: 1: Overflow; 2: Not overflow. When designating a skill group: 3: Overflow; 4: Not overflow. |
spillId | String | Yes | Overflow conditions: When designating an agent: 1: Agent offline; 2: Agent occupied; 3: Intelligent judgement. When designating an agent group: 4: No agent online in the skill group; 5: All agents occupied in the skill group; 6: Skill group off duty; 7: Intelligent judgement. |
platform_action Parameter Value Description:
Param | Type | Required | Description |
---|---|---|---|
customerCode | String | Yes | Merchant's unique ID in the platform |
flowGroupId | String | No | Skill group ID under the designated main account |
Access to Agent button definition:
<button
session-from="sobot|{{userInfo.nickName}}|{{userInfo.avatarUrl}}|{{params}}|transfer_action={{transfer_action}}|platform_action={{platform_action}}|partnerid={{partnerid}}|robotid={{robotid}}|unionid={{unionid}}|customer_fields={{customer_fields}}"
open-type="contact"
>Agent Chat</button>
2
3
4
Note: 1. session-from length limit: 1,000 chars
2. Fields are separated by "|", corresponding to different parameter values; "sobot|nickname|avatar|custom field" are fixed fields, and field spaces are required even if no field is passed, such as: sobot||||; transfer_action, platform_action, partnerid, robotid, unionid and customer_fields are optional fields, not limited by sequence and space. Users can pass them as needed for their own business.
# Mini Program Card Docking
# ● Customer Sending Card
Support the customer to send Mini Program card in the native chat via Mini Program. Add several fields to agent chat message button: show-message-card shows message card in the chat, send-message-title shows the title of the message card in the chat, send-message-path shows the Mini Program path for jumping after clicking the message card in the chat, and send-message-img shows the image of the message card in the chat. After the fields are added and the visitor accesses the chat, a prompt of the Mini Program card will appear on the chat page. Refer to the official document for details
<button type="primary" size="40"
<!-- Original configurations remain unchanged when Mini Program card function is used, and the following configuration items should be added -->
show-message-card="true"
send-message-title="{{miniprogrampage_title}}"
send-message-path="{{miniprogrampage_path}}"
send-message-img="{{miniprogrampage_img}}"
open-type="contact">
Click Here to Send Message to Agent
</button>
2
3
4
5
6
7
8
9
# ● Agent Sending Card API
You need to send postMessage on iframe page at the new workbench of Sobot, where you can receive and send the message
Message format is as follows:
{
cid:xxx, // cid got in the docking page URL
uid:xxx,// uid got in the docking page URL
msgType: 26, // Fixed value 26
miniPage: {
headimg: "https://img.sobot.io/console/common/face/admin.png", // Mini Program avatar, for workbench display
name: "Mini Program Name", // Mini Program name, for workbench display
thumbUrl:"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1667994205,255365672&fm=5", // Mini Program cover image, for workbench display
title: "Mini Program Title",
pagepath: "pages/index/index", // Jump URL
thumbMediaId:"nI3DlJZsXd7h0JVZ-LklyzjWtZY4Q-lNAacBe50Chl0k9Zs5PR_p2_jV2na2o3_P" // Mini Program media_id
}
}
2
3
4
5
6
7
8
9
10
11
12
13
Sending example:
window.parent.postMessage({
cid: xxx,
uid: xxx,
msgType: 26,
miniPage: {
headimg: "https://img.sobot.io/console/common/face/admin.png",
name: "Mini Program Name",
title: "Mini Program Title",
pagepath: "pages/index/index",
thumbMediaId:"nI3DlJZsXd7h0JVZ-LklyzjWtZY4Q-lNAacBe50Chl0k9Zs5PR_p2_jV2na2o3_P" , // Mini Program media_id
thumbUrl:"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1667994205,255365672&fm=5",
}
}, '*');
2
3
4
5
6
7
8
9
10
11
12
13
# ● UnionID Encryption
Based on live docking Mini Program and official account, official accounts and Mini Programs in the same WeChat Open Platform can identify users as the same customer according to their unique UnionID. The Mini Program needs to transfer UnionID to Sobot. In order to prevent information leakage, UnionID can be encrypted by the encryption function of Sobot
Encryption condition:
Set through Docking Channel Settings - Channel Key. Enable UnionID Encryption Settings to generate the key, and encrypt UnionID with the key in the Mini Program
Encryption method:
Encrypt with AES / ECB / PKCS5Padding
Encryption range:
After Encryption Setting is enabled, the encryption range is: Mini Program users