Rasa can support Handover Protocol? How Hand over bot to human chat?

Can you please tell me rasa can support Hand over option?. If rasa support handover protocol means how will use this option( chat bot to human chat). Please advice?

team wait for your valuable reply

Rasa support handover option? it’s support hand over option means how will enable this option?

Hi @Selvaganapathi06!

IF you mean facebook messenger handover protocol, for what i saw some weeks ago, it doesnt support it.

But the good news is: basic supporits no hard to implement on your own:

class ActionHandOverToInbox(Action):
def name(self):
    return 'action_handover_to_inbox'

def run(self, dispatcher, tracker, domain):
    recipient_id = dispatcher.sender_id
    response = self.pass_thread_control(app_id=app_settings.FACEBOOK_INBOX_APP_ID, recipient_id=recipient_id)

    if response.get("success"):
        dispatcher.utter_template(template="utter_handover_done", tracker=tracker)

    return []


def pass_thread_control(self, app_id, recipient_id):
    url = app_settings.FACEBOOK_PASS_THREAD_CONTROL_ENDPOINT

    data = {"recipient": {"id": recipient_id}, "target_app_id": app_id}
    params = {"access_token": app_settings.FACEBOOK_PAGE_ACCESS_TOKEN}

    r = requests.post(url, json=data, params=params)

    return r.json()
1 Like

Hi

Has anyone implemented something like this for Skype for Business or for the WebChat? I suppose this would be very crucial for many RASA users, since a handover to humans is recommended by most scientific papers.

Best regards, Dario

can you share your file.From where i ll get app_settings.FACEBOOK_PASS_THREAD_CONTROL_ENDPOINT it is showing me error

@Umesh, first of all, you need to make sure your facebook page as already defined its primary and secondary receiver, basically you just put your bot as the primary (bot will handle all the incoming messages), and the secondary one is a human agent who will chat when the bot fails, in this link you can see how to do it.

after you have it alls set up, you can do something like this

class FacebookConversation:
    ''' All information related to facebook conversations '''
    def move_to_inbox(self, sender_id):

        url = 'https://graph.facebook.com/v6.0/me/pass_thread_control?access_token={}'.format(<<YOUR TOKEN HERE>>)
        headers ={
            "Content-Type": "application/json"
        }
        data = {
            "recipient":{"id":sender_id},
            "target_app_id":263902037430900,
            "metadata":"String to pass to secondary receiver app"
        }

        r = requests.post(url, headers=headers, data =json.dumps(data))

        return (r.status_code)

This will move the conversation to inbox and return the status

2 Likes