We are instrumenting the Genesys Cloud Web Messaging SDK (v1.2.0) to track customer journey metrics in New Relic. The setup involves identifying users before they start a chat session. We’ve configured the widget to accept custom attributes via the onReady callback, but the attributes aren’t showing up in the conversation metadata in the Genesys UI or the analytics export.
Here’s the initialization code running in the browser context:
pureCloudMessaging.init({
organizationId: 'ORG_ID',
deploymentId: 'DEPLOY_ID',
onReady: (messaging) => {
const user = getCurrentUser(); // Returns { id: '123', name: 'Sam' }
messaging.setGuestAttributes({
'userId': user.id,
'customerTier': 'Gold',
'source': 'mobile-app'
});
console.log('Attributes set:', messaging.getGuestAttributes());
}
});
The console log confirms the attributes are stored locally in the widget instance. However, when I inspect the API response from GET /api/v2/conversations/guests/{guestId} shortly after the session starts, the attributes object is empty.
{
"id": "guest-uuid",
"attributes": {},
"externalContactId": null
}
We’ve verified that the deployment configuration allows custom attributes. The setGuestAttributes method seems to be a local state operation until the first message is sent or the session is explicitly started. Is there a specific SDK method we need to call to flush these attributes to the server before the startSession call? Or is there a delay in the propagation that we’re missing?
We’ve tried calling messaging.startSession() immediately after setting the attributes, but the result is the same. The userId is critical for our New Relic entity correlation, so we can’t wait for the first message to trigger the sync. Any pointers on the correct sequence of SDK calls?