この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

開発 API のコードサンプル

リリース API がリリースのカスタマイズにどのように役立つかをテストおよびプレビューします。
次のコードサンプルでは、次の開発 API メソッドを使用するチャットウィンドウを示します。
  • startChat
  • showWhenOnline
  • showWhenOffline
  • addCustomDetail
  • setName
  • map
  • setChatWindowWidth
  • setChatWindowHeight
  • doKnowledgeSearch
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<apex:page >
18    <h1>Welcome!</h1>
19      Thank you for contacting customer support.
20
21    <!-- START Button code -->
22      <img id="liveagent_button_online_573D000000000Ar" style="display: none; 
23      border: 0px none; cursor: pointer" onclick="liveagent.startChat('573D000000000Ar')"
24      src="https://na1.salesforce.com/resource/1319587702000/Chat_Online" />
25
26      <img id="liveagent_button_offline_573D000000000Ar" style="display: none;
27      border: 0px none;
28      "src="https://na1.salesforce.com/resource/1319587748000/Chat_Offline" />
29
30      <script type="text/javascript">
31        if (!window._laq) { window._laq = []; }
32          window._laq.push(function(){liveagent.showWhenOnline('573D000000000Ar',
33          document.getElementById('liveagent_button_online_573D000000000Ar'));
34          liveagent.showWhenOffline('573D000000000Ar',
35          document.getElementById('liveagent_button_offline_573D000000000Ar'));
36        });</script>
37    <!-- END Button code -->
38
39<!-- Deployment code -->
40<script type='text/javascript'
41  src='https://c.la1s1.saleforceliveagent.com/content/g/deployment.js'></script>
42
43<script type='text/javascript'>
44  // An auto query that searches contacts whose email field exactly matches "john@acme.com"
45  liveagent.addCustomDetail('Contact E-mail', 'john@acme.com');
46  liveagent.findOrCreate('Contact').map('Email','Contact E-mail',true,true,false);
47  // Conducts a Knowledge One search on the provided value; in this case,
48  // searches Knowledge One articles for the term "Problems with my iPhone"
49  liveagent.addCustomDetail('Case Subject', 'Problem with my iPhone').doKnowledgeSearch();
50  // An auto query that searches contacts whose first name field  matches "John Doe"
51  liveagent.addCustomDetail('Contact Name', 'John Doe');
52  liveagent.findOrCreate('Contact').map('FirstName','Contact Name',true,false,false);
53  // Saves the custom detail to a custom field on LiveChatTranscript at the end of a chat
54  liveagent.addCustomDetail('Company', 'Acme').saveToTranscript('Company__c');
55  // Overrides the display name of the visitor in the agent console when engaged in a chat
56  liveagent.setName('John Doe');
57  // Sets the width of the chat window to 500px
58  liveagent.setChatWindowWidth(500);
59  // Sets the height of the chat window to 500px
60  liveagent.setChatWindowHeight(500);
61  liveagent.init('https://d.la1s1.salesforceliveagent.com/chat', '572D0000000002R',
62'00DD0000000JXbY');
63</script>
64</apex:page>
65

このリリースコードの結果は、次のようなページになります。

Live Agent のリリース