Web Messaging SDK custom guest attributes not persisting for authenticated users

We’re deploying the Genesys Cloud Web Messaging widget and trying to pass custom guest attributes for authenticated users. The widget loads fine, but the attributes don’t show up in the conversation metadata.

const widget = window.$engage.widget;
widget.setGuestAttributes({ userId: '123', role: 'admin' });

The API call succeeds, but the data isn’t there. Is there a specific sequence or timing issue I’m missing?

Timing is likely the issue. The widget initializes before your script runs. Wait for the ready event.

window.$engage.ready(() => {
 window.$engage.widget.setGuestAttributes({ userId: '123', role: 'admin' });
});

Check browser console for errors.