We are implementing a custom authentication flow for the Genesys Cloud Web Messaging widget. The goal is to pass specific user context attributes to the guest profile before the conversation starts. We’ve configured the widget in our React frontend and are trying to intercept the initialization to add custom data.
Here is the relevant configuration snippet we are using:
const widgetConfig = {
deploymentId: 'our-deployment-id',
onBeforeSend: (event) => {
console.log('Intercepting message:', event);
// Attempting to modify the payload or attributes
event.attributes = {
...event.attributes,
customUserId: 'user-12345',
sessionId: 'sess-9876'
};
return event;
},
onReady: () => {
console.log('Widget ready');
}
};
window.genesysCloudWebMessaging = {
...window.genesysCloudWebMessaging,
config: widgetConfig
};
The onBeforeSend hook fires correctly when a message is typed. However, the custom attributes customUserId and sessionId do not appear in the conversation transcript or in the associated user profile in Genesys Cloud. The standard attributes like name and email work fine if set via setGuestInfo.
We’ve tried setting these attributes directly in the setGuestInfo call after the widget is ready, but the timing seems off. The conversation often starts before our async user data is fetched. Is there a way to delay the widget’s auto-send or properly inject these attributes into the initial connection payload? We need these attributes to be present from the very first message for our routing logic to work correctly.