# Agent Presence

In 

# Usage

The agent has selected a pause or available state from the drop-down selector in the masthead. This will return both the current agent state and the previous state together with timestamps for each. This will allow you to calculate the time spent in each state if required.

# Syntax

webClient.onAgentPresenceChange(listener: Function);

# Arguments

Name Type Description
listener function JavaScript method executed when the API method call is completed

# Sample Javascript

const callback = (response) => {
    if (response.error) console.error(response.error);
    if (response.result)
        alert(response.result);
}
webClient.onAgentPresenceChange(callback);

# Response

This method is asynchronous. The response is returned in an object passed to a callback method. The response object contains the following fields.

Result
Example success Response

Returns this object if the API method call was invoked successfully, false otherwise.

{
    result: {
        presence: {
            current: {
                pauseReason: {
                    id:number;
                    title:string;
                    timestamp: number; // unix timestamp 
                }
                ;
                previous: {
                    pauseReason: {
                        id:number;
                        title:string;
                        timestamp: number; // unix timestamp
                    }
                }
            }
        };
        timestamp: number; // unix timestamp
    };
}