Rasa webchat - get actual url

I am using the Rasa-Webchat widget (GitHub - botfront/rasa-webchat: A feature-rich chat widget for Rasa and Botfront) to deploy a virtual assistant on a website. It is a chatbot designed to buy products. On the website where the chatbot is hung, there is also a virtual store, where the user can browse through each existing product.

Is there any way to get the url of the product that the user is currently viewing at the time of writing in the webchat?

By doing so, I could get more data about the context of the message, knowing which product the user is currently looking at.

Hola @gds,

Note that I’ve never used this widget and I am not very knowledgeable of front-end development. But it seems (from this section) that you can send custom data using the .send() method. Maybe you could define a slot + entity in your domain (say, user_url) and a dummy intent (say, set_url), and then send /set_url{"user_url": <val>} somewhere in your website’s code using the WebChat.send() method I mentioned. <val> would probably take the value of window.location.href.

Hello @fede, thank you very much! I will try it.

does it work?

Hey, did you manage to make it work? I am trying the exact same thing, can you help me

I use the following solution with my webchat instance, that send a initPayload with window.location.href to my bot, that saves it as a slot. The only problem is that when i use action_restart i lose this value, and I don’t know how to fix that

	<script>!(function () {
  let e = document.createElement("script"),
    t = document.head || document.getElementsByTagName("head")[0];
  (e.src =
    (e.async = !0),
    (e.onload = () => {
          initPayload: window.location.href,
          socketUrl: "http://localhost:5006?token=thisismysecret",
          // add other props here
    t.insertBefore(e, t.firstChild);