logo

Custom Parameter Scheme Document for Mini Programs

Overview

Due to limitations within mini programs themselves, it is currently not possible to retrieve user information via API. Therefore, Udesk utilizes the session-from parameter supported by mini programs to achieve this functionality. The session-from parameter supports up to 1000 characters. To ensure normal usage, the length of this field should be kept <= 1000 bytes. It supports customer system information, custom fields, business titles, and business custom fields.

Configuration Method

  1. Log in to the WeChat Mini Program platform at: https://mp.weixin.qq.com/
  2. Go to Development->Basic Configuration to obtain Developer ID (AppID) and Developer Password (AppSecret).
  3. Go to Udesk: Management Center->Channel Management->Mini Programs->Access WeChat Mini Program, fill in Developer ID and Developer Password.
  4. Paste the generated URL address and Token into the mini program backend message push. Paste the randomly generated EcodingAESKey into the system, as well as paste APPSercret into the system.
  5. User information can be obtained through this mini program.

Supported Fields

Field Explanation

Customer Field Reference

Business Record Field Reference

Parameter NameExplanation
customer_nameCustomer name, default is 'Mini Program User' (system field)
nick_nameNickname
avatarAvatar
emailEmail
customer_tokenCustomer external unique identifier, equivalent to token
ipIP
descriptionCustomer description
organization_idCompany ID
tagsTags
owner_idCustomer owner ID
owner_group_idCustomer owner group ID
levelLevel
cellphonesPhone numbers, format is array, including parameters id (phone id), cellphone (phone number), id is empty when adding customer phone, non-empty when updating customer phone, format see example
other_emailsOther emails, format is array, including parameters id (email id), other_email (other email address), id is empty when adding customer email, non-empty when updating customer email, format see example
custom_fieldsCustom fields
generated_channelCustom channel name

Usage Instructions

Parameter Configuration

var customer_info = {
    "customer_name": "Customer Name", // Udesk system field
    "email": "test@udesk.cn", // Email
    "customer_token": 'test_token', // Customer external ID
    "generated_channel": 'Custom Channel Name',
    "ip": "192.168.1.1", // IP
    "description": "Description",
    "organization_id": 1, // Company ID
    "tags": "Tag1,Tag2", // Tags separated by comma
    "owner_id": 1, // Customer owner ID
    "owner_group_id": 1, // Customer owner group ID
    "level": "normal", // Level
    "cellphones": [
      ["", "13100000002"], // Array format [[phone ID, phone number]]
      ["3", "13100000003"] // When id is empty string or null, it means adding phone number; when it has value, it means updating the phone number corresponding to this id
      ], 
    "other_emails": [
      ["", "13100000002@udesk.cn"], // Array format [[email ID, email]]
      ["1", "13100000003@udesk.cn"] // When id is empty string or null, it means adding email; when it has value, it means updating the email corresponding to this id
      ], 
    "custom_fields": {
        "TextField_1": "Normal text content",
    }
}

var nick_name = "jack" // Mini program customer nickname
var avatar = "https://www.udesk.cn/images/index/logo1124.png" // Customer avatar

var note_info = {
    "title": "Business Record Title",
    "custom_fields": {
        "TextField_1": "Normal text content",
    }
}

var unionid = "ocpX10_1hQmCVGXzKrMwu-g7yuzU" // Mini program user unionid

// Convert to string
customer_info_str = JSON.stringify(customer_info)
note_info_str = JSON.stringify(note_info)

Inline Example


<!-- session-from = "udesk|Mini Program User Nickname|Avatar|customer^Customer Information|note^Business Record Information|unionid^Mini Program User Unionid" -->

<button open-type="contact" size="mini" session-from="udesk|{{nick_name}}|{{avatar}}|customer^{{customer_info_str}}|note^{{note_info_str}}|unionid^{{unionid}}">Enter Customer Session</button>

Help Center Access Instructions

http://udesk.udesk.cn/hc/articles/54089

Reference Example Code

https://github.com/wangmingle/weixin_mini_test.git

Behavioral Trajectory SDK

Before using, you need to open the behavioral trajectory. To open the behavioral trajectory, please contact the corresponding implementer. Udesk Mini Program SDK is used to collect customer's product browsing trajectory, order events, etc., and display them in IM Console > Session > Visitor Trajectory. If the mini program is not set in the Udesk customer service system, it needs to be set in [Management Center>Channel Management>Mini Programs - Access WeChat Mini Programs]

Obtaining and Using SDK

Download SDK After successful download, put the file in the root directory utils directory of the mini program, and import it in app.js import UdeskSdk from './utils/ud-sdk';

// Import sdk in app.js at the first line
import UdeskSdk from './utils/ud-sdk';

UdeskSdk.init({
  appId: 'xxxxxxxx',
  companyToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  companyDomain: 'xxx.udeskdemo.cn',
  onPageShow: function(){
    //do something
  }
});

Domain Setting

After logging in to the mini program background, we can see the AppID and server domain name in the menu "Development"-"Development Settings" (AppSecret must be configured)

Domain Setting

Initialization

Method Explanation

UdeskSdk.init({ appId, companyToken, companyDomain, onPageShow, onPageHide });

Parameter Explanation

Parameter NameTypeValueRequiredExplanation
appIdStringYesMini program appId
companyTokenStringYesCompany Mini Program authentication Token
companyDomainStringYesCompany domain, such as: xxx.udesk.cn
onPageShowFunctionNoAccepts page display event
onPageHideFunctionNoAccepts page hide event

> Product Browsing Trajectory Upload

Method Explanation

Call this function before initialization

UdeskSdk.trace(type, data);

Parameter Explanation

Parameter NameTypeValueRequiredExplanation
typeStringproductYesTracking type
dataObjectYesTracking data
data.nameStringYesProduct name
data.urlStringNoProduct jump link (display in new page), if empty, cannot be clicked
data.imgUrlStringNoIf empty, not displayed
data.paramsObjectNoParameter list
data.params.textStringNoParameter text
data.params.colorStringNoParameter color value, specified as hexadecimal color value (such as #ff0000)
data.params.foldBooleanNoWhether to bold
data.params.breakBooleanNoWhether to wrap
data.params.sizeNumberDefault 12NoFont size

Example

import UdeskSdk from './utils/ud-sdk';

UdeskSdk.trace('product', {
  name: " Apple iPhone X (A1903) 64GB Space Gray Mobile 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
  }]
});

> Order Event Upload

Method Explanation

Call this function before initialization

UdeskSdk.trace(type, data);

Parameter Explanation

Parameter NameTypeValueRequiredExplanation
typeStringorderYesTracking type
dataObjectYesTracking data
data.order_noStringYesOrder number
data.nameStringYesOrder name
data.urlStringNoOrder jump link
data.priceNumberYesOrder price
data.order_atDateYesOrder placement time
data.pay_atDateNoPayment time
data.statusStringYesOrder status: wait_pay (to be paid), paid (paid), closed (closed)
data.remarkStringNoRemarks, maximum length is 1000 bytes (2 bytes per Chinese character)
data.consignee_nameStringNoConsignee name
data.consignee_phoneStringNoConsignee phone number
data.commodit_numStringNoTotal number of products
commoditiesArrayNoProduct Information Array (Object)

commodities Product Information Object

Parameter NameTypeRequiredExplanation
commodit_namestringNoProduct name
commodit_nostringNoProduct number
commodit_countnumericNoProduct quantity
commodit_feestringNoProduct price

Example

import UdeskSdk from './utils/ud-sdk';

UdeskSdk.trace('order', {
  order_no: "1000",
  name: "First Order",
  url: "https://xxx.xxxx.com/order link",
  price: 16.8,
  order_at: new Date(),
  pay_at: new Date(),
  status: "wait_pay",
  remark: "Remarks up to 1000 bytes",
  consignee_name: 'jack',
  consignee_phone: '01012345',
  consignee_address: 'Beijing, Daxing District',
  commodit_num: 88,
  commodities: [
    {
      commodit_name: 'Milk A',
      commodit_no: 'NO123456',
      commodit_count: 1,
      commodit_fee: '46.5'
    }
  ]
});