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