getAgentInput()

Returns the string of text which is currently in the agent’s text input area in the chat log of a chat with a specific chat key. Available in API version 29.0 or later.

Syntax 

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

Arguments 

NameTypeDescription
chatKeyStringThe chatKey associated with the chat for which to retrieve the agent’s input text.
callbackfunctionJavaScript method called upon completion of the method.

Sample Code–Visualforce 

1<apex:page >
2    <apex:includeScript value="/support/console/68.0/integration.js"/>
3    <a href="#" onClick="testGetAgentInput();">Get Agent Input</a> 
4
5    <script type="text/javascript">
6
7        function testGetAgentInput() {
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            sforce.console.chat.getAgentInput(chatKey, getAgentInputSuccess);
12        }
13        
14        function getAgentInputSuccess(result) {
15            //Report whether getting the agent's input was successful
16            if (result.success == true) {
17                agentInput = result.text;
18                alert('The text in the agent input is: ' + agentInput);
19            } else {
20                alert('Getting the agent input was not successful');
21            }
22        };
23    
24
25    </script>
26</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:

NameTypeDescription
textStringThe text that is currently in an agent’s text input area.
successBooleantrue if getting the agent’s input was successful; false if getting the agent’s input wasn’t successful.