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

@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