Basic Usage
Log in to the Udesk customer service system administrator account, navigate to Management Center -> Channel Management -> Instant Messaging -> Web Plugin -> (specific plugin) Management, configure the basic properties, then copy the code to your webpage to enable Udesk IM.
Considerations
Device Support
WebIM currently supports devices such as PC/Android (including tablets)/IOS (including tablets).
Browser Compatibility
WebIM currently supports IE8+ (inclusive) and other mainstream browsers based on its core (360/qq/...), as well as other mainstream browsers (chrome/firefox/...).
Basic Example
Embedded Code Example
<body>
<!-- Webpage content. Copy the code from the administrator's instant messaging webpage plugin here. -->
<script>
(function(a,h,c,b,f,g){a["UdeskApiObject"]=f;a[f]=a[f]||function(){(a[f].d=a[f].d||[]).push(arguments)};g=h.createElement(c);g.async=1;g.src=b;c=h.getElementsByTagName(c)[0];c.parentNode.insertBefore(g,c)})(window,document,"script","https://xxx.xxxx.cn/im_client/js/udeskApi.js?1487931175918","ud");
ud({
"code": "xxxx",
"link": "https://xxx.xxxx.cn/im_client/?web_plugin_id=1",
"isInvite": true,
"mode": "inner",
"color": "#307AE8",
"pos_flag": "srb",
"language": "en-us", // Language - English
"onlineText": "Contact Customer Service, Online Consultation",
"offlineText": "Customer Service Off Duty, Please Leave a Message",
"mobile": {
"mode": "blank",
"color": "#307AE8",
"pos_flag": "crb",
"onlineText": "Contact Customer Service, Online Consultation",
"offlineText": "Customer Service Off Duty, Please Leave a Message"
}
});
</script>
</body>
Link Example
https://xxx.xxxx.cn/im_client/?web_plugin_id=xx&language=zh-cn&agent_id=xxx&group_id=xxx
Custom Configuration
Developers can customize related configurations according to their needs. All properties and events are configured within
ud({...})
, and all methods are called usingud(methodName, ...arguments)
.
Configuration Method
- ud({key: val, key2: val2, ...});
- ud(key, val);
Parameter Explanation
Global Parameters
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
code | String | System-generated | Yes | Company unique identifier |
link | String | System-generated | Yes | Company IM Client link |
isInvite | Boolean | true or false (default) | No | Whether to enable visitor invitation function |
agent_id | String | Specified agent ID, default unspecified | No | Specify the customer service agent for the session |
group_id | String | Specified group ID, default unspecified | No | Specify the customer service group for the session |
session_key | String | 6-character random string | No | Different session_key for the same client triggers a new session. Only letters, numbers, and underscores are supported |
merchant_id | String | Merchant ID | No | If passed, both session_key and merchant_id need to transmit the same merchant ID Session logic: passing stores related parameters, do not disrupt the current session order, robot, pre-consultation form, messages, etc., only save parameters during manual session and display replacement |
merchant_name | String | Merchant name | No | In the session with the customer service, the "customer service introduction" will be replaced by "merchant name" |
merchant_avatar | String | Merchant avatar | No | In the session with the customer service, the "customer service avatar" will be replaced by "merchant avatar" |
merchant_list | Boolean | true or false (default) | No | When merchant_list=true in the webpage plugin link, the webpage plugin loads all the merchants in the current customer's history sessions, sorted by the latest session time for each merchant |
mode | String | inner: embedded mode (default) blank: standalone window mode | No | Button opens window display mode. Configurable in the management console |
color | String | Button color code, default: #307AE8 | No | Configure IM button color. Configurable in the management console |
pos_flag | String | Button shape + position 1) Shape: h(horizontal) v(vertical) c(circular) i(image); 2) Position: lt(left top) mt(mid top) rt(right top) lm(left middle) mm(middle) rm(right middle) lb(left bottom) mb(mid bottom) rb(right bottom) Default: crb (pc), hrb (mobile) | No | Button shape + position Example: vrb (vertical right bottom) Image configuration path: Management Center - Channel Management - Instant Messaging - Web Plugin - Management - Button Settings |
onlineText | String | Display text when customer service is online, default: "Contact Customer Service, Online Consultation" | Yes | Configurable in the management console |
offlineText | String | Display text when customer service is offline, default: "Customer Service Off Duty, Please Leave a Message" | Yes | Configurable in the management console |
noBubble | Boolean | true or false (default) | No | Do not display message pop-up bubble reminders |
manualInit | Boolean | true or false (default) | No | Manual initialization. When set to true, the embedded code will not initialize automatically and needs to be called actively using the ud('init') method |
language | String | "zh-cn" (Chinese) or "en-us" (English) | No | Configure client multilingualism [Details] |
channel | String | Custom channel | No | Configurable in the management console |
targetSelector | String | Supports #id,.class,tagName,... Default system-generated Unique | No | Main target button selector 1) Used to trigger the chat window 2) Used to replace the default system-provided button, specifying valid defaults no longer display 3) Used to receive invitations 4) Used to receive new message reminders 5) ... |
selector | String | Supports #id,.class,tagName,... Default none Multiple possible | No | Auxiliary button selector 1) Used to trigger the chat window |
css | Object | Button custom style, such as: css:{top:10%}, default none | No | |
window | Object | Standalone window mode only Standalone window default size is width 780, height 560 Example window: {"width": "780", "height": "560"} | No | Configure the size of the opened standalone window |
panel | Object | Webpage embedded mode only | No | Session panel [Details] |
pop | Object | No | Message reminder bubble [Details] | |
customer | Object | No | Customer information [Details] | |
product | Object | No | Consultation object [Details] | |
hide_product | Boolean | No | When the parameter is true, the display of the client's consultation object will be hidden, and the customer service side will still display | |
mobile | Object | No | Mobile-related configuration [Details] When the website is responsive layout, provide customization for pc and mobile | |
robot_modelKey | String | Robot FAQ template ID | No | Call the common problem template according to the robot common problem template ID, you can view it in 'Km-Robot-FAQ dialogue-Knowledge base-Common problem-ID' |
c_cf_dialogueDesc | String | Custom value, supports multiple values separated by commas | No | The purpose of this field is to meet the needs of customers to pass any custom information to the robot Usage: First, you need to set a custom field named c_cf_dialogueDesc in the customer custom field in the customer service system. After setting the customer's field value, open the web IM webpage plugin and add the field to the path parameter. The format is as follows https://xxx.udesk.cn/im_client/?web_plugin_id=41597&c_cf_dialogueDesc=* This way, the system will automatically pass the value of c_cf_dialogueDesc to the robot, and the robot's dialogue description field will receive this value |
uba | {app_key: string} | User behavior analysis configuration | No | Example: ud(\{uba:{app_key: 'xxxxxxx'\}}) |
src_url | String | http URL address | No | Source URL |
Example
ud({
"code": "xxxx",
"link": "https://xxx.xxxx.cn/im_client/",
"mode": "inner",
"color": "#307AE8",
"pos_flag": "srb",
"onlineText": "Contact Customer Service, Online Consultation",
"offlineText": "Customer Service Off Duty, Please Leave a Message",
"targetSelector": "#btn_udesk_im",
"selector": ".udesk_im",
"pop": {},
"panel": {},
"mobile": {},
"window": {}
});
> Mobile - Parameter Explanation
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
mode | String | inner: embedded mode (default) blank: standalone window mode | No | Button opens window display mode. Configurable in the management console |
color | String | Button color code, default: #307AE8 | No | Configure IM button color. Configurable in the management console |
pos_flag | String | Button shape + position 1) Shape: h(horizontal) v(vertical) c(circular) i(image); 2) Position: lt(left top) mt(mid top) rt(right top) lm(left middle) mm(middle) rm(right middle) lb(left bottom) mb(mid bottom) rb(right bottom) Default: crb (pc), hrb (mobile) | No | Button shape + position Example: vrb (vertical right bottom) Image configuration path: Management Center - Channel Management - Instant Messaging - Web Plugin - Management - Button Settings |
onlineText | String | Display text when customer service is online, default: "Contact Customer Service, Online Consultation" | Yes | Configurable in the management console |
offlineText | String | Display text when customer service is offline, default: "Customer Service Off Duty, Please Leave a Message" | Yes | Configurable in the management console |
noBubble | Boolean | true or false (default) | No | Do not display message pop-up bubble reminders |
language | String | "zh-cn" (Chinese) or "en-us" (English) | No | Configure client multilingualism |
targetSelector | String | Supports #id,.class,tagName,... Default system-generated Unique | No | Main target button selector 1) Used to trigger the chat window 2) Used to replace the default system-provided button, specifying valid defaults no longer display 3) Used to receive invitations 4) Used to receive new message reminders 5) ... |
selector | String | Supports #id,.class,tagName,... Default none Multiple possible | No | Auxiliary button selector 1) Used to trigger the chat window |
css | Object | Button custom style, such as: css:{top:10%}, default none | No | |
pop | Object | No | Message reminder bubble [Details] |
Example
ud({
"mobile", {
"mode": "blank",
"color": "#307AE8",
"pos_flag": "crb",
"onlineText": "Contact Customer Service, Online Consultation",
"offlineText": "Customer Service Off Duty, Please Leave a Message",
"pop": {
"direction": "top",
"arrow": {
"top": 0,
"left": "70%"
}
}
}
});
> Session Panel - Parameter Explanation
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
css | Object | Custom style, such as: css:{top:10%}, default none | No | Panel position only supports top, left, right |
onToggle | Function | Custom method Parameter: data.visible (true or false)}, | No | Check whether the current session panel is open. When visible is true, it is open |
Example
ud({
"panel": {
"css": {
"top": "0",
"left": "0"
},
"onToggle": function(data) { //Panel switch time
if (data.visible) {
//console.log('Window open');
}
else{
//console.log('Window closed');
}
}
}
});
> Message Reminder Bubble - Parameter Explanation
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
css | Object | Custom style, such as: css:{top:10%}, default none | No | |
direction | String | Bubble pop-up direction, "top" (default); "right"; "left"; "bottom" | No | |
offset | Object | Bubble offset, {top:0,left:0}, default relative center display | No | |
arrow | Object | Bubble arrow configuration, {top:0,left:0}, default relative center display | No |
Example
ud({
"pop": {
"direction": "top",
"arrow": {
"top": 0,
"left": "70%"
}
}
});
Sure! Here's the translation of the provided markdown document:
Customer Information - Parameter Description
Overview
When website logged-in users chat via web im, they can transfer customer information to Udesk through links. This allows customer service to directly view customer information while chatting with customers. The customer information assistant component can further help understand other information about this customer, such as orders.
Usage
Add parameters and encrypted information to the link (https://xxxx.udesk.cn/im_client/) in the web im conversation window according to the following rules to transmit customer information.
The email and phone number are used for customer identification, that is, they are compared with existing data in the Udesk system's CRM. If it is an existing customer, the information will be updated; if there is no match, a new customer will be created.
Customer Authentication - Request Parameters
Identity authentication is required to pass customer information and business records signature encryption algorithm. If you do not need to pass this data, identity authentication is not required;
Validity period of customer identity recognition: 4 days;
Order of customer identity recognition: web_token > customer_token > c_email > c_phone;
If the passed web_token or customer_token does not exist in the system; but the passed c_email or c_phone exists, the system will still recognize it as an existing customer. If only web_token is passed without passing customer_token, c_email, c_phone, etc., identity data, web_token will only match one data of the customer's web_token. If no match is found, a new customer will be created.
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
nonce | String | Random number | Yes | A random number, dynamically generated, provides higher security than static random numbers. |
timestamp | String | Timestamp | Yes | Current timestamp (13 milliseconds). |
web_token | String | Customer ID | Yes | Unique identifier for the customer, recommended to use email, phone number, etc. Only letters, numbers, and underscores are supported, special characters are disabled |
customer_token | String | External customer ID | No | External unique identifier for the customer, equivalent to open_api_token Only letters, numbers, and underscores are supported, special characters are disabled |
signature | String | Encrypted signature | Yes | [Signature encryption algorithm] |
encryption_algorithm | String | SHA1 or SHA256 | No | Encryption algorithm, defaults to SHA1 if not specified, SHA256 recommended |
Signature Encryption Algorithm (Three Steps)
- Concatenate characters according to the parameters and order behind:
nonce
,timestamp
,web_token
,im_user_key
in the form ofkey=value&
im_user_key acquisition location [Management Center-Instant Messaging-Web Plugins-Management/Adding Customer Information KEY]
sign_str = nonce=value×tamp=value&web_token=value&im_user_key
- Use the encryption algorithm to calculate the signature string
sign_str = sha1(sign_str)
or sign_str = sha256(sign_str)
- Convert the string to uppercase
sign_str = sign_str.toUpperCase()
-
Common mistakes reminder
-
im_user_key requires only values without parameters
-
The signature string should be converted to uppercase
SHA1 Example:
sign_str = "nonce=9ca6fff5a509fb887ac72cf5c92010e7×tamp=1455675719000&web_token=test@udesk.cn&b476f9f8-5309-4d0a-a2d4-af08c4507a15";
sign_str = sha1(sign_str);
sign_str = sign_str.toUpperCase();
Examples
// SHA1 Example
ud({
"customer": {
"nonce": "9ca6fff5a509fb887ac72cf5c92010e7",
"signature": "9B2619225AA6476DC1EB80DBB8801E1575EBE39C",
"timestamp": "1455675719000",
"web_token": "test@udesk.cn"
}
});
// SHA256 Example
ud({
"customer": {
"nonce": "9ca6fff5a509fb887ac72cf5c92010e7",
"signature": "4CC40FA2D762DAB1D4509750A7135123743D26F2552B7E23611AB8CB5D35825B",
"timestamp": "1455675719000",
"web_token": "test@udesk.cn",
"encryption_algorithm": "SHA256"
}
});
Customer Parameters
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
c_name | String | Customer name | No | |
c_email | String | Customer emailunique | No | |
c_phone | String | Customer phone numberunique | No | |
customer_token | String | External customer identifierunique | No | The same field as open_api_token |
c_desc | String | Customer description | No | |
c_org | String | Company name | No | If multiple companies are opened, multiple ones are supported, separated by commas in English such as: "handsome, beautiful"; if not opened, only the first one is taken |
c_tags | String | Customer tags | No | Pass customer tags, separated by commas such as: "handsome, beautiful" |
c_owner | String | Customer owner ID | No | |
c_vip | String | 'vip'(VIP customer) or 'normal'(ordinary customer) | No | Customer VIP identification |
c_owner_group | String | Customer responsible group ID | No | |
c_other_emails | String | Other customer email list | No | Separated by commas such as: "a@xxx.cn, b@xxx.cn" |
c_cf_<custom field name> | String | Customer custom field | No | Customer custom field such as: c_cf_name, c_cf_age, ... |
Business Record - Request Parameters
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
c_cn_title | String | Record subject | No | Pass the record subject |
c_cn_<custom field name> | String | Record custom field | No | Record custom field such as: c_cn_name, c_cn_age, ... |
Examples
ud({
"customer": {
"c_name": "Customer Name Kimi",
"c_email": "newest3@udesk.cn",
"c_other_emails": '11@udesk.cn,22@udesk.cn',
"c_desc": "Intentional customer, huge potential",
"c_org": "desc",
"c_phone": "1100110012",
"c_tags": "handsome, newly added",
"c_owner_group": "62",
"c_owner": "3",
"c_vip": "vip",
"c_qq": "123123",
"c_cf_aget": 10,
"c_cf_like": "Extreme Challenge",
"c_cn_title":"Record subject",
"c_cn_name":"Record name",
"nonce": "694db2645b3f69a8",
"signature": "315345C77C73A128CF9850EAD777F7A71D423A36",
"timestamp": "1465878579000",
"web_token": "newest3@udesk.cn"
}
});
Link Example
Encode the passed parameters, otherwise, they may appear as garbled!
Ticket Information - Request Parameters
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
t_subject | String | Ticket subject | No | Ticket subject |
t_content | String | Ticket description | No | If passed, it will be included on the page and will overwrite the message content template |
t_priority_id | String | Ticket priority | No | t_priority_id range 1 (urgent), 2 (high), 3 (standard), 4 (low) Details |
t_status_id | String | Ticket status | No | t_status_id range 1 (open), 2 (resolved), 3 (closed), 4 (in progress) Details |
t_tags | String | Ticket tags | No | Pass ticket tags, separated by commas such as: "tag1, tag2, tag3" |
t_cf_<custom field name> | String | Ticket custom field | No | Ticket custom field, get field details list through API such as: t_cf_TextField_213, t_cf_SelectField_225 Details |
Examples
ud({
"ticket": {
"t_subject": "Ticket subject",
"t_content": "Ticket description",
"t_priority_id": '3',//standard
"t_status_id": "1",//open
"t_tags": "Sound of Thunder, But Hope for Rain, Can Keep You Here",
"t_cf_TextField_213": "Text",
"t_cf_TextField_214": "12:00:00",//time
"t_cf_TextField_215": "2018-10-26",//date
"t_cf_TextField_215": "2018-10-20 12:00",//datetime
"t_cf_SelectField_225": "3",//single select or dropdown
"t_cf_SelectField_226": "1,2",//multi-select
"t_cf_SelectField_227": "0,0",//cascading
}
});
Link Example
Encode the passed parameters, otherwise, they may appear as garbled!
Consultation Object - Parameter Description
Two access methods are provided: URL parameter method, JavaScript access method
Parameter Description
Name | Value | Description |
---|---|---|
title | String | Title |
title_style | String | Title style, for example: color:rgb(50,50,50);font-weight:bold |
url | String | Link to the landing page |
image | String | Display image address |
send | true or false | When true, a send button will appear below the consultation object. Clicking send will send the current consultation object as a product message to the customer service |
<custom parameter> | Multiple custom parameters can be defined, can be in Chinese | |
<custom parameter>_style | String | Custom parameter style |
URL Parameter Method
Add the prefix product_ in front of all parameters. Encode the passed parameters, otherwise, they may appear as garbled!
JavaScript Access Method
ud({
product: {
title: "Apple iPhone 7",
url: "http://item.jd.com/3133829.html?cu=true&utm_source…erm=9457752645_0_11333d2bdbd545f1839f020ae9b27f14",
image: "http://img14.360buyimg.com/n1/s450x450_jfs/t3157/63/1645131029/112074/f4f79169/57d0d44dN8cddf5c5.jpg",
"price": "¥6189.00",
"Promotional price": "¥6188.00"
}
});
Configuration of Client-Side Multilingual Support - Details
Finding Configured Language Codes from Multilingual Configuration
Multilingual feature needs to be enabled separately by contacting Udesk
Management -> Account Settings -> Multilingual Support
Language Name | File Name | Language Code | Update Date | Action |
---|---|---|---|---|
English | reocar_language_translation(en-us).xlsx | en-us | 2017/08/23 14:30 | Download File |
Upload File | ||||
Update |
Select the language code en-us
configured as the parameter for the language. If you need to use French, you need to first configure the multilingual for French, and then use the language code from the 'French Configuration Record' in the multilingual support list.
zh-cn (Simplified Chinese) is already the system default and can be used directly without configuring it in 'Multilingual Support.'
If a language code parameter is passed that is not configured in the 'Multilingual Support List,' the default Simplified Chinese will be used.
The displayed content in frontend static resources now supports Simplified Chinese and English, and does not support custom language translation. If you need support for more languages, please contact us.
Multilingual Language Code Configuration Rules
Language codes can only be selected from the following list:
If the desired multilingual language code is not in the list below, please contact Udesk.
Language Name | Language Code |
---|---|
Arabic | ar |
English | en-us |
Spanish | es |
French | fr |
Japanese | ja |
Korean | ko |
Thai | th |
Indonesian | id |
Traditional Chinese | zh-TW |
Portuguese | pt |
Russian | ru |
Method Description
Method Name | Parameter | Description |
---|---|---|
init | None | Manual initialization, but effective when manualInit is set to true . Example: ud("init") |
hidePanel | None | Manually hide the session panel. Example: ud("hidePanel") |
showPanel | None | Manually open the session panel. Example: ud("showPanel") |
dataTrace | type (Data type), data (Data) | Data tracking including browsing history, events, etc. |
Product Browsing History Upload
Method Description
ud("dataTrace", type, data);
Parameter Description
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
type | String | product | Yes | Tracking type |
data | Object | Yes | Tracking data | |
data.name | String | Yes | Product name | |
data.url | String | No | Product redirect link (opens in new page). Cannot be clicked if value is empty. | |
data.imgUrl | String | No | Image URL. Will not display if value is empty. | |
data.params | Object | No | Parameter list | |
data.params.text | String | No | Parameter text | |
data.params.color | String | No | Parameter color value, specified as hexadecimal color (e.g., #ff0000) | |
data.params.fold | Boolean | No | Whether it's bold | |
data.params.break | Boolean | No | Whether it's line break | |
data.params.size | Number | Default 12 | No | Font size |
Example
// Product browsing history
ud("dataTrace", "product", {
"name": " Apple iPhone X (A1903) 64GB Space Gray Mobile Unicom 4G Phone",
"url": "https://item.jd.com/6748052.html",
"imgUrl": "http://img12.360buyimg.com/n1/s450x450_jfs/t10675/253/1344769770/66891/92d54ca4/59df2e7fN86c99a27.jpg",
"params": [
{
"text": "¥6999.00",
"color": "#FF0000",
"fold": false,
"break": false, //break is a keyword, should be wrapped in quotes for IE8
"size": 12
}
]
});
Order Event Upload
Order event upload requires prior customer authentication, and then can be called using the following methods.
Method Description
ud("dataTrace", type, data);
Parameter Description
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
type | String | order | Yes | Tracking type |
data | Object | Yes | Tracking data | |
data.order_no | String | Yes | Order number | |
data.name | String | Yes | Order name | |
data.url | String | No | Order redirect link | |
data.price | Number | Yes | Order price | |
data.order_at | Date | Yes | Order placement time | |
data.pay_at | Date | No | Payment time | |
data.status | String | Yes | Order status: wait_pay (pending payment), paid (paid), closed (closed) | |
data.remark | String | No | Remark, maximum length is 1000 bytes (Chinese counts as 2 bytes) | |
data.consignee_name | String | No | Consignee name | |
data.consignee_phone | String | No | Consignee phone | |
data.commodit_num | String | No | Total number of commodities | |
commodities | Array | No | Commodity Information Array (Object) |
Commodities Object for Product Information
Parameter Name | Type | Required | Description |
---|---|---|---|
commodit_name | string | No | Product name |
commodit_no | string | No | Product number |
commodit_count | numeric | No | Product quantity |
commodit_fee | string | No | Product price |
Example
ud("dataTrace", "order", {
order_no: '1',
name: 'First Order',
url: 'http://xxx.xxxx.com/order-link',
price: 16.8,
order_at: new Date(),
pay_at: new Date(),
status: 'wait_pay',
remark: 'Remark',
consignee_name: 'tom',
consignee_phone: '01012345',
consignee_address: 'Beijing, China',
commodit_num: 88,
commodities: [
{
commodit_name: 'Milk A',
commodit_no: 'NO123456',
commodit_count: 1,
commodit_fee: '46.5'
}
]
});
Marketing Session Event Tracking
Method Description
ud("dataTrace", type, data);
Parameter Description
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
type | String | marketing | Yes | Tracking type |
data | Object | Yes | Tracking data | |
data.name | String | Yes | Event name |
Example
// Cancel Order
ud("dataTrace", "marketing", {
"name": "Cancel Order"
});
Event Description
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
onReady | Function | Listening event, no parameters | No | Callback for Udesk IM plugin initialization completion |
onUnread | Function | Listening event, parameters: data:{count:1 //unread message count} | No | Callback for unread message event |
Example
ud({
"onReady": function() {
console.log('Initialization complete');
},
"onUnread": function(data) {
console.log('Unread message count: ' + data.count);
}
});
> Button Position Modification (Drag and Drop)
Overview
Mainly used for third-party modification of button positions to implement custom drag and drop events. Modify the CSS (top, right, bottom, left) of class
udesk-client-btn
.
Notes
To prevent dragging clicks from triggering events such as expanding session templates or accepting invitations, you need to: Call
ud('noDrag')
in thedocument.onmousedown
event. Callud('isDrag')
in thedocument.onmousemove
event.
Example
- Modify button position: Customer Service System Backend -> Channel Management -> Instant Messaging -> Web Plugin (Click Manage) -> Button Settings (Top Right)
- Drag and drop modification method: Implemented by the user. You can use native
mousemove
andmouseup
methods, depending on your actual business logic.
Window Settings - Custom URL for Information Area
When using the Udesk web plugin and configuring a custom URL in the window settings of the plugin, you can send messages to Udesk customer service/robots on the configured page.
Basic Usage
The custom URL page communicates with the parent page through postMessage
and needs to follow a specific message format.
Customer service chat interface: Can send text messages and product messages. Robot chat interface: Only supports sending text messages.
Passing Current Window Web Page Link to Custom iframe
The window will pass the parameters of the current web page link to the custom URL's iframe. (Among these four parameters,
cur_url
,cur_title
,pre_url
,src_url
are not passed.)
Parameter Description
Parameter Name | Type | Value | Required | Description |
---|---|---|---|---|
method | String | 'sendMsg' | Yes | Method name, currently only supports sendMsg |
type | String | 'text' or 'product' | Yes | Message type: text message or product message |
content | String or Object | Yes | Message content |
Example
- Text Message
var data = JSON.stringify({
method: "sendMsg", // Fixed method
type: "text", // Fixed type
content: “xxx” // Message to be sent
});
var origin = "*";
window.parent.postMessage(data, origin);
- Product Message Parameter Details
var data = JSON.stringify({
method: "sendMsg", // Fixed method
type: "product", // Fixed type
content: { // Product message format
name: "Apple iPhone X (A1903) 64GB Space Gray Mobile Unicom 4G Phone",
url: "https://item.jd.com/6748052.html",
imgUrl: "http://img12.360buyimg.com/n1/s450x450_jfs/t10675/253/1344769770/66891/92d54ca4/59df2e7fN86c99a27.jpg",
params: [{
text: "¥6999.00",
color: "#FF0000",
fold: false,
break: false,
size: 12
}, {
text: "Add 30 yuan for orders over 1999 yuan"
}]
}
});
var origin = "*";
window.parent.postMessage(data, origin);
Notes
- Please limit the sending frequency.
- Pay attention to the message format.
Custom Search Keywords
Parameter Name | Type | Description |
---|---|---|
udesk_wd | String | Search keyword, passed from third party like Baidu promotion |
Third Party Website Link Example (e.g., Company Official Website)
https://www.companydomain.com?udesk_wd=xxxx
Web Plugin Link Example
https://companydomain.udesk.cn/im_client/?udesk_wd=xxxx
Transmitting Events to External Sources
The web plugin sends events to external sources via window.postMessage
.
Third-party pages receive them by using window.addEventListener('message',function (event) \{ //event \})
.
Example
window.addEventListener('message',function (event) {
/*
Example: Handling session end event
Differentiate event types using the received type, see parameter details for specific event types
*/
let receiveEvent = JSON.parse(event.data)
if (receiveEvent.type === 'chatDone') {
// Custom event
}
})
Value | Description |
---|---|
chatting | Session start event |
chatDone | Session end event |
queuing | Entering queue event |
hidePanel | Hide window event |