Passing CRM ID in Web Messaging SDK startChat() not persisting to Genesys Cloud

I’m trying to pass a CRM customer ID into the Genesys Cloud Web Messaging SDK using the startChat() method. The goal is to have this ID available in the conversation context for WFM reporting.

Here is the code snippet I am using:

const guest = new GenesysWebMessaging.Guest({
 orgId: 'my-org-id',
 deploymentId: 'my-deployment-id'
});

guest.startChat({
 name: 'Test User',
 email: 'test@example.com',
 customAttributes: {
 crmId: 'CUST-12345'
 }
});

The chat starts successfully. However, when I check the conversation details via the API endpoint /api/v2/conversations/messaging, the customAttributes field is empty. The name and email fields are populated correctly.

I’ve checked the Network tab in the browser dev tools. The initial POST to the deployment endpoint includes the customAttributes in the payload. But it seems like Genesys Cloud is stripping it out before storing it.

Is there a specific configuration in the Web Deployment settings that needs to be enabled to allow custom attributes? Or is the startChat() method signature different for passing CRM data?

I’ve tried adding the ID to the attributes object instead of customAttributes, but that didn’t work either.

The startChat method signature you’re using doesn’t actually accept a customAttributes object directly in that version of the SDK. You’re likely seeing the data drop because it’s being ignored silently.

You need to attach the CRM ID as a custom attribute after the guest object is initialized but before you kick off the chat session. The Web Messaging SDK exposes a setCustomAttributes method on the guest instance.

Try this pattern:

const guest = new GenesysWebMessaging.Guest({
 orgId: 'my-org-id',
 deploymentId: 'my-deployment-id'
});

// Set attributes before starting the chat
guest.setCustomAttributes({
 'crmId': '123456789',
 'sourceSystem': 'InternalPortal'
});

guest.startChat({
 name: 'Test User',
 email: 'test@example.com'
});

Make sure those custom attributes are also defined in the Genesys Cloud UI under Messaging > Deployments > Custom Attributes. If they aren’t whitelisted there, the API will reject them regardless of what you pass in the client. Check the browser console for a 400 error if it still fails.

Yep, setCustomAttributes on the guest instance does the trick. Just make sure you call it right after initialization and before startChat, otherwise the SDK drops the data.