RocketChat / Apps.Rasa

Integration between Rocket.Chat and the RASA Chatbot platform
17 stars 12 forks source link

[New Feature] Enable communication between Rasa Rest API and this App #1

Closed murtaza98 closed 4 years ago

murtaza98 commented 4 years ago

Main Tasks include

murtaza98 commented 4 years ago

I'd like to propose a new communication model for this App to interact with Rasa.

Existing approach:

Currently, in #6, I've implemented a request-response model i.e the App will send a request to Rasa server with the user's question, and the RASA server will reply back with the appropriate response for the user's query.

Problem with this approach

This approach work's perfectly for synchronous messages, however, for asynchronous messages, this approach won't work. To handle asynchronous messages we will need a new endpoint as we did in Dialogflow's App. So in short, with this approach, we handle synchronous and asynchronous messages separately. This is what I'd like to improve with my proposed approach

Proposed approach

I'd like to propose a generic approach to handle both synchronous and asynchronous messages. This is possible only with RASA using CallbackInput. As described there

The callback channel behaves very much like the rest input, but instead of directly returning the bot messages to the HTTP request that sends the message, it will call a URL you can specify to send bot messages.

So my plan is to expose a generic endpoint CallbackInput in our app and supply its URL to RASA. Rasa will then send synchronous and asynchronous messages to this endpoint.

So this is my plan. Please let me know ur thoughts on it. Thanks :smile:

renatobecker commented 4 years ago

I didn't get why having just the approach based on the REST API endpoint will be beneficial if we can have both approaches just like we did for the Dialogflow App. Do you think that instead of returning the response you get synchronous, we should await another REST API request to return a message to the end-user? The REST API calls work through the network, so the server may face some problems such as latency, etc.. Do you really think that let the end-user awaiting a response will provide a better UX?

I'll be waiting for your feedback.

murtaza98 commented 4 years ago

Hello @renatobecker Thanks for ur feedback on this matter. Ur points are completely valid. Using callbacks would certainly add a slight delay. However, there is a feature in Rasa called Reminders. The way it works is if an intent gets triggered, then for this intent, the chatbot-developer can schedule a reminder which will be triggered after N seconds.

Using reminders with rest endpoint

If we use the rest endpoint, it will work properly with synchronous responses, however, if asynchronous messages like reminders are present, then it won't display those messages. Ideally, we would expect that rasa uses callback to send this reminder messages, but it doesn't trigger the callback if we use rest API. Please note that in rasa u cannot use rest and callback together. I tried using it but it didn't work.

Using reminders with callback endpoint

If we use the callback endpoint, both simple responses and reminders will be sent these callback endpoint. I agree with your point, that this might add a delay, however, if we follow this approach then our app can support reminder messages from rasa

Some References which helped me:

https://forum.rasa.com/t/rasa-reminders/2417