Web Messaging SDK: startChat() custom attributes not appearing in conversation metadata

I’m trying to pass a CRM customer ID through the Genesys Cloud Web Messaging SDK using the startChat method, but the value isn’t making it into the conversation metadata on the backend. Here’s the setup:

I’ve got a React frontend that fetches the customer ID from our internal CRM API before initializing the chat widget. The goal is to have this ID available in the Genesys Cloud conversation object so we can tag it correctly and route it to agents who have context on the customer.

Here’s the JavaScript code I’m using to initialize the chat:

const genApi = await GenesysCloudWebMessaging.init({
 organizationId: 'my-org-id',
 deploymentId: 'my-deployment-id',
});

const customerData = {
 customerId: 'CRM-12345', // This is what I want to pass
 name: 'John Doe'
};

await genApi.startChat({
 attributes: {
 externalCustomerId: customerData.customerId,
 customerName: customerData.name
 },
 language: 'en',
 routing: {
 queueId: 'my-queue-id'
 }
});

The chat starts successfully, and I can see the conversation in the Genesys Cloud admin console. However, when I look at the conversation details via the API (/api/v2/conversations/messages/{id}), the attributes object is empty. I’m not seeing externalCustomerId or customerName anywhere in the JSON payload.

I’ve checked the Network tab in Chrome DevTools, and the request to the Genesys Cloud messaging endpoint does include the attributes field in the POST body. It looks like this:

{
 "attributes": {
 "externalCustomerId": "CRM-12345",
 "customerName": "John Doe"
 },
 "language": "en",
 "routing": {
 "queueId": "my-queue-id"
 }
}

So the data is being sent. I’m wondering if there’s a specific configuration in the Genesys Cloud deployment settings that needs to be enabled to allow custom attributes from the SDK? Or maybe I’m using the wrong key names? The docs mention attributes but don’t give a clear example for startChat.

I’ve also tried using setData before startChat, but that seems to be for updating existing data, not initializing it. Any ideas on what I’m missing?

The startChat config object doesn’t map directly to conversation metadata in the way you’re expecting. You need to use setCustomData before initiating the chat, or pass it via the start method’s specific payload structure if you’re using the newer SDK versions.

Here is the working pattern for the Genesys Cloud Web Messaging SDK (v2+):

// Initialize the widget first
const widget = new GenesysCloudWebMessaging.Widget({
 organizationId: 'YOUR_ORG_ID',
 deploymentId: 'YOUR_DEPLOYMENT_ID',
 // ... other config
});

// Set custom data BEFORE starting the chat
await widget.setCustomData({
 'crm_customer_id': 'CRM-12345'
});

// Now start the chat
await widget.startChat();

If you are using the older genesys-cloud-web-messaging library (v1), the syntax is slightly different. You pass the data in the start call:

widget.start({
 customData: {
 'crm_customer_id': 'CRM-12345'
 }
});

Make sure the attribute key crm_customer_id is defined in your Web Messaging deployment configuration. If it’s not pre-defined there, the SDK will drop it silently. Check your deployment settings in the Genesys Cloud admin portal under Messaging > Deployments. You’ll need to add the custom attribute to the allowed list.

Also, verify the SDK version. The newer @genesys/web-messaging package has a slightly different API surface. If you’re on v2.0+, setCustomData is the standard approach. Don’t mix v1 and v2 syntax.