These docs are for v0.0.1. Click to read the latest docs for v1.0.61.

Discussions

Ask a Question
Back to All

widget framework methods not working...

when i call api2.getInteractionCapabilities() it returns undefined

when i call api2.getInteractionServices() it returns an object that looks like this:

these issues are reported by a customer and reproduced by me on NA Demo 02. in both cases, we are calling api2.onDataEvent('onAnyInteractionEvent', callback); in connectedCallback(), and calling the getInteractionxxx methods from there.

is this the correct behavior for these methods (and the documentation is wrong)? or, is there a bug? or, are we doing it wrong? in which case, how are these supposed to be used?

Code is below:

connectedCallback() {
    // Create UWF Notification API instance.
    console.log("Connected Callback called");

    const interactionId = this.getAttribute('interactionid');
    console.log(interactionId);
    api2 = window.WS.widgetAPI();
    console.log(api2);

    api2.onDataEvent('onAnyInteractionEvent', callbackagain);

    shadowRoot.querySelector( "#lookUpCust").addEventListener( "click", () => searchForCJ());
    shadowRoot.querySelector( "#callCustomer").addEventListener( "click", () => callOut());
	shadowRoot.querySelector( "#callCustomer").style.visibility = "hidden";

    function callbackagain(data) {
        if( data.length == 0) {
			if( interactionState == "INACTIVE") {
				return console.log( "interactionEvent: no data already INACTIVE");
			}
            interactionState = "INACTIVE";
            console.log( "interactionEvent: callback with no data");
			shadowRoot.querySelector( "#contentArea").innerHTML = getTemplate();
			shadowRoot.querySelector( "#lookUpCust").addEventListener( "click", () => searchForCJ());
			shadowRoot.querySelector( "#callCustomer").addEventListener( "click", () => callOut());
			shadowRoot.querySelector( "#callCustomer").style.visibility = "hidden";
            return;
        }
        if( data[0].state == interactionState) {
            console.log( "interactionEvent: duplicate event for state " + interactionState);
            return;
        }
        interactionState = data[0].state;
        console.log( "interactionEvent: " + data[0].state + " Channel: " + data[0].channel);
		console.log( api2.getInteractionCapabilities());
		console.log( api2.getInteractionServices());