Is possible to pass the value of slots in rasa official script in the html page?

I’m trying to use rasa in my html page and a need to pass in the script the value of username for example, is there any way to do this?

1 Like

div id=rasa-chat-widget data-websocket-url=http://xxxx:5005 /div |—|—| script src= type=application/javascript /script

Hello @ayoubelma welcome to the forum.

Can I ask why you want this approach? You can simply use the third party widget and render it on your website or index.html (which you have created) or if there is any other approach please let us know.

Yes, I assume you are using the REST channel, in which case you can add metadata in the payload like this:

  "sender": "111111",
  "message": "hi",
    "username": "ayoubelma",
    "membership_status": "premium"

You can then read the metadata in a custom action by overriding action_session_start and then getting session_started_metadata. You can read more about that here.

1 Like

I need to recognize the user without ask again a login, the chatbot will be in a closed section and in there the user has to bee logged

you mean that i have to add this in the html script of my page?

let me try to explain a little bit more. in the script to add rasa to a website, like the example in this Your Own Website , I need to pass an extra attribute that i should catch in the chatbot for some operations. I can’t ask it again to the user, so I need to add it in some way in the html script

If the website already knows the name of the user, you don’t need to ask them.

Are you using an existing chat widget or did you write your own?

I’m using the widget shown in rasa official website, simply adding the script in this section “chat widget” Your Own Website .My problem is that I have the data in my own website but I don’t know how to pass them to rasa chatbot

can you elaborate more?

a little update, I’m trying to do that using the jwt token with socket io, and setting the data that I need in it. But, is it possible from rasa to get the payload information? how can I get them?

This is a great sol for rest channel, but I’m using socket io. I didn’t realized your response before

action_session_start and session_started_metadata will work with the socket channel.

so, if I have a jwt token used for socket io connection I can read it seraching for session_started_metadata? for example I have an attr “name”, I don’t have node “metadata” in my jwt

I’m trying to understand who call methods in classes like /rasa/core/actions/". I can see for example that in those classes there are some method that decode the jwt ecc, but who call them? who catch the jwt?

A little update.I modified the setting before a prop in self obj where token is setted to saving the info, and modified the line message = UserMessage( data[“message”], output_channel, sender_id,, metadata = self.token) await on_new_message(message) ;then using tracker.latest_message I can get the info in metadata tag

Thank you all for replies

Hi @nik202 as per the solution of this thread, the person modified the file. Could you please tell me where exactly can I find this file in my rasa project? Or do I need to create a custom channel altogether just to pass some metadata?