I have implemented it in actions.py with below class. but getting error
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")
dispatcher.utter_message(response)
message = ""
while message != "/unpause":
#url = "http://127.0.0.1:5000/handoff/{}".format(tracker.sender_id)
url = "http://127.0.0.1:5002/handoff/{}".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"]
print("message",message)
if message != "/unpause":
dispatcher.utter_message("Human agent: {}".format(message))
return [ConversationPaused()]