Trying to pass custom authenticated user attributes to the Genesys Cloud Web Messaging widget. The goal is to have the userId and accountId available on the contact object immediately upon connection, without needing a separate flow to fetch them from a CRM later.
We are using the JavaScript SDK. The standard pattern seems to be setting the attributes via genesyscloud.messenger.setGuestAttributes before calling genesyscloud.messenger.init. Here is the implementation:
const config = {
organizationId: 'org-123',
deploymentId: 'deploy-456',
environmentUrl: 'https://api.mypurecloud.com'
};
genesyscloud.messenger.setGuestAttributes({
userId: 'auth-user-789',
accountId: 'acct-001',
tier: 'premium'
});
genesyscloud.messenger.init(config);
The widget loads fine. The chat session starts. However, when we inspect the contact data in using a Get Contact Attributes action, the custom attributes are missing. The built-in userId exists, but our custom keys are not there. The accountId is also absent.
I checked the network tab. The POST /api/v2/conversations/messaging/contacts request shows the payload, but the custom attributes aren’t included in the initial guestAttributes block. They only appear if we send a subsequent message after the session is established, which defeats the purpose of pre-identifying the user.
Is there a specific timing issue here? Or does the SDK require a different method for authenticated users? We’ve tried moving the setGuestAttributes call after init but before the first message, but that feels wrong and still doesn’t populate the contact object at the start of the flow. The documentation is vague on the exact lifecycle hook required for this to work reliably.