Newer Version Available

This content describes an older version of this product. View Latest

acceptChat()

Accepts a chat request. Available in API version 29.0 or later. This method isn't supported with Omni-Channel in API version 37.0 or later.

Syntax

1sforce.console.chat.acceptChat(chatKey:String, (optional)callback:Function)

Arguments

Name Type Description
chatKey String The chat key for the chat request you wish to accept.
callback function JavaScript method called upon completion of the method.

Sample Code–Visualforce

1<apex:page>
2    <apex:includeScript value="/support/console/47.0/integration.js"/>
3    <a href="#" onClick="testAcceptChat();return false;">Accept Chat</a> 
4
5    <script type="text/javascript">
6        function testAcceptChat() {
7            //Get the value for 'myChatKey'from the getChatRequests() or onChatRequested() methods. 
8            //These values are for example purposes only
9            var chatKey = 'myChatKey';
10            sforce.console.chat.acceptChat(chatKey, acceptSuccess);
11        }
12        
13        function acceptSuccess(result) {
14            //Report whether accepting the chat was succesful
15            if (result.success == true) {
16                alert('Accepting the chat was successful');
17            } else {
18                alert('Accepting the chat was not successful');
19            }
20        };
21    </script>
22</apex:page>

Response

This method is asynchronous so it returns its response in an object in a callback method. The response object contains the following properties:

Name Type Description
success Boolean true if accepting the chat was successful; false if accepting the chat wasn’t successful.