RocketChat / Apps.Rasa

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

[New Feature] Add Synchronous handover support in the App #3

Closed murtaza98 closed 4 years ago

murtaza98 commented 4 years ago

Sync handover support means - When the bot is not able to answer the user's query N no of times continuously, then the app will automatically transfer control from Bot to an online Livechat Agent.

murtaza98 commented 4 years ago

The implementation for this feature is will be a bit tricky than Dialogflow due to the following reason:-

  1. Unlike Dialogflow, which provides a property isFallback within all its response, Rasa's API response(see references) doesn't have this property.
  2. Unlike Dialogflow which provides the detected-Intent-Name within all its response, Rasa's API response doesn't include this.

My proposed solution to tackle this issue:-

  1. Provide a additional App-Setting with named Fallback Intent Name.
  2. After making HTTP call to get response for query, make another HTTP call to /conversations/{sender-Id}/tracker endpoint. The response from this enpoint will contain last_message.intent property which we can compare with the App-Setting in Step 1.

References

engahmed1190 commented 4 years ago

@murtaza98 it can be sent from RASA Chatbot itself where Fallback Action to be triggered after N times and Flag to be raised

class ActionDefaultFallback(Action): 

def name(self): return "my_fallback_action"

def run(self, dispatcher, tracker, domain):
    i = tracker.get_slot('i')
    dispatcher.utter_message("okay")
    if i == 3:  // N =3 
        dispatcher.utter_message("Handoff ")
        return [ConversationPaused()]

    if i == None:
        i = 0
    i += 1
    return [UserUtteranceReverted(),SlotSet("i", i)]
murtaza98 commented 4 years ago

@engahmed1190 Thanks for sharing this info. This should work :+1: