• Chris Mollan
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Users are forgetting to set their status to online when they load up the service cloud console.  How can I automate this so that the users status is always set to online when they load the console?

 
I am trying to use the console integration kit to automatically set the user to online for Live Agent when they start the service cloud console.  Below is my code for a footer component.  It has two ways to set the agent status.  The first is near the bottom of the script where the function to set online is automatically run when the page loads.  The second is a link that the user can click.

There seems to be a timing problem.  The function does run automatically, but it seems to run before the Live Agent component initializes.  I am guessing that my function sets the agent online and then the Live Agent component resets to offline.

I think it is a timing problem because using the link after everything has started does sets the agent online.

Is there an event I can listen for or something else that allows my component to wait until everything is initialized?
<apex:page showHeader="false" sidebar="false">
    <apex:includeScript value="/support/console/29.0/integration.js"/>

    <a href="#" onClick="fnSetAgentState('Online');return false;">Set Agent Status to Online</a> 

    <script type="text/javascript">
        function fnGetAgentState() {
            sforce.console.chat.getAgentState(function(result) {
                if (result.success) {
                    alert('Agent State: ' + result.state);
                } else {
                    alert('getAgentState has failed');
                }
            });
        }
    
        function fnSetAgentState(state) {
            sforce.console.chat.setAgentState(state, function(result) {
                if (result.success) {
                    fnGetAgentState();
                } else {
                    alert('Live Agent: SetAgentState has failed');
                }
            });
        }
        
        fnSetAgentState('Online');
    </script>
</apex:page>