getAgentState()
Returns the agent's current Chat status, such as Online, Away, or Offline. Available in API version 29.0 or
later.
Syntax
sforce.console.chat.getAgentState(callback:Function)
Arguments
Name | Type | Description |
---|---|---|
callback | function | JavaScript method called upon completion of the method. |
Sample Code–Visualforce
<apex:page>
<apex:includeScript value="/support/console/64.0/integration.js"/>
<a href="#" onClick="testGetAgentState();return false;">Get Agent State</a>
<script type="text/javascript">
function testGetAgentState() {
sforce.console.chat.getAgentState(function(result) {
if (result.success) {
alert('Agent State:' + result.state);
} else {
alert('getAgentState has failed');
}
});
}
</script>
</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 |
---|---|---|
state | String | String representing the current agent state—for example, Online, Away, or Offline. |
success | Boolean | true if getting the agent’s Chat status was successful; false if getting the agent’s Chat status wasn’t successful. |