How to send live agent's message to rasa bot from rocket chat during handover?

Hello Everyone, I want to add a live chat feature in my rasa bot and for that, I am using rocket chat I have registered the visitor and created a room in rocket chat by adding custom actions in the actions.py file, and I am able to send visitor messages in rocket chat by using custom component approach but how do send back the live agent’s response or reply back to rasa, I am not able to understand what should be the approach for it. If anyone has any solution so please let me know I have been stuck on it for the last 2 weeks.

Here is my actions.py file for the handover process:

class RegisterVisitor(Action):
    def name(self) -> Text:
        return "action_register_visitor"

    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        # Your code goes here
        
        url = "http://localhost:3000/api/v1/livechat/visitor"

        payload = json.dumps({
        "visitor": {
            "name": "Livechat Visitor",
            "email": "visitor@rocket.chat",
            "department": "OPB",
            "token": "iNKE8a6k6cjbqWhWd",
            "phone": "55 51 5555-5555",
            "customFields": [
            {
                "key": "address",
                "value": "Rocket.Chat street",
                "overwrite": True
            }
            ]
        }
        })
        headers = {
        'Content-Type': 'application/json'
        }
        response = requests.request("POST", url, headers=headers, data=payload)
        dispatcher.utter_message(text="Visitor is registered")
        print(response.text)
        return []

class CreateRoom(Action):
    
    def name(self) -> Text:
        return "action_create_room"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
            
            url = "http://localhost:3000/api/v1/livechat/room?token=iNKE8a6k6cjbqWhWd"

            payload={}
            headers = {}

            response = requests.request("GET", url, headers=headers, data=payload)
            print(response.text)
            return []

class ActionSendMessageToRocketChat(Action):
    def name(self) -> Text:
        return "action_send_msg"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
           
            url = "http://localhost:3000/api/v1/livechat/message "
            usr_msg=open('rocketchat_msg.txt',"r+")
            live_msg = usr_msg.read()
            payload = json.dumps({
            "token": "iNKE8a6k6cjbqWhWd",
            "rid": "SpN4mPdL4ehRdzawd",
            "msg": live_msg
            })
            headers = {
            'Content-Type': 'application/json'
            }

            response = requests.request("POST", url, headers=headers, data=payload)

            print(response.text)

Thank you

Hi @shruti_v, take a look at this blogpost How to Build a “Human” Handoff Feature with Rasa

Hey, @rasa_learner thank you I will look into it.

Hey, @rasa_learner as per the guidance you shared I don’t understand how to set up the chatroom which will connect with the rasa and rocket chat server can you please share some steps which I can follow to set up the chatroom for it I followed this https://github.com/RasaHQ/chatroom but not able to understand it. Thank you!

Hello everyone, I am not able to understand to connect to the chatroom to switch the rasa server to rocket chat please if someone has any solution for it let me know I have been stuck on it for 2 weeks.

Hey Hi Sruti, Have you done This process “Human Handoff”. If you have completed please give me a reference.

@shruti_v any progress!