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

エージェントへの直接転送のコードサンプル

リリース API を使用してエージェントへの直接転送を実装します。

次のコードサンプルは、エージェントが訪問者に [私とチャット] リンクを送信できるようにエージェントへの直接転送を設定する方法を示します。

1<apex:page standardController="User" showHeader="false">
2  <h1>Direct-to-Agent Chat with {!user.name}</h1>
3
4  <!-- dta_online is displayed whenever the specific agent is available to chat. -->
5  <div id="dta_online" style="display: none;">
6
7    <!-- A valid button is required here even though it's direct-to-agent - some button settings still apply. -->
8    <!-- {!left(user.id,15)} is needed to truncate an 18-char ID to the 15-char version that Live Agent uses. -->
9    <a href="javascript://Chat" onclick="liveagent.startChat('573D01234567890', '{!left(user.id,15)}')">Chat with {!user.name}!</a>
10
11  </div>
12
13  <!-- dta_offline is displayed if the specific agent is unavailable. -->
14  <div id="dta_offline" style="display: none;">
15
16    <!-- button_online is displayed if any agents are available to chat for the button. -->
17    <div id="button_online" style="display: none;">Sorry, {!user.name} is not available. If you&rsquo;d like, you can
18      <a href="javascript://Chat" onclick="liveagent.startChat('573D01234567890')">start a chat with another agent</a>.
19    </div>
20
21    <!-- button_offline is displayed if no agents are available to chat for the button. -->
22    <div id="button_offline" style="display: none;">Sorry, all agents (including {!user.name}) appear to be unavailable.</div>
23
24  </div>
25
26  <!-- Change the domain name to the correct one for your org. -->
27  <script type='text/javascript' src='https://c.la1s1.saleforceliveagent.com/content/g/deployment.js'></script>
28
29  <script type='text/javascript'>
30    /* The following calls pass the user ID as the first argument and show whether the agent is online.*/
31    liveagent.showWhenOnline('{!left(user.id,15)}', document.getElementById('dta_online'));
32    liveagent.showWhenOffline('{!left(user.id,15)}', document.getElementById('dta_offline'));
33
34    /* The following calls pass the button ID as the first argument and show whether 
35    any agents are available to handle chats from the button. */
36    liveagent.showWhenOnline('573D01234567890', document.getElementById('button_online'));
37    liveagent.showWhenOffline('573D01234567890', document.getElementById('button_offline'));
38
39    /* This domain and the IDs are specific to your org, so replace these with your own. */
40    liveagent.init('https://d.la1s1.salesforceliveagent.com/chat', '572D01234567890', '00DD01234567890');
41  </script>
42</apex:page>

組織でこのコードサンプル (ChatWithMe) を使用すると、エージェントはチャット要求を直接送信するリンクを作成できます。

http://your.website/ChatWithMe?id=005D01234567890

どのエージェントも使用できるクイックテキストメッセージを作成することで、エージェントはより簡単に [私とチャット] リンクを作成できます。

http://your.website/ChatWithMe?id={!User_ID}

リンクの User ID の部分には、クイックテキストを使用するエージェントのユーザ ID が自動的に入力されます。