Hi all, I installed Rasa X using the docker compose installation. I’m trying to issue an external event from my actions.py file. This works when I run everything manually, but when I try to run it through Rasa x it error. I would appreciate any suggestions:
My code in actions.py looks like this:
async def run(self, dispatcher, tracker: Tracker, domain: Dict[Text,Any],)->List[Dict]:
import requests
slot_value=tracker.get_slot('lookup_email')
slots=self.find_user(slot_value.lower())
conversation_id=tracker.sender_id
if len(slots)>0:
print('setting slots- id:{} group:{} email"{}'.format(slots[0],slots[1],slot_value.lower()))
#return{'id':slots[0],'group':slots[1],'email':slot_value.lower()}
#will want expand this for more slots to include other slots
d='{"name":"EXTERNAL_group","entities":{"group":"'+slots[1]+'"}}'
url=f'http://localhost:5005/conversations/{conversation_id}/trigger_intent?output_channel=latest'
x=requests.post(url, data=d)
#x=requests.post(f'http://localhost:5005/conversations/{conversation_id}/trigger_intent?output_channel=latest', data={"name":"EXTERNAL_group","entities":{"group":slots[1]}})
return []
I get the following error in my log:
Exception occurred while handling uri: 'http://app:5055/webhook'
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/urllib3/connection.py", line 170, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/opt/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/opt/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 706, in urlopen
chunked=chunked,
File "/opt/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/opt/venv/lib/python3.7/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.7/http/client.py", line 1277, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1323, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1272, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.7/http/client.py", line 1032, in _send_output
self.send(msg)
File "/usr/local/lib/python3.7/http/client.py", line 972, in send
self.connect()
File "/opt/venv/lib/python3.7/site-packages/urllib3/connection.py", line 200, in connect
conn = self._new_conn()
File "/opt/venv/lib/python3.7/site-packages/urllib3/connection.py", line 182, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f39226bfe50>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/opt/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 756, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/opt/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=5005): Max retries exceeded with url: /conversations/7c7ee9e1031d4a1b8d29269bf92c0b28/trigger_intent?output_channel=latest (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f39226bfe50>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.7/site-packages/sanic/app.py", line 973, in handle_request
response = await response
File "/app/rasa_sdk/endpoint.py", line 103, in webhook
result = await executor.run(action_call)
File "/app/rasa_sdk/executor.py", line 398, in run
action(dispatcher, tracker, domain)
File "/app/rasa_sdk/utils.py", line 230, in call_potential_coroutine
return await coroutine_or_return_value
File "/app/actions/actions.py", line 178, in run
x=requests.post(url, data=d)
File "/opt/venv/lib/python3.7/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/opt/venv/lib/python3.7/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/opt/venv/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/opt/venv/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/opt/venv/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5005): Max retries exceeded with url: /conversations/7c7ee9e1031d4a1b8d29269bf92c0b28/trigger_intent?output_channel=latest (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f39226bfe50>: Failed to establish a new connection: [Errno 111] Connection refused'))
My credentials.yml file looks like this:
rasa:
url: http://localhost:5002/api
I should note that I have tried setting that to 5005, no port and the below with no difference:
rasa:
url: ${RASA_X_HOST}/api
In case it’s important the endpoints.yml file looks like this:
models:
url: ${RASA_MODEL_SERVER}
token: ${RASA_X_TOKEN}
wait_time_between_pulls: ${RASA_MODEL_PULL_INTERVAL}
tracker_store:
type: sql
dialect: "postgresql"
url: ${DB_HOST}
port: ${DB_PORT}
username: ${DB_USER}
password: ${DB_PASSWORD}
db: ${DB_DATABASE}
login_db: ${DB_LOGIN_DB}
lock_store:
type: "redis"
url: ${REDIS_HOST}
port: ${REDIS_PORT}
password: ${REDIS_PASSWORD}
db: ${REDIS_DB}
cache:
type: "redis"
url: ${REDIS_HOST}
port: ${REDIS_PORT}
password: ${REDIS_PASSWORD}
db: ${REDIS_CACHE_DB}
key_prefix: "rasax_cache"
event_broker:
type: "pika"
url: ${RABBITMQ_HOST}
username: ${RABBITMQ_USERNAME}
password: ${RABBITMQ_PASSWORD}
queues:
- ${RABBITMQ_QUEUE}
action_endpoint:
url: ${RASA_USER_APP}/webhook
token: ""