diff --git a/docs/samples/contact-center/app.js b/docs/samples/contact-center/app.js index b80188142c4..2000f2427d7 100644 --- a/docs/samples/contact-center/app.js +++ b/docs/samples/contact-center/app.js @@ -28,6 +28,7 @@ const agentLoginButton = document.querySelector('#loginAgent'); const dialNumber = document.querySelector('#dialNumber'); const registerStatus = document.querySelector('#ws-connection-status'); const logoutAgentElm = document.querySelector('#logoutAgent'); +const buddyAgentsDropdownElm = document.getElementById('buddyAgentsDropdown'); // Store and Grab `access-token` from sessionStorage if (sessionStorage.getItem('date') > new Date().getTime()) { @@ -183,6 +184,31 @@ function logoutAgent() { }); } +async function fetchBuddyAgents() { + try { + buddyAgentsDropdownElm.innerHTML = ''; // Clear previous options + const buddyAgentsResponse = await webex.cc.getBuddyAgents({mediaType: 'telephony'}); + + if (buddyAgentsResponse.data && buddyAgentsResponse.data.agentList.length === 0) { + console.log('The fetched buddy agents list was empty'); + buddyAgentsDropdownElm.innerHTML = `No buddy agents available`; + return; + } + + buddyAgentsResponse.data.agentList.forEach((agent) => { + const option = document.createElement('option'); + option.text = `${agent.agentName} - ${agent.state}`; + option.value = agent.agentId; + buddyAgentsDropdownElm.add(option); + }); + + } catch (error) { + console.log('Failed to fetch buddy agents', error); + buddyAgentsDropdownElm.innerHTML = ''; // Clear previous options + buddyAgentsDropdownElm.innerHTML = `Failed to fetch buddy agents, ${error}`; + } +} + const allCollapsibleElements = document.querySelectorAll('.collapsible'); allCollapsibleElements.forEach((el) => { el.addEventListener('click', (event) => { diff --git a/docs/samples/contact-center/index.html b/docs/samples/contact-center/index.html index ceea4239d00..97be88b448d 100644 --- a/docs/samples/contact-center/index.html +++ b/docs/samples/contact-center/index.html @@ -80,7 +80,7 @@ - + @@ -91,7 +91,7 @@ Agent Station Login/Logout - + Agent @@ -121,6 +121,11 @@ sate + + Buddy Agents + Get Buddy Agents + + @@ -133,4 +138,4 @@