Adding Post Metadata

Learn how to apply metadata to individual posts in Modern Chat

Similarly to the Author properties object, you can provide a flat object containing custom-defined metadata key/value pairs in either the window.KHOROS_CONFIG object or set inside a custom delegate before the Send(message) method.

The field is titled metadata and can be set in the delegate with message.metadata = { … }, or statically in the initialization definition.

<script>
const searchBarContents = () => {
    return document.querySelector('#searchBar').value;
};

window.KHOROS_CONFIG = {
    appId,
    companyKey,
    widgetId,
    metadata: {
        stringValue: 'string here',
        boolValue: true,
        numberValue: 42,
        searchBarContents
    }
};
</script>

Alternatively, you can define the metadata in a delegate like this:

window.KHOROS_CONFIG = {
    delegate: {
          beforeSend: function(message) { 
               message.metadata.shoppingCart = document.getElementById('#shoppingCart').innerText; 
          }
    }
}

Brand Messenger Legacy Included Metadata

Modern Chat benefits from four included metadata fields available automatically through Metadata Visibility to your agents. These metadata fields require no additional development effort to work with Modern Chat.

They can also be used in metadata tag rules, enabling you to use data provided through them for actions such as agent routing.

These fields make it easier for agents (and administrators) to identify what the end-user is seeing in their browser with each message sent through Modern Chat.

For example, if your agent is leading an end-user to a specific area of the site, it will let the agent know if the end-user has made it to the right place when they send their next message.

From an administrative standpoint, having the ability to identify userAgent properties aids in troubleshooting should problems arise more often for particular browsers, operating systems, etc. that prompts users to reach out to customer service.

Here is a breakdown of these fields:

Metadata FieldDisplay AsDescription
siteReferrerWebsite ReferrerThe referring website (e.g., www.google.com). This field is unpopulated in cases where the user directly entered the address into the browser's address bar.
clients[0].urlPage URLThe page URL at the moment the post was sent.
clients[0].titlePage TitleThe title of the page at the moment the post was sent.
clients[0].userAgentUser-AgentA string that lets servers and network peers identify the application, operating system, vendor, and/or version of the requesting user agent.
clients[0].platformPlatformThe platform from which the post was made. For Modern Chat, this is almost always WEB.