samplecode:
>
window.botpress.on('webchat:initialized', () => {
// Here, you would fetch the data for your logged-in user.
// This is just an example with static data.
const returningUserData = {
crmId: 'CRM-12345', // This is your unique userKey
firstName: 'Jane',
lastName: 'Doe',
email: 'jane.doe@example.com',
};
console.log('Webchat is initialized. Sending user data to the bot.');
// This function sends the user's data to Botpress.
window.botpress.updateUser({
data: returningUserData,
});
});