diff --git a/docs/samples/contact-center/app.js b/docs/samples/contact-center/app.js
index 4144f3ac6f2..cb81ddb920a 100644
--- a/docs/samples/contact-center/app.js
+++ b/docs/samples/contact-center/app.js
@@ -15,6 +15,9 @@ let webex;
let sdk;
let agentDeviceType;
let deviceId;
+let agentStatusId;
+let agentStatus;
+let agentId;
const authTypeElm = document.querySelector('#auth-type');
const credentialsFormElm = document.querySelector('#credentials');
@@ -27,6 +30,8 @@ const agentLogin = document.querySelector('#AgentLogin');
const agentLoginButton = document.querySelector('#loginAgent');
const dialNumber = document.querySelector('#dialNumber');
const registerStatus = document.querySelector('#ws-connection-status');
+const idleCodesDropdown = document.querySelector('#idleCodesDropdown')
+const setAgentStatusButton = document.querySelector('#setAgentStatus');
const logoutAgentElm = document.querySelector('#logoutAgent');
const buddyAgentsDropdownElm = document.getElementById('buddyAgentsDropdown');
@@ -116,6 +121,7 @@ function register() {
console.log('Event subscription successful: ', agentProfile);
teamsDropdown.innerHTML = ''; // Clear previously selected option on teamsDropdown
const listTeams = agentProfile.teams;
+ agentId = agentProfile.agentId;
listTeams.forEach((team) => {
const option = document.createElement('option');
option.value = team.id;
@@ -133,8 +139,22 @@ function register() {
option.value = voiceOptions;
agentLogin.add(option);
});
+
+ const idleCodesList = agentProfile.idleCodes;
+
+ if(idleCodesList.length > 0) setAgentStatusButton.disabled = false;
+
+ idleCodesList.forEach((idleCodes) => {
+ if(idleCodes.isSystemCode === false) {
+ const option = document.createElement('option');
+ option.text = idleCodes.name;
+ option.value = idleCodes.id;
+ idleCodesDropdown.add(option);
+ }
+ });
+
}).catch((error) => {
- console.log('Event subscription failed', error);
+ console.error('Event subscription failed', error);
})
}
@@ -173,6 +193,22 @@ function doAgentLogin() {
});
}
+async function handleAgentStatus(event) {
+ const select = document.getElementById('idleCodesDropdown');
+ auxCodeId = event.target.value;
+ agentStatus = select.options[select.selectedIndex].text;
+}
+
+function setAgentStatus() {
+ let state = "Available";
+ if(agentStatus !== 'Available') state = 'Idle';
+ webex.cc.setAgentState({state, auxCodeId, lastStateChangeReason: agentStatus, agentId}).then((response) => {
+ console.log('Agent status set successfully', response);
+ }).catch(error => {
+ console.error('Agent status set failed', error);
+ });
+}
+
function logoutAgent() {
webex.cc.stationLogout({logoutReason: 'logout'}).then((response) => {
diff --git a/docs/samples/contact-center/index.html b/docs/samples/contact-center/index.html
index 97be88b448d..356dda80793 100644
--- a/docs/samples/contact-center/index.html
+++ b/docs/samples/contact-center/index.html
@@ -116,9 +116,11 @@