How to Access and Utilize userData in Botpress Web...
# 📖tutorials
f
[YouTube Video](

https://youtu.be/KInxF67proo

) In this tutorial, I'll show you how to access and utilize userData in the Botpress web chat. We'll create a new bot and learn how to retrieve the user's data, such as language preference, using the Get User Data card in Botpress. I'll demonstrate how to display this data in the chat window and how to use it in an execute code card to set the translator agent's language based on the user's preference. By the end of this video, you'll understand how to leverage the userData to personalize the user experience in your Botpress web chat. [YouTube Video](

https://youtu.be/KInxF67proo

) https://cdn.discordapp.com/attachments/1226976192805077082/1226976192943624215/userData_-_2024_Apr_08.bpz?ex=6626b9a0&is=661444a0&hm=9209c93369c12f7744e68fed73ca061e9b71aa58fac6acb208b420500361337d&
HTML used:
Copy code
html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="https://cdn.botpress.cloud/webchat/v1/inject.js"></script>
    <script>
    window.botpressWebChat.init({
        "composerPlaceholder": "Chat with bot",
        "botConversationDescription": "This chatbot was built surprisingly fast with Botpress",
        "botId": "BOT ID",
        "hostUrl": "https://cdn.botpress.cloud/webchat/v1",
        "messagingUrl": "https://messaging.botpress.cloud",
        "clientId": "CLIENT ID",
        "webhookId": "WEBHOOK ID",
        "lazySocket": true,
        "themeName": "prism",
        "frontendVersion": "v1",
        "showPoweredBy": true,
        "theme": "prism",
        "themeColor": "#2563eb",
        "enableConversationDeletion": true,
        "userData": {
            "language": "da"
        }
    });
    </script>
</body>
</html>
121 Views