Web Messaging SDK: Setting custom guest attributes for authenticated users

We are integrating the Genesys Cloud Web Messaging widget and need to pass custom attributes to identify authenticated users. The documentation suggests using setAttributes on the widget instance, but the values are not appearing in the conversation metadata in Architect. We are calling genesysCloudMessaging.setAttributes({ userId: '12345' }) after the onReady event fires. The API call returns success, but the agent sees an empty guest object. Is there a specific timing requirement or a different API endpoint we should be hitting to persist this data?

The docs say you can set attributes on the guest, but there’s a catch. You can’t just call setAttributes on the widget instance after onReady if you want them to persist as part of the identity. The widget API is a bit tricky here.

“Guest attributes must be set before the conversation is initiated or via the identify method for authenticated users.”

If you’re calling setAttributes after the chat starts, it might just be transient. Try using genesysCloudMessaging.identify({ userId: '12345', customAttr: 'value' }) instead. This links the identity to the guest session properly.

Here’s how I handle it in our .NET backend when redirecting to the widget:

var payload = new {
 userId = user.Id,
 customData = new Dictionary<string, string> {
 { "crmId", user.CrmId },
 { "tier", user.Tier }
 }
};
// Pass this via URL params or local storage before loading the script

Make sure your Architect flow is actually mapping those custom attributes to the conversation metadata. Sometimes the API succeeds, but the flow doesn’t pick them up if the keys don’t match exactly. Check the flow logs.

Cause: The guest identity locks after the first message. setAttributes only updates metadata, it doesn’t merge into the core identity object if the session is already active.

Solution: Use identify instead. It replaces the anonymous guest with your authenticated user.

genesysCloudMessaging.identify({ id: '12345', name: 'User' });

Make sure you call this before the user types anything.