https://discord.gg/botpress logo
Custom chatbot entry message depending on URL path
# 🤝help
p
Hello Botpress friends, I have a question about customizing the chatbot’s start message. Is there a way to configure the bot to start differently based on the page URL? I’d like the conversation to understand the context of the current page. For example, if the user is on url.com/pokemon, the bot should begin with something like: “Hello, Pokémon fan! How can I help you today?” But if the user is on url.com/minecraft, it should say: “Stacked any blocks today? How can I help?” (The examples are just to illustrate the use case. 😄)
w
use [Send user data](https://botpress.com/docs/webchat/interact/send-user-data#initialize-with-user-data)
Copy code
ts
window.botpress.on('webchat:initialized', () => {
  console.log('Webchat has been initialized. Loading user...');
  window.botpress.updateUser({
    data: {
      pageUrl: window.location.href
    },
  })
});
p
Thank you Zannax, that helped me!
2 Views