Newer Version Available

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

Deployment API Code Sample

Test and preview how the Deployment API can help you customize your deployments.
The following code sample shows a chat window that uses the following Deployment API methods:
  • startChat
  • showWhenOnline
  • showWhenOffline
  • addCustomDetail
  • setName
  • map
  • setChatWindowWidth
  • setChatWindowHeight
  • doKnowledgeSearch
1swfobject.registerObject("clippy.codeblock-0", "9");<apex:page >
2    <h1>Welcome!</h1>
3      Thank you for contacting customer support.
4
5    <!-- START Button code -->
6      <img id="liveagent_button_online_573D000000000Ar" style="display: none; 
7      border: 0px none; cursor: pointer" onclick="liveagent.startChat('573D000000000Ar')"
8      src="https://na1.salesforce.com/resource/1319587702000/Chat_Online" />
9
10      <img id="liveagent_button_offline_573D000000000Ar" style="display: none;
11      border: 0px none;
12      "src="https://na1.salesforce.com/resource/1319587748000/Chat_Offline" />
13
14      <script type="text/javascript">
15        if (!window._laq) { window._laq = []; }
16          window._laq.push(function(){liveagent.showWhenOnline('573D000000000Ar',
17          document.getElementById('liveagent_button_online_573D000000000Ar'));
18          liveagent.showWhenOffline('573D000000000Ar',
19          document.getElementById('liveagent_button_offline_573D000000000Ar'));
20        });</script>
21    <!-- END Button code -->
22
23<!-- Deployment code -->
24<script type='text/javascript'
25  src='https://c.la1s1.saleforceliveagent.com/content/g/deployment.js'></script>
26
27<script type='text/javascript'>
28  // An auto query that searches contacts whose email field matches "john@acme.com"
29  liveagent.addCustomDetail('Contact E-mail', 'john@acme.com');
30  liveagent.findOrCreate('Contact').map('Email','Contact E-mail',true,false,false);
31  // Conducts a Knowledge One search on the provided value; in this case,
32  // searches Knowledge One articles for the term "Problems with my iPhone"
33  liveagent.addCustomDetail('Case Subject', 'Problem with my iPhone').doKnowledgeSearch();
34  // A fast-fill to populate a contact’s name with "John Doe"
35  liveagent.addCustomDetail('Contact Name', 'John Doe');
36  liveagent.findOrCreate('Contact').map('FirstName','Contact Name',false,false,false);
37  // Saves the custom detail to a custom field on LiveChatTranscript at the end of a chat
38  liveagent.addCustomDetail('Company', 'Acme').saveToTranscript('Company__c');
39  // Overrides the display name of the visitor in the agent console when engaged in a chat
40  liveagent.setName('John Doe');
41  // Sets the width of the chat window to 500px
42  liveagent.setChatWindowWidth(500);
43  // Sets the height of the chat window to 500px
44  liveagent.setChatWindowHeight(500);
45  liveagent.init('https://d.la1s1.salesforceliveagent.com/chat', '572D0000000002R',
46'00DD0000000JXbY');
47</script>
48</apex:page>
49

This deployment code results in a page that looks like this:

Live Agent Deployment