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

開発 API のコードサンプル

リリース API がリリースのカスタマイズにどのように役立つかをテストおよびプレビューします。
次のコードサンプルでは、次の開発 API メソッドを使用するチャットウィンドウを示します。
  • startChat
  • showWhenOnline
  • showWhenOffline
  • addCustomDetail
  • setName
  • map
  • setChatWindowWidth
  • setChatWindowHeight
  • doKnowledgeSearch
1<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 exactly matches "john@acme.com"
29  liveagent.addCustomDetail('Contact E-mail', 'john@acme.com');
30  liveagent.findOrCreate('Contact').map('Email','Contact E-mail',true,true,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  // An auto query that searches contacts whose first name field  matches "John Doe"
35  liveagent.addCustomDetail('Contact Name', 'John Doe');
36  liveagent.findOrCreate('Contact').map('FirstName','Contact Name',true,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>

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

Live Agent のリリース