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

事後チャットのコードサンプル

このコードサンプルを使用して、エージェントと顧客で事後チャットページがどのように動作するかをテストおよびプレビューします。

従来のチャット製品はメンテナンス専用モードになり、新機能の作成を継続することはできません。引き続き使用可能ですが、新しいチャットチャンネルを実装することは推奨しておりません。代わりにアプリ内および Web のメッセージングにより顧客とのコミュニケーションを最新化できます。メッセージングによって、人気の高い多数のチャット機能に加えて、いつでも再開可能な非同期の会話が利用可能になります。

重要

表示する変数を含めて、事後チャットページをカスタマイズできます。

有効なセッションを必要とするサイトで事後チャットページをホストする場合、チャットの実行時間が長いと、セッションタイムアウトになる可能性があります。事後チャットページを表示していたユーザーがログインページにリダイレクトされた場合、事後チャットのコンテキスト変数が失われます。

メモ

使用可能な変数 説明
requestTime システムでチャット要求を受信したときのタイムスタンプ。
startTime エージェントがチャットを受け入れたときのタイムスタンプ。
deploymentId リリースの ID。
buttonId チャットを開始したボタンの ID。
chatKey 一意のチャットキー。
lastVisitedPage エージェントに送信される前回アクセスしたページの値。
originalReferrer リリースコードが含まれる、顧客がアクセスした最初のページ。
latitude チャット訪問者の地理的位置 (緯度)。
longitude チャット訪問者の地理的位置 (経度)。
city チャット訪問者の地理的位置 (市区郡)。
region チャット訪問者の地理的位置 (地域)。
country チャット訪問者の地理的位置 (国)。
organization チャットをホストした Salesforce 組織 ID。
disconnectedBy チャットを終了した理由。可能な値:
  • agent - エージェントがチャットを終了した
  • client - チャット訪問者がチャットを終了した
  • error - システムでエラーが発生してチャットが切断された
  • clientIdleTimeout - 割り当てられた時間内にチャット訪問者が応答しなかった (アイドルタイムアウトが設定されている必要がある)
  • agentsUnavailable - チャットを受信できるエージェントがいないか、キューに空きがない
windowLanguage チャットボタンに設定されたウィンドウの言語。
chatDetails チャットデータの JSON 表現。
transcript トランスクリプトのプレーンテキストコピー。
attachedRecords JSON 配列形式のチャットセッションに割り当てられた ID のリスト。
error チャット中に発生したエラーの説明。
次のコードサンプルでは、チャットに関する基本情報を含む事後チャットページが作成されます。
1<apex:page showHeader='false'>
2      <div id='details'>
3      <!-- This will present all the post chat parameters available to this page -->
4            <h1>Post Chat Page</h1>   
5            <p>  
6            <!-- These variables are passed to the post-chat page and can be used to customize your post-chat experience -->
7                  Request Time:  <apex:outputText id='c_rt' value='{!$CurrentPage.parameters.requestTime}' /><br/>
8                  Start Time:  <apex:outputText id='c_st' value='{!$CurrentPage.parameters.startTime}' /><br/>
9                  Deployment Id: <apex:outputText value='{!$CurrentPage.parameters.deploymentId}' /><br/>
10                  Button Id: <apex:outputText value='{!$CurrentPage.parameters.buttonId}' /><br/>
11                  Chat Key: <apex:outputText value='{!$CurrentPage.parameters.chatKey}' /><br />
12                  Last Visited Page: <apex:outputText value='{!$CurrentPage.parameters.lastVisitedPage}' /><br/>
13                  Original Referrer: <apex:outputText value='{!$CurrentPage.parameters.originalReferrer}' /><br/>
14                  <!-- When the GeoLocation is not available this will appear as Unknown -->
15                  Latitude: <apex:outputText value='{!$CurrentPage.parameters.latitude}' /><br/>   
16                  Longitude: <apex:outputText value='{!$CurrentPage.parameters.longitude}' /><br/>
17                  City: <apex:outputText value='{!$CurrentPage.parameters.city}' /><br/>
18                  Region: <apex:outputText value='{!$CurrentPage.parameters.region}' /><br/>
19                  Country: <apex:outputText value='{!$CurrentPage.parameters.country}' /><br/>
20                  <!-- End of GeoLocation information -->
21                  Organization: <apex:outputText value='{!$CurrentPage.parameters.organization}' /><br/>
22                  Disconnected By: <apex:outputText value='{!$CurrentPage.parameters.disconnectedBy}' /><br/>
23                  Window Language: <apex:outputText value='{!$CurrentPage.parameters.windowLanguage}' /><br/>
24                  Chat Details: <apex:outputText value='{!$CurrentPage.parameters.chatDetails}' /><br />
25                  Transcript: <apex:outputText value='{!$CurrentPage.parameters.transcript}' /><br/>     
26                  Attached Records : <apex:outputText value='{!$CurrentPage.parameters.attachedRecords}' /><br />
27                  Error: <apex:outputText value='{!$CurrentPage.parameters.error}' /><br />
28            </p>
29      </div>
30      <hr/>
31      <!-- Message to show if chat is abandoned -->
32      <div id='abandoned' style='display: none;'>
33          We are sorry you decided to leave the chat. Feel free to initiate a new session.
34      </div>
35      <!-- Code to decide if we show the abandoned block or the full data -->
36      <script type='text/javascript'>
37            var requestTime = '{!$CurrentPage.parameters.requestTime}';
38            var startTime = '{!$CurrentPage.parameters.startTime}';
39            // when startTime doesn't have a value, it means the chat never started
40            if (!startTime) {
41                  document.getElementById('details').style.display = 'none';
42                  document.getElementById('abandoned').style.display = 'block';
43            }
44      </script>
45
46</apex:page>

このコードでは、次の事後チャットページがエージェントに表示されます。

事後チャットページ

チャットが中止されると、次のメッセージが表示されます。

チャットが中止されたときの事後チャット