The Embedded Webchat allows you to add custom data to the user. With this user data feature, you can include information like email or browser details, or any other useful data for your bot.

Update the User Data

First, use the Embedded Webchat on your site. This will give you access to the window.botpress object. You can use the window.botpress.updateUser function to send any data back to Botpress.

Here's an example of the updateUser function:

window.botpress.updateUser({
  "data": {
    "firstName": firstname,
    "lastName": lastname,
    "email": email,
  }
})

Important note, the user can't be updated until the webchat is opened. Use the window.botpress.on('webchat:opened', () => {}) event to confirm the user exists and can be updated.

Retreive the User Data in your Studio

Once you have sent the data to Botpress, you can use the Get User Data card in the studio to retrieve the user data sent from your website.

User Data Studio

User Data Demo