Webchat via GTM for serving multiple sites

Hi there. We are implementing Webchat with CoBrowse over three different sites in one corporate family. But we would like to centralise the JS setup to avoid duplication and overhead, but maintain the ability to customize properties in the config on page load. Example: override Priority and inject userData to the config provided via GTM.

The examples in the documentation seem to assume the config would be setup embedded on a page. Has anyone included PureCloud on a site using GTM or even an external CDN? And if so, how did you go about adding/altering properties in the config directly from the site state?

Code example in case this is still unclear. Imagine this is injected by GTM:

var chatButton = document.getElementById('chatHeader');
ININ.webchat.create(chatConfig)
        .then(function (webchat) {
            chatButton.onclick = function () {
                var agentEmail = '';
                webchat.getConfig().setAgentEmail(agentEmail);
                webchat.renderFrame({
                    containerEl: 'chatContainer'
                });
            };
        })
        .catch(function (err){
            console.log(err);
        });

How would I do the equivalent of this command from my page after the above is loaded (could I?):

webchat.getConfig().setData({"firstName": firstName, "lastName": lastName});

Thanks

I think the most straightforward way would be to construct the chatConfig object dynamically based on your needs. Once it's been configured to your liking, pass it to ININ.webchat.create(chatConfig).

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.