Webchat Custom Data

Hello everyone, I am new at Rasa. Could someone help me with sending custom data from WebChat to custom actions.py? Let say for example, I want to send bot_id to actions, and depending on bot_id to format the answer from 3rd party API. I appreciate any help.

WebChat.default.init({ selector: “#webchat”, initPayload: “/greet”, interval: 500, socketUrl: “https://domain.com/”, socketPath: “/socket.io”, customData: {“bot_id”: “123456879”}, title: “Sara”, subtitle: “I’m still in development”, profileAvatar: “https://rasa.com/assets/img/demo/sara_avatar.png”, showCloseButton: true, fullScreenMode: false, params: { storage: “local” }})

I too am stuck here. Did you find the solution for passing Custom Data to actions.py . @rappix. I would really appreciate any kind of information.

Hi @suryateja. I found a solution for this case. I am creating sender_id manually, which is in format bot_id+random_string. Then on my backend in actions controller, I get bot_id from sender_id.

Thanks for the reply … :slight_smile: @rappix In my case ,I have generated a unique_ID for each user ,using the chatbot .Do you know, how can I change sender_id dynamically according to the different user talking to out bot. i.e , I need to add unique_ID of user to sender_ID dynamically.

Just use javascript to create sender_id and save it in cookie. That way you can also use RASA built-in API to retrieve conversation history for current user.

please give me the sample code

Hi,

please try this solution will help for custom data using socket