sendMessage()
特定のチャットキーを持つチャットに、エージェントから新しいチャットメッセージを送信します。API バージョン 29.0 以降で使用できます。
構文
1sforce.console.chat.sendMessage(chatKey:String, message:String, callback:Function)引数
| 名前 | 型 | 説明 |
|---|---|---|
| chatKey | String | エージェントのメッセージが送信されるチャットの chatKey。 |
| message | String | チャットでエージェントから顧客に送信するメッセージ。 |
| callback | function | メソッドの完了時にコールされる JavaScript メソッド。 |
サンプルコード – Visualforce
1<apex:page >
2 <apex:includeScript value="/support/console/29.0/integration.js"/>
3 <a href="#" onClick="testSendMessage();">Send Message</a>
4
5 <script type="text/javascript">
6
7 function testSendMessage() {
8 //Get the value for 'myChatKey'from the sforce.console.chat.getDetailsByPrimaryTabId() or other chat methods.
9 //These values are for example purposes only
10 var chatKey = 'myChatKey';
11 var text ='This is sample text to send as a message';
12 sforce.console.chat.sendMessage(chatKey, text, sendMessageSuccess);
13 }
14
15 function sendMessageSuccess(result) {
16 //Report whether getting the chat log was successful
17 if (result.success == true) {
18 alert('Message Sent');
19 } else {
20 alert('Sending the message was not successful');
21 }
22 };
23
24
25 </script>
26</apex:page>