getDetails
getDetails JavaScript メソッドは、リリース API および事前チャット API を使用して渡されたカスタム詳細とチャット情報にアクセスして Visualforce チャットウィンドウ���取り込むために使用します。
使用方法
リリース API および事前チャット API を使用してチャットに渡されたチャット情報とカスタム詳細を抽出し、この情報を Visualforce チャットウィンドウに統合します。カスタム Visualforce チャットウィンドウ内でこのメソッドをコールします。
チャット情報およびカスタム詳細が変更されたか利用可能になったときにこのメソッドをコールします。これらの詳細が利用可能になったか更新されたことを確認するには、次の 3 つの必要なイベントをチャットウィンドウのコードに含める必要があります。
1liveagent.addEventListener(liveagent.chasitor.Events.CHAT_REQUEST_SUCCESSFUL, myCallBack);
2 liveagent.addEventListener(liveagent.chasitor.Events.CHAT_ESTABLISHED, newagent);
3 liveagent.addEventListener(liveagent.chasitor.Events.AGENT_CHAT_TRANSFERRED, newagent);次のコードサンプルで、これらのイベントを取り込む方法を確認できます。
API バージョン 29.0 以降で使用できます。
構文
liveagent.chasitor.getDetails();
応答
| 名前 | 型 | 説明 | 使用可能なバージョン |
|---|---|---|---|
| details | Object | Visualforce チャットウィンドウに取り込むすべてのカスタム詳細を含むオブジェクト。 | API バージョン 29.0 以降で使用できます。 |
getDetails メソッドは、次のサンプルオブジェクトに類似した構造を持つ details JavaScript オブジェクトを返します。
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":"example@salesforce.com",
16 "transcriptFields":[],
17 "entityMaps":[]
18 },
19 {
20 "label":"Email",
21 "value":"sonic@sega.com",
22 "transcriptFields":["Email__c"],
23 "entityMaps":[
24 {
25 "fieldName":"Email",
26 "isAutoQueryable":true,
27 "entityName":"Contact",
28 "isExactMatchable":true,
29 "isFastFillable":false
30 }]
31 }
32 ],
33 "prechatDetails":[
34 {
35 "label":"prechat field",
36 "value":"any info",
37 "transcriptFields":[],
38 "entityMaps":[]
39 }],
40 “agent” : {
41 "agentName":"jsmith",
42 "userId":"005x0000001JGgr",
43 "transfer":0
44 },
45 "visitorId":"251a5956-bcbc-433d-b822-a87c062e681c",
46}コードサンプル
1<apex:page showHeader="false">
2
3<script type='text/javascript'>
4 liveagent.addEventListener(liveagent.chasitor.Events.CHAT_REQUEST_SUCCESSFUL,
5 myCallBack);
6 liveagent.addEventListener(liveagent.chasitor.Events.CHAT_ESTABLISHED,
7 newagent);
8 liveagent.addEventListener(liveagent.chasitor.Events.AGENT_CHAT_TRANSFERRED,
9 newagent);
10
11 function myCallBack() {
12 var details = liveagent.chasitor.getDetails();
13// ..
14 }
15
16 function newagent() {
17 var details = liveagent.chasitor.getDetails();
18// …
19 }
20</script>
21
22<style>
23html {
24 padding: 20px;
25}
26body {
27 background-color: #778899;
28 overflow: hidden;
29 width: 100%;
30 height: 100%;
31 padding: 20px;
32 margin: 0
33}
34#waitingMessage {
35 color:white;
36 height: 100%;
37 width: 100%;
38 vertical-align: middle;
39 text-align: center;
40 display: none;
41 }
42#liveAgentClientChat.liveAgentStateWaiting #waitingMessage { display: table; }
43#liveAgentSaveButton, #liveAgentEndButton { z-index: 2; }
44.liveAgentChatInput {
45 top:8px;
46 height: 25px;
47 border-width: 1px;
48 border-style: solid;
49 border-color: #BB0000;
50 padding: 2px 0 2px 4px;
51 background: #fff;
52 display: block;
53 width: 99%;
54}
55.liveAgentSendButton {
56 display: block;
57 width: 60px;
58 height: 31px;
59 padding: 0 0 3px;
60 position: absolute;
61 top: 0;
62 right: -67px;
63}
64#liveAgentChatLog {
65 border-color: #BB0000;
66 background-image:linear-gradient(#DDEEFF, #AABBCC);
67 box-shadow: 10px 10px 5px #888888;
68 border-radius: 10px;
69 padding:10px;
70 width: auto;
71 height: auto;
72 top: 3px;
73 position: absolute;
74 overflow-y: auto;
75 left: 0;
76 right: 0;
77 bottom: 0;
78}
79</style>
80
81<div style="top: 0; left: 0; right: 0; bottom: 0; position: absolute; padding:10px;">
82<liveAgent:clientchat >
83 <liveAgent:clientChatSaveButton label="Save Chat" />
84 <liveAgent:clientChatEndButton label="End Chat" />
85 <div id="prechatdata">
86 </div>
87 <div style="top: 30px; left: 5px; right: 5px; bottom: 5px;
88 position: absolute; z-index: 0;">
89 <liveAgent:clientChatAlertMessage />
90 <liveAgent:clientChatStatusMessage />
91 <table id="waitingMessage" cellpadding="0" cellspacing="0">
92 <tr>
93 <td>Please wait while you are connected to an available agent.</td>
94 </tr>
95 </table>
96 <div style="top: 0; right: 0; bottom: 41px; left: 0; padding: 0;
97 position: absolute; word-wrap: break-word; z-index: 0;">
98 <liveAgent:clientChatLog />
99 </div>
100 <div style="position: absolute; height: auto; right: 0; bottom: 0; left: 0;
101 margin-right: 67px;">
102 <liveagent:clientChatInput /><liveAgent:clientChatSendButton label="Send"/>
103 </div>
104 </div>
105</liveAgent:clientchat>
106</div>
107</apex:page>