From Bright Pattern Documentation
Jump to: navigation, search
Line 2: Line 2:
 
= Agent State =
 
= Agent State =
 
Agent State is used to request an agent's state and interaction information, as well as to change an agent's state. Use either ''getState'' or ''setStatus''.
 
Agent State is used to request an agent's state and interaction information, as well as to change an agent's state. Use either ''getState'' or ''setStatus''.
 
  
 
== getState ==
 
== getState ==
Line 29: Line 28:
 
   
 
   
 
  <iframe id="repeater" style="position:absolute; right: 8px; width: 200px; height: 200px;" src="https://<tenant>.brightpattern.com/agentdesktop/UniversalRepeater.jsp"></iframe>//The Agent Desktop widget ("repeater") and display properties. In the source, replace "<tenant>" with your actual Agent Desktop web server name.
 
  <iframe id="repeater" style="position:absolute; right: 8px; width: 200px; height: 200px;" src="https://<tenant>.brightpattern.com/agentdesktop/UniversalRepeater.jsp"></iframe>//The Agent Desktop widget ("repeater") and display properties. In the source, replace "<tenant>" with your actual Agent Desktop web server name.
   
 
<button onclick="bpspat.api.getState(log)">Get State</button>//HTML element with getState method attached.
 
 
   
 
   
  <div id="log">Logs...</div>//Logs section.
+
  <button onclick="bpspat.api.getState(log)">Get State</button>//Button with getState method attached.
 +
 +
<<nowiki />div id="log">Logs...</div>//Logs section.
 
   
 
   
 
  <script type="text/javascript">//Gets agent state data.
 
  <script type="text/javascript">//Gets agent state data.
Line 41: Line 40:
 
  }
 
  }
 
  </script>
 
  </script>
 
  
 
== How to Use getState ==
 
== How to Use getState ==
# Paste the above sample code onto your page.<br /><br />
+
# Paste the above sample code into the body of your HTML page.<br /><br />
 
# Save and open the page in your web browser.<br /><br />
 
# Save and open the page in your web browser.<br /><br />
 
# Make sure the agent is logged in.<br /><br />
 
# Make sure the agent is logged in.<br /><br />
 
# Click the '''Get State''' button to initiate the request.<br /><br />
 
# Click the '''Get State''' button to initiate the request.<br /><br />
 
# View the response data on the page.<br /><br />
 
# View the response data on the page.<br /><br />
 
  
 
== Response ==
 
== Response ==
 
=== Example Response ===
 
=== Example Response ===
The following is an example of the response you may get when you call ''getState''.
+
The following is an example of the response you may get when you call ''getState''. Every time the state changes, the logs display the updated agent state:
  
  {
+
Logs...
data.agent_id: "john.smith";
+
  {"command":"STATE_CHANGED","data":{"status":"ready","reason":""}}
data.status: "Not Ready";
+
{"command":"STATE_CHANGED","data":{"status":"not_ready","reason":"Not ready"}}
data.reason: "Lunch"
+
{"command":"STATE_CHANGED","data":{"status":"not_ready","reason":"A+ Super Star!!!"}}
data.interactions: [ {
 
data.item_id: "123123123";
 
data.global_id: "asd234asdf234df"
 
data.phone_number: "55511122233"
 
data.service: "Customer Support"
 
data.screenpop_data: "Case: 123123"
 
data.attached_data: {a:b, c:d}
 
data.service: "Customer Support";
 
  }, ...
 
]
 
}
 
  
 
=== Response Fields ===
 
=== Response Fields ===
Line 76: Line 62:
 
| '''Data Type'''
 
| '''Data Type'''
 
| '''Description'''
 
| '''Description'''
 +
| '''Example'''
 
|-
 
|-
| data.agent_id
+
| agent_id
 
| string
 
| string
 
| agent username
 
| agent username
 +
| "john.smith"
 
|-
 
|-
| data.status
+
| status
 
| string
 
| string
| agent state (e.g., "Ready" or "Not Ready")
+
| agent state
 +
| "Not ready"
 
|-
 
|-
| data.reason
+
| reason
 
| string
 
| string
| Not Ready reason (e.g., "Lunch" or "Break")
+
| Not Ready reason
 +
| "Lunch"
 
|-
 
|-
| data.interactions
+
|interactions
 
| array
 
| array
| List of interaction data
+
| List of interaction data, including data items below
 +
| "item_id":"5B07EFE4-0658-45E0-AA6E-23AA042C1F0E","screenpop_data":{}
 
|-
 
|-
| data.item.id
+
| item.id
 
| string
 
| string
 
| Interaction ID
 
| Interaction ID
 +
| "5B07EFE4-0658-45E0-AA6E-23AA042C1F0E"
 
|-
 
|-
| data.global_id
+
| global_id
 
| string
 
| string
 
| Global interaction ID (GIID)
 
| Global interaction ID (GIID)
 +
| "0CB4F48D-C4D8-4C9F-94F5-770AD5002C40"
 
|-
 
|-
| data.phone_number
+
| phone_number
 
| string
 
| string
| Customer phone number
+
| Phone number dialed (either extension number or full number)
 +
| "1012"
 
|-
 
|-
| data.service
+
| service
 
| string
 
| string
 
| Name of the service handling the interaction
 
| Name of the service handling the interaction
 +
| "Maintenance Renewal"
 
|-
 
|-
| data.screenpop_data
+
| screenpop_data
 
| string
 
| string
 
| Information shown on screen-pop
 
| Information shown on screen-pop
 +
| -
 
|-
 
|-
| data.attached_data
+
| attached_data
 
| object
 
| object
 
| File attachments
 
| File attachments
 +
| -
 
|}
 
|}
 
  
 
== setStatus ==
 
== setStatus ==
Line 149: Line 145:
 
The following is the minimum that you need to paste into your HTML webpage in order to use ''setStatus''.
 
The following is the minimum that you need to paste into your HTML webpage in order to use ''setStatus''.
  
  <script type="text/javascript" src="https://<tenant>.brightpattern.com/agentdesktop/libs/servicepattern-sdk-v1.js"> </script>//JavaScript that calls on your tenant's (contact center's) Agent Desktop and the SDK libraries. In the source, replace "<tenant>" with your actual Agent Desktop web server name.
+
  <script type="text/javascript" src="https://<tenant>.brightpattern.com/agentdesktop/libs/servicepattern-sdk-v1.js"> </script>
 +
//JavaScript that calls on your tenant's (contact center's) Agent Desktop and the SDK libraries. In the source, replace "<tenant>" with your actual Agent Desktop web server name.
 
   
 
   
 
  <iframe id="repeater" style="position:absolute; right: 8px; width: 200px; height: 200px;" src="https://<tenant>.brightpattern.com/agentdesktop/UniversalRepeater.jsp"></iframe>//The Agent Desktop widget ("repeater") and display properties. In the source, replace "<tenant>" with your actual Agent Desktop web server name.
 
  <iframe id="repeater" style="position:absolute; right: 8px; width: 200px; height: 200px;" src="https://<tenant>.brightpattern.com/agentdesktop/UniversalRepeater.jsp"></iframe>//The Agent Desktop widget ("repeater") and display properties. In the source, replace "<tenant>" with your actual Agent Desktop web server name.
 
      
 
      
  <button onclick="bpspat.api.setStatus('READY')">Set Status</button>//HTML element with setStatus method  attached to set agent state to Ready.
+
  <button onclick="bpspat.api.setStatus('READY')">Set Status</button>
 +
//HTML element with setStatus method  attached to set agent state to Ready.
 
   
 
   
<div id="log">Logs...</div>//Logs section.
+
  <<nowiki />div id="log">Logs...</div>//Logs section.
 
   
 
   
 
  <script type="text/javascript">
 
  <script type="text/javascript">
 
             //initiate script with origin of Agent Desktop embedded on the page
 
             //initiate script with origin of Agent Desktop embedded on the page
             window.bpspat.api.init(window.location.href.substring(0,  
+
             window.bpspat.api.init(window.location.href.substring(0, window.location.href.indexOf("/agentdesktop/AgentDesktopSdkTest.jsp")));//remove suffix, pass origin
window.location.href.indexOf("/agentdesktop/AgentDesktopSdkTest.jsp")));//remove suffix, pass origin
 
 
   
 
   
 
             document.getElementById("repeater").src = window.location.href.replace("AgentDesktopSdkTest", "UniversalRepeater");
 
             document.getElementById("repeater").src = window.location.href.replace("AgentDesktopSdkTest", "UniversalRepeater");
Line 172: Line 169:
 
             window.bpspat.api.addStatusChangeHandler(log);
 
             window.bpspat.api.addStatusChangeHandler(log);
 
  </script>
 
  </script>
 
  
 
== How to Use setStatus ==
 
== How to Use setStatus ==

Revision as of 19:22, 7 February 2019

• 5.19 • 5.3 • 5.8

<translate>

Agent State

Agent State is used to request an agent's state and interaction information, as well as to change an agent's state. Use either getState or setStatus.

getState

Requests information about an agent's current state and interactions. Note that the agent must be logged in to Agent Desktop in order to use getState.

Syntax

window.bpspat.api.getState(callback)
callback = function(data) {
}

Parameters

Parameter Type Description
callback function JavaScript method executed when API method request is completed

Sample Code

The following is the minimum that you need to paste into your HTML webpage in order to use getState.

<script type="text/javascript" src="https://<tenant>.brightpattern.com/agentdesktop/libs/servicepattern-sdk-v1.js"> </script>//JavaScript that calls on your tenant's (contact center's) Agent Desktop and the SDK libraries. In the source, replace "<tenant>" with your actual Agent Desktop web server name.

<iframe id="repeater" style="position:absolute; right: 8px; width: 200px; height: 200px;" src="https://<tenant>.brightpattern.com/agentdesktop/UniversalRepeater.jsp"></iframe>//The Agent Desktop widget ("repeater") and display properties. In the source, replace "<tenant>" with your actual Agent Desktop web server name.

<button onclick="bpspat.api.getState(log)">Get State</button>//Button with getState method attached.

<div id="log">Logs...//Logs section.

<script type="text/javascript">//Gets agent state data.
function log(data) {
let div = document.createElement("div");
div.innerHTML = JSON.stringify(data);
document.getElementById("log").appendChild(div);
}
</script>

How to Use getState

  1. Paste the above sample code into the body of your HTML page.

  2. Save and open the page in your web browser.

  3. Make sure the agent is logged in.

  4. Click the Get State button to initiate the request.

  5. View the response data on the page.

Response

Example Response

The following is an example of the response you may get when you call getState. Every time the state changes, the logs display the updated agent state:

Logs...
{"command":"STATE_CHANGED","data":{"status":"ready","reason":""}}
{"command":"STATE_CHANGED","data":{"status":"not_ready","reason":"Not ready"}}
{"command":"STATE_CHANGED","data":{"status":"not_ready","reason":"A+ Super Star!!!"}}

Response Fields

Name Data Type Description Example
agent_id string agent username "john.smith"
status string agent state "Not ready"
reason string Not Ready reason "Lunch"
interactions array List of interaction data, including data items below "item_id":"5B07EFE4-0658-45E0-AA6E-23AA042C1F0E","screenpop_data":{}
item.id string Interaction ID "5B07EFE4-0658-45E0-AA6E-23AA042C1F0E"
global_id string Global interaction ID (GIID) "0CB4F48D-C4D8-4C9F-94F5-770AD5002C40"
phone_number string Phone number dialed (either extension number or full number) "1012"
service string Name of the service handling the interaction "Maintenance Renewal"
screenpop_data string Information shown on screen-pop -
attached_data object File attachments -

setStatus

Requests an agent routing state change (with or without a reason code).

Syntax

window.bpspat.api.setStatus(status, reason_code="")

For example:

window.bpspat.api.setStatus('READY')

Parameters

Parameter Data Type Required/Optional Description
status string required Specifies the agent state to be set
reason_code number optional Specifies the reason for agent state change

Sample Code

The following is the minimum that you need to paste into your HTML webpage in order to use setStatus.

<script type="text/javascript" src="https://<tenant>.brightpattern.com/agentdesktop/libs/servicepattern-sdk-v1.js"> </script>
//JavaScript that calls on your tenant's (contact center's) Agent Desktop and the SDK libraries. In the source, replace "<tenant>" with your actual Agent Desktop web server name.

<iframe id="repeater" style="position:absolute; right: 8px; width: 200px; height: 200px;" src="https://<tenant>.brightpattern.com/agentdesktop/UniversalRepeater.jsp"></iframe>//The Agent Desktop widget ("repeater") and display properties. In the source, replace "<tenant>" with your actual Agent Desktop web server name.
    
<button onclick="bpspat.api.setStatus('READY')">Set Status</button>
//HTML element with setStatus method  attached to set agent state to Ready.

<div id="log">Logs...//Logs section.

<script type="text/javascript">
            //initiate script with origin of Agent Desktop embedded on the page
            window.bpspat.api.init(window.location.href.substring(0, window.location.href.indexOf("/agentdesktop/AgentDesktopSdkTest.jsp")));//remove suffix, pass origin

            document.getElementById("repeater").src = window.location.href.replace("AgentDesktopSdkTest", "UniversalRepeater");

            function log(data) {
                let div = document.createElement("div");
                div.innerHTML = JSON.stringify(data);
                document.getElementById("log").appendChild(div);
            }

            window.bpspat.api.addStatusChangeHandler(log);
</script>

How to Use setStatus

  1. Paste the above sample code onto your page.

  2. Save and open the page in your web browser.

  3. Make sure the agent is logged in.

  4. Click the Set Status button to initiate the request.

  5. View the response data on the page.


</translate>

< Previous | Next >