Newer Version Available

This content describes an older version of this product. View Latest

preChatInit

Use the preChatInit method to access the custom details that have been passed into the chat through the addCustomDetail Deployment API method.

Usage

Extracts the custom details that have been passed into the chat through the addCustomDetail Deployment API method and integrates them into a pre-chat form.

Available in API versions 29.0 and later.

Syntax

liveagent.details.preChatInit(String chatUrl, function detailCallback, (optional) String chatFormName)

Parameters

Name Type Description Available Versions
chatUrl String The URL of the chat to retrieve custom details from. Available in API versions 29.0 and later.
detailCallback String Name of the JavaScript function to call upon completion of the method. Available in API versions 29.0 and later.
(Optional) chatFormName String The name of the HTML form tag for the pre-chat form to which to incorporate the custom details. Available in API versions 29.0 and later.

Responses

Name Type Description Available Versions
details Object An object containing all of the custom details that were included in the pre-chat form using the preChatInit method. Available in API versions 29.0 and later.
The details object has a structure similar to the following example object:
1{
2    "geoLocation":{
3        "countryCode":"US",
4        "countryName":"United States",
5        "longitude":-122.4294,
6        "organization":"SALESFORCE.COM",
7        "latitude":37.764496,
8        "region":"CA",
9        "city":"San Francisco"
10
11    },
12    "customDetails":[
13        {
14            "label":"Email",
15            "value":"sonic@sega.com",
16            "transcriptFields":["Email__c"],
17            "entityMaps":[
18            {
19                "fieldName":"Email",
20                "isAutoQueryable":true,
21                "entityName":"Contact",
22                "isExactMatchable":true,
23                "isFastFillable":false
24            }]
25        },
26        {
27            "label":"Name",
28            "value":"Sonic H.",
29            "transcriptFields":[],
30            "entityMaps":[]
31        }
32    ],
33    "visitorId":"251a5956-bcbc-433d-b822-a87c062e681c"
34}

detailCallback

The detailCallback method specifies the behavior that should occur after the preChatInit method returns the details object.

Syntax Parameters Description Available Versions
1function myCallBack(details) {
2       // Customer specific code
3    }
details Specifies the actions to occur after the custom details are retrieved using the preChatInit method. Available in API versions 29.0 and later.