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 21: | Line 22: | ||
| JavaScript method executed when API method request is completed | | 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>//HTML element with getState method attached. | ||
+ | |||
+ | <div id="log">Logs...</div>//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 == | == How to Use getState == | ||
+ | # Paste the above sample code onto your page.<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 '''Get State''' 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 example | + | The following is an example of the response you may get when you call ''getState''. |
{ | { | ||
Line 100: | Line 124: | ||
=== Syntax === | === Syntax === | ||
window.bpspat.api.setStatus(status, reason_code="") | window.bpspat.api.setStatus(status, reason_code="") | ||
+ | |||
+ | For example: | ||
+ | window.bpspat.api.setStatus('READY') | ||
=== Parameters === | === Parameters === | ||
Line 119: | Line 146: | ||
|} | |} | ||
+ | === 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...</div>//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 == | ||
+ | # Paste the above sample code onto your page.<br /><br /> | ||
+ | # Save and open the page in your web browser.<br /><br /> | ||
+ | # Make sure the agent is logged in.<br /><br /> | ||
+ | # Click the '''Set Status''' button to initiate the request.<br /><br /> | ||
+ | # View the response data on the page.<br /><br /> | ||
</translate> | </translate> |
Revision as of 17:59, 7 February 2019
<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>//HTML element with getState method attached.
//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
- Paste the above sample code onto your page.
- Save and open the page in your web browser.
- Make sure the agent is logged in.
- Click the Get State button to initiate the request.
- 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.
{ data.agent_id: "john.smith"; data.status: "Not Ready"; data.reason: "Lunch" 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
Name | Data Type | Description |
data.agent_id | string | agent username |
data.status | string | agent state (e.g., "Ready" or "Not Ready") |
data.reason | string | Not Ready reason (e.g., "Lunch" or "Break") |
data.interactions | array | List of interaction data |
data.item.id | string | Interaction ID |
data.global_id | string | Global interaction ID (GIID) |
data.phone_number | string | Customer phone number |
data.service | string | Name of the service handling the interaction |
data.screenpop_data | string | Information shown on screen-pop |
data.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.
//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
- Paste the above sample code onto your page.
- Save and open the page in your web browser.
- Make sure the agent is logged in.
- Click the Set Status button to initiate the request.
- View the response data on the page.
</translate>