Android Conversation: Metadata (APAC)

Custom metadata can be sent to Khoros Response, allowing for important contextual information to be relayed to the agent and/or admin that conveys information such as:

  • Operating system
  • Membership status
  • Shopping cart contents
  • App version

We can set and manage metadata going along with messages. There is a set of default metadata that is added to each outgoing message before sending. Additionally, we have an option to set custom metadata.

The default metadata that is set contains the following data:

{
    "vendor", "brandMessenger",
    "os", "android",
    "sdkVersion", BuildConfig.VERSION_NAME, // Eg: 0.3.0
    "appId", packageName), // eg: com.app.brandmessenger
    "appVersion", appInfo.versionName, // eg: 1.0
    "client.appName", appName, // eg: Khoros App
    "client.osVersion", android.os.Build.VERSION.SDK_INT, // eg: 31
    "client.devicePlatform", android.os.Build.MODEL, // eg: Pixel 4 XL
    "client.buildNumber", appInfo.versionCode, // eg: 1
    "client.platform", "android"
}

As you can see, each object must be a flat key/value pair of strings. If there are any other data types other than string, they must be converted to string and sent as key-value pair. Nested objects are not supported at this time.

For adding custom metadata, add the following lines on app initialisation:

BrandMessengerManager.setConversationDelegate(new KBMConversationDelegate() {
    @Override
    public Message modifyMessageBeforeSend(Message message) {
        Map<String, String> customMetadata = new HashMap<>();
        customMetadata.putAll(message.getMetadata());
        // add/remove any metadata including default here
        customMetadata.put("customKey1", "customVal1");
        message.setMetadata(customMetadata);
        return message;
    }
});

Metadata can also be added in a global way (in contrast to per-message method above).

Map<String, String> metadata = new HashMap<>();
BrandMessengerClient.getInstance(context).setMessageMetaData(metadata);
val metadata: Map<String, String> = HashMap()
BrandMessengerClient.getInstance(context).setMessageMetaData(metadata)

Lastly, in the Agent's Admin page, in Developer -> Metadata Visibility, add the Brand Messenger V2 network. This will show the default fields like client.platform.

Add the fields from the dictionary like appName, and they should be visible under each message in the conversation under the metadata section. Displayed metadata names are configurable from the admin tab of the Care web instance.


Did this page help you?