Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Use webchattonic.updateContext(context) to update the current web chat context, that then triggers (optionally) a change context flow to be handled by the bot, and sets the context to be sent in each subsequent message by the user. See Installation and usage for more information on what it does.

Code Block
languagejs
document.addEventListener('readystatechange', function(event) {
    if (event && event.target && event.target.readyState === 'complete') {
        setTimeout(function() {
            if (webchattonic) {
                webchattonic.updateContext('new context');
            }
        }, 3000)
    }
})

Change the user’s metadata

Use webchattonic.updateMetadata(metadata) to update the user’s metadata information. See Installation and usage for more information on what variables are allowed to be sent.

Code Block
languagejs
document.addEventListener('readystatechange', function(event) {
    if (event && event.target && event.target.readyState === 'complete') {
        setTimeout(function() {
            if (webchattonic) {
                var metadata = {
                    firstName: 'Name',
                    lastName: 'Lastname'
                    'profile.id': 'Some external id'
                }
                webchattonic.updateMetadata(metadata);
            }
        }, 3000)
    }
})