Trying to shove the CRM customer ID into the Genesys Web Messaging SDK, but it’s not sticking. I’m calling startChat with customAttributes set, yet the conversation data coming into Architect is blank. Here’s the call:
The startChat method in the Web Messaging SDK doesn’t actually persist customAttributes to the conversation object directly like that. It sets them on the session, but they often get stripped or ignored if the underlying contact isn’t fully initialized yet. You’re fighting the SDK’s internal state machine.
If you’re building a custom integration, skip startChat for this specific data injection. Use the REST API to update the contact immediately after the chat starts, or better yet, use the setCustomAttributes method on the ChatChannel instance after the connection is established.
Here’s the pattern that actually works in Studio and Architect:
// 1. Start the chat normally
const chat = await genesys.cloud.web.messaging.startChat();
// 2. Wait for the channel to be ready
chat.on('connected', () => {
// 3. Inject the attributes explicitly
chat.setCustomAttributes({
crmCustomerId: "12345"
});
// 4. Send a dummy message to trigger the flow if needed
chat.sendMessage("Initiating CRM lookup");
});
In Architect, make sure you’re reading from the Contact Attributes data block, not the Interaction Attributes. There’s a subtle difference. The SDK pushes to Contact Attributes. If your flow is looking at Interaction Attributes, you’ll see nothing.
Also, check your OAuth scopes. If you’re using a server-side xy to verify this, ensure you have conversation:write and contact:write. Without those, the attributes might be sent but silently dropped by the platform.
I’ve seen this trip up a lot of devs. The documentation implies startChat handles it, but the reality is the timing is off. The contact ID isn’t assigned until the channel is open. So you have to wait for the connected event.
If you’re still stuck, try logging the raw payload being sent to the /api/v2/conversations/webchat endpoint. You’ll likely see the customAttributes field is empty or malformed. Fix the timing, and the data will flow through.