Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| vendors:cisco:wxcc:widgets [2026/02/25 14:05] – [Headless Social Auto Answer Widget] gerardorourke | vendors:cisco:wxcc:widgets [2026/02/26 11:19] (current) – gerardorourke | ||
|---|---|---|---|
| Line 142: | Line 142: | ||
| ===== Change RONA V2 ====== | ===== Change RONA V2 ====== | ||
| + | |||
| + | This Widget is based on Aashish Berry **change-rona** widget which is located here: | ||
| + | *https:// | ||
| + | |||
| + | It has 2 enhancements over the original. | ||
| + | |||
| + | * It stops double initialization - which seems to happen in WxCC gadgets? (when you press f5 and look at the console logs - it often get double logs) | ||
| + | * < | ||
| + | if (initialized) return; // stop double initialization of Widget | ||
| + | this.init(); | ||
| + | initialized = true; | ||
| + | } | ||
| + | </ | ||
| + | * The original version attempted to make the agent available after the delaySeconds timer expires - no matter what. i.e. Even if in the mean time, the agent have moved from RONA and back into Idle with manual code. This is not what users would want. This is now prevented by checking, just before moving the agent into available, that the current state is indeed still Idle RONA. Only if its Idle due to RONA will it attempt move the agent back to an Available state. | ||
| + | |||
| + | * Note - As the user logs in the widget the widget loads, it then pauses for 15 seconds before loading the rest of the code. If the agent has NOT completed login by this time (i.e. if the user does not complete login by confirming their team / extension), the events to catch the RONA events do not trigger and the gadget does not work as intended. | ||
| + | |||
| + | **Package: | ||
| + | *download above and to run locally (http:// | ||
| + | *npm install | ||
| + | *npm run build | ||
| + | *npm run dev | ||
| + | |||
| + | |||
| + | <file JavaScript change-rona.js> | ||
| + | /* | ||
| + | /* | ||
| + | Update on Sample Gadget provided by Aashish Berry (aaberry) - https:// | ||
| + | This version checks BEFORE attempting to make the agent available that the agent state is Idel with Idle Code of ' | ||
| + | Only then will it allow the agent state to move back to available. | ||
| + | |||
| + | This allows an agent to go Idle with different reason code (manually) and the widget will NOT pushed the agent back into available automatically | ||
| + | It also not allow the gadget to attempt to move the agent into available again even if the agent is already available! | ||
| + | */ | ||
| + | |||
| + | import { Desktop } from ' | ||
| + | |||
| + | const logger = Desktop.logger.createLogger(' | ||
| + | logger.info(' | ||
| + | let initialized = false; | ||
| + | |||
| + | class changeRona extends HTMLElement { | ||
| + | |||
| + | constructor() { | ||
| + | super(); | ||
| + | this.attachShadow({ mode: " | ||
| + | } | ||
| + | |||
| + | connectedCallback() { | ||
| + | if (initialized) return; // stop double initialization of Widget | ||
| + | this.init(); | ||
| + | initialized = true; | ||
| + | } | ||
| + | |||
| + | disconnectedCallback() { | ||
| + | Desktop.agentContact.removeAllEventListeners(); | ||
| + | Desktop.agentStateInfo.removeAllEventListeners(); | ||
| + | } | ||
| + | |||
| + | sleep = (delay) => new Promise(r => setTimeout(r, | ||
| + | |||
| + | |||
| + | async init() { | ||
| + | logger.info(' | ||
| + | await this.sleep(15000); | ||
| + | await Desktop.config.init({ widgetName: " | ||
| + | |||
| + | if (this.delaySeconds) { | ||
| + | logger.info(' | ||
| + | this.delaySeconds = this.delaySeconds * 1000; | ||
| + | } | ||
| + | else { | ||
| + | this.delaySeconds = 10000; | ||
| + | logger.info(' | ||
| + | } | ||
| + | |||
| + | logger.info(" | ||
| + | this.agentInteractionEvents(); | ||
| + | } | ||
| + | |||
| + | async agentInteractionEvents() { | ||
| + | // | ||
| + | Desktop.agentContact.addEventListener(" | ||
| + | logger.info(' | ||
| + | this.triggerChange(); | ||
| + | }); | ||
| + | |||
| + | } | ||
| + | |||
| + | async triggerChange() { | ||
| + | await this.sleep(this.delaySeconds); | ||
| + | logger.info(" | ||
| + | if (Desktop.agentStateInfo.latestData.idleCode.name === ' | ||
| + | logger.info(" | ||
| + | try { | ||
| + | await Desktop.agentStateInfo.stateChange({ | ||
| + | state: ' | ||
| + | auxCodeIdArray: | ||
| + | }); | ||
| + | logger.info(" | ||
| + | } catch (e) { | ||
| + | logger.error(e); | ||
| + | } | ||
| + | }else{ | ||
| + | logger.info(" | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | window.customElements.define(" | ||
| + | </ | ||