Genesys Cloud - Main

 View Only
Discussion Thread View
  • 1.  Custom theme in Widget V2

    Posted 02-17-2021 07:29
    Hoping someone can help with an issue I have at the moment implementing the V2 web chat widget with a custom theme. The standard widget code is fine on the page and produces no issues, however when I add the code to register the theme and then make it active I receive the following error response: Uncaught TypeError: Cannot set property 'theme' of undefined at (index):141

    This is the section of code being referred to in the error, to keep it simple the branding has been based on the example included within the Widget development guide

    const customPlugin = CXBus.registerPlugin('Custom');

    window._genesys.widgets.main.theme = "mybrand";
    window._genesys.widgets.main.themes = {
    "mybrand": "cx-theme-mybrand"
    };
    </script>

    I am hoping that I am just missing something very simple, any assistance would be greatly appreciated
    #DigitalChannels

    ------------------------------
    Gareth James
    CALLSCAN AUSTRALIA PTY. LTD.
    ------------------------------


  • 2.  RE: Custom theme in Widget V2

    GENESYS
    Posted 02-18-2021 10:59
    Hello Gareth,
    One reason might be that the variable you are trying to reference does not exist: this may happen if the assignment is executed too early, while the widget libraries have not been loaded. I would recommend that you follow procedure here: basically, store all your configuration object (the window._genesys object) within a separate file, let's say widgets.config.js. In that object, you can already define both 'theme' and 'themes' attributes. Then use the link above to load the widgets.config.js as described: this way it will be loaded at the right moment, and the error might be addressed.

    Alternatively, you should raise ticket with our Support, or try with Developer Center.

    Thanks
    Angelo

    ------------------------------
    Angelo Cicchitto
    Genesys - Employees
    ------------------------------



  • 3.  RE: Custom theme in Widget V2

    GENESYS
    Posted 02-18-2021 13:43
    Hello Gareth,

    The problem for this error is that you probably haven't set the main structure initially (I mean window._genesys.widgets.main).
    So with javascript, you cannot set elements/attributes in this structure directly (like window._genesys.widgets.main.them and window._genesys.widgets.main.themes).
    It would have to be something like this:

    window._genesys.widgets.main = {
      theme: "mybrand",
      themes: {
        "mybrand": "cx-theme-mybrand"
      }
    };

    But if you set this where I think you set this, it still won't work. You have to define the themes at widgets configuration level, before the Widgets plugin are loaded.
    So instead - do this at the same time you define window._genesys.widgets.webchat.

    window._genesys = {
        widgets: {
            main: {
                timeFormat: 24,
                lang: 'en',
                theme: "mybrand",
                themes: {
                    "mybrand": "cx-theme-mybrand"
                },
                mobileMode: 'auto',
                mobileModeBreakpoint: 600
            },
            webchat: {
                transport: {
                    type: 'purecloud-v2-sockets',
                    dataURL: 'https://api.mypurecloud.com',
                    deploymentKey: 'xxxxxxx',
                    orgGuid: 'yyyyyyyyy',
                    interactionData: {
                        routing: {
                            targetType: 'QUEUE',
                            targetAddress: 'ABCD',
                            priority: 2
                        }
                    }
                },
                userData: {}
            }
        }
    };

    Regards,

    ------------------------------
    Jerome Saint-Marc
    Genesys - Employees
    ------------------------------



  • 4.  RE: Custom theme in Widget V2

    Posted 02-18-2021 19:55
    Hi Jerome,

    That's brilliant, thanks for the informative response.

    ------------------------------
    Gareth James
    CALLSCAN AUSTRALIA PTY. LTD.
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources