botfront / rasa-webchat

A feature-rich chat widget for Rasa and Botfront
https://botfront.io/rasa
Apache License 2.0
954 stars 497 forks source link

Access the webchat state outside of the component #252

Open khalo-sa opened 4 years ago

khalo-sa commented 4 years ago

Hey, first of all let me thank you for open sourcing this great component, much appreciated!

I have kind of unusual use case for the webchat, and wasn't able to solve a problem related to the nature of this use case: I am trying to put a self developed "dashboard" component next to the webchat component. This dashboard is used to give the user of the webchat additional information beyond what is already replied by the bot and displayed in the webchat. To make this work, I need to make an additional api call to my own backend server whenever the user sends a message via webchat. Therefore, I think that somehow I need to register from outside of the webchat component that this event took place so that I can trigger that respective api call. From what I read, React refs could be part of the solution, but besides that I am pretty clueless what to do... Do you guys have an idea what is needed to make it work? Thank you!

MatthieuJnon commented 4 years ago

Hi, unfortunately, we don't currently have a way to listen to messages sent from the user outside of the webchat. I'm going to add one to the prop onWidgetEvent though, I'll let you know here once it's done.

khalo-sa commented 4 years ago

@MatthieuJnon Amazing, thank you!

khalo-sa commented 4 years ago

@MatthieuJnon Could you point me at the code changes necessary to implement that feature myself? I could create a PR in case I am successful.

rajalala commented 3 years ago

Hey any updates on this? ☺️ I have a use case where I'd love to be able to access user messages so either widget event or access to user_uttered socket event would be great! (As far as I understood, user_uttered socket event is not available on the React version?)