Ras Bot to respond only when asked and human hand off


We have Rasa integrated with Symphony. We can create chatrooms in Symphony. When Rasa BOT is added in the Chat room, we want it to start responding only when its addressed to BOT. Once the conversation with Rasa BOT ends and the user want to handoff to human in the room, the Rasa BOT should be silent in the room unless is again addresses.

eg. abc: Hi @RasaBot

RasaBot : Please enter your id

abc: 11111

RasaBot : Here are your details

abc: Thanks. I want to talk to support team member.

RasaBot : Sure. Let me inform.

RasaBot: Hi ‘SupportPerson’, please check the queries of user abc

SupportPerson : Hi abc

abc: Hi I have a query

(From here Rasa BOT should be silent and should respond back only when user says @RasaBot)

Please help to understand this implementation.

I have implemented it in actions.py with below class. but getting error :slight_smile: Error : Exception occurred while handling uri: ‘http://localhost:5055/webhook’ Traceback (most recent call last): File “c:\users\userid\projects\chatbot\venv\lib\site-packages\urllib3\connection.py”, line 160, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File “c:\users\userid\projects\chatbot\venv\lib\site-packages\urllib3\util\connection.py”, line 84, in create_connection raise err File “c:\users\userid\projects\chatbot\venv\lib\site-packages\urllib3\util\connection.py”, line 74, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred: Traceback (most recent call last): File “c:\users\pg81704\projects\chatbot\venv\lib\site-packages\urllib3\connectionpool.py”, line 677, in urlopen chunked=chunked, File “c:\users\userid\projects\chatbot\venv\lib\site-packages\urllib3\connectionpool.py”, line 392, in _make_request conn.request(method, url, **httplib_request_kw) File “C:\Users\userid\AppData\Local\Continuum\anaconda3\lib\http\client.py”, line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File “C:\Users\userid\AppData\Local\Continuum\anaconda3\lib\http\client.py”, line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File “C:\Users\userid\AppData\Local\Continuum\anaconda3\lib\http\client.py”, line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File “C:\Users\userid\AppData\Local\Continuum\anaconda3\lib\http\client.py”, line 1016, in _send_output self.send(msg) File “C:\Users\userid\AppData\Local\Continuum\anaconda3\lib\http\client.py”, line 956, in send self.connect() File “c:\users\pg81704\projects\chatbot\venv\lib\site-packages\urllib3\connection.py”, line 187, in connect conn = self._new_conn() File “c:\users\userid\projects\chatbot\venv\lib\site-packages\urllib3\connection.py”, line 172, in _new_conn self, “Failed to establish a new connection: %s” % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002228A4D5B00>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

actions.py: class Action_Humanagent(Action):

def name(self):

        return "action_talk_to_human"

def run(self, dispatcher, tracker, domain):

    response = ("Reaching out to a human agent")



    message = ""

    while message != "/unpause":

        #url = "{}".format(tracker.sender_id) 

        url = "{}".format(tracker.sender_id) 

        req = requests.get(url)

        resp = json.loads(req.text)

        if "error" in resp:

            raise Exception("Error fetching message: " + repr(resp["error"]))

        message = resp["message"]


        if message != "/unpause":

            dispatcher.utter_message("Human agent: {}".format(message))

    return [ConversationPaused()]

The error you’re getting looks like it might be due to a firewall blocking access. Have you tried disabling your fire temporarily?

@rctatman Thanks for your response. This has been resolved. The way I am handling it it

  1. Use “ConversationPaused()” to pause the conversation
  2. /restart to resume it.

It works. Thanks

1 Like