End, Complete, and Disposition an Interaction
You can bundle several methods together to wrap up interactions for the logged-in agent.
The getState method retrieves agent state information, including the interaction ID that you will need in order to end the interaction. The terminateInteraction method ends an active interaction immediately, placing the agent in after-call work (ACW). The setDisposition method sets the disposition, and completeInteraction completes the interaction. The combination method completeInteractionWithDisp allows you to do both at the same time.
Each method can be attached to a web element, such as a button, on your webpage. When clicked, the button will process it.
In this article, you will learn how to attach each method to a button, declare parameters such as item_id in fields, and place sample JavaScript into HTML.
Sample Code
In this sample code, the methods are attached to button elements.
Copy this sample code for pasting into your HTML file. This is the bare minimum that you need for the SDK to work. Make sure you replace "<tenant>" with the name of your Agent Desktop web server (e.g., "example.brightpattern.com").
<script type="text/javascript" src="https://<tenant>.brightpattern.com/agentdesktop/libs/servicepattern-sdk-v1.js">
</script>
<iframe id="repeater" style="position:absolute; right: 8px; width: 300px; height: 700px;" src="https://<tenant>.brightpattern.com/agentdesktop/UniversalRepeater.jsp"></iframe>
<button onclick="bpspat.api.getState(log)">Get State</button>
<br>
<input id="item" type="text" placeholder="Interaction Id, see Logs"/>
<br>
<br>
<button onclick="bpspat.api.terminateInteraction(document.getElementById('item').value)">Terminate</button>
<br>
<br>
<input id="dispositionItem" type="text" placeholder="Item_id"/>
<input id="disposition" type="text" placeholder="Disposition name"/>
<input id="dispositionCode" type="text" placeholder="Disposition code"/>
<br>
<button onclick="bpspat.api.setDispositionByName(document.getElementById('dispositionItem').value, document.getElementById('disposition').value)">Set Disposition By Name</button>
<button onclick="bpspat.api.setDisposition(document.getElementById('dispositionItem').value, document.getElementById('dispositionCode').value)">Set Disposition By Code</button>
<br>
<br>
<button onclick="bpspat.api.completeInteraction(document.getElementById('item').value)">Complete</button>
<br>
<br>
<input id="item" type="text" placeholder="Interaction Id, see Logs"/>
<input id="disposition" type="text" placeholder="Disposition name"/>
<input id="notes" type="text" placeholder="Notes"/>
<br>
<button onclick="bpspat.api.completeInteractionWithDisp(document.getElementById('item').value,(document.getElementById('disposition').value,(document.getElementById('notes').value)">Complete with Disposition</button>
<br>
<br>
<div id="log">Logs...</div>
<br>
<br>
<script type="text/javascript">
window.bpspat.api.init("https://<tenant>.brightpattern.com");
function log(data) {
let div = document.createElement("div");
div.innerHTML = JSON.stringify(data);
document.getElementById("log").appendChild(div);
}
</script>
Example Exercise
There are many ways to style your page elements and Agent Desktop widget display. The following is provided for example purposes only.
- Paste the
sample code into the body of your HTML file.
- Save and open the page in your web browser. Make sure the agent is logged in and "Ready."
- A call comes in and the agent accepts it.
- During the call, click Get State, which brings up the agent status log data.
- Copy the item_id from the logs and paste it into the Item_ ID field above the Terminate button. That is needed so the system knows which interaction to end.
- Click Terminate to end the call. This places the agent in the after-call work state.
- To disposition the call, paste the item_id into the Item_ID field. Then enter a disposition name or code (one that is already configured for your contact center) in the Set Disposition by Name or Set Disposition by Code fields.
- Click Complete to complete the call. This places the agent in the Ready state.
- Alternatively, you can disposition and complete the call at the same time by entering the same item_id and disposition name, and clicking Complete with Disposition. This exercise includes both methods, so you can pick and choose.
< Previous | Next >