diff --git a/docs/samples/contact-center/app.js b/docs/samples/contact-center/app.js index 5776f561046..e2aa257225e 100644 --- a/docs/samples/contact-center/app.js +++ b/docs/samples/contact-center/app.js @@ -148,11 +148,41 @@ async function handleAgentLogin(e) { } } +async function fetchBuddyAgents() { + try { + const buddyAgentsResponse = await webex.cc.getBuddyAgents({channelName: 'telephony', state: 'Available'}); + const buddyAgentsDropdown = document.getElementById('buddyAgentsDropdown'); + buddyAgentsDropdown.innerHTML = ''; // Clear previous options + + if (buddyAgentsResponse.agentList.length === 0) { + const option = document.createElement('option'); + option.text = 'No buddy agents available'; + option.disabled = true; + buddyAgentsDropdown.add(option); + return; + } + + buddyAgentsResponse.agentList.forEach((agent) => { + const option = document.createElement('option'); + option.text = `${agent.agentName} - ${agent.state}`; + option.value = agent.agentId; + buddyAgentsDropdown.add(option); + }); + } catch (error) { + const buddyAgentsDropdown = document.getElementById('buddyAgentsDropdown'); + buddyAgentsDropdown.innerHTML = ''; // Clear previous options + const option = document.createElement('option'); + option.text = `Failed to fetch buddy agents, ${error}`; + option.disabled = true; + buddyAgentsDropdown.add(option); + console.log('Failed to fetch buddy agents', error); + } +} + function doAgentLogin() { webex.cc.stationLogin({teamId: teamsDropdown.value, loginOption: agentDeviceType, dialNumber: dialNumber.value}).then((response) => { console.log('Agent Logged in successfully', response); - } - ).catch((error) => { + }).catch((error) => { console.log('Agent Login failed', error); }); } diff --git a/docs/samples/contact-center/index.html b/docs/samples/contact-center/index.html index f6a2cdbf6e1..34f76e83882 100644 --- a/docs/samples/contact-center/index.html +++ b/docs/samples/contact-center/index.html @@ -80,7 +80,7 @@