Deploying Rasa Bot with Twilio on Gcloud App Engine

Hi, I’ve been trying to deploy my Rasa Bot in Gcloud App Engine. So far it works well on the rasa server side, as it correctly predicts which kind of intent the incoming message from Twilio is.

However, on the actions side, it’s unable to say which action to take as it logs in the console that no domain file was found. To double check on that, I called the GET /domain endpoint and find out that it is empty, so I don’t know what to do.

I’m thinking that this might be related to me using the rasa/rasa docker image, instead of my own (which I’m working on creating but I have issues there too), but if that’s the case why is it predicting correctly which intent to assign? Is it because of the models that are loaded up with that image?

If anyone can give some hint on what I could do I would appreciate it.

hi, can you help me step by step to deploy rasa to Google cloud.

Hi! I did it mostly by following this post.

I solved my domain issue by setting all the responses’ text between quotes, as sometimes rasa x will unquote them, maybe because I don’t have rasa x updated.

If you follow that post, you will need your channel credentials and to comment out the rasa url in credentials.yml, as the post explains.

My dockerfile looks like this: FROM rasa/rasa USER root ENV BOT_ENV=development COPY . /var/www WORKDIR /var/www RUN pip install --no-cache-dir phonenumbers pgeocode RUN rasa train nlu RUN rasa train # Use this for action_server.yaml deploy # Use this for bot deployment using app.yaml ENTRYPOINT [“rasa”, “run”, “-p”, “8080”, “–debug”, “-vv”, “–enable-api”, “-m”, “models”, “–cors”, “*”, “actions”]

After that you need just to run gcloud app deploy and wait for the service to run

Hi juansolana. I followed that post but when I ran the container docker run -d -p 8080:8080 hassaanseeker/chatbot . then checked 192.168.99.100. I got nothing :frowning:

I never ran the docker commands on that post as I knew my bot was running locally already. I went straight for the gcoud App Engine part. Also, the post suggests that ip, but I think it doesn’t necessarily mean that’s the one you will get, not sure how to check which one got assigned though.

If your bots run locally already, it’s just a matter of commenting out the rasa endpoint as the post suggests, follow the steps on how to set up an App Engine project, and then deploy it. I normally deploy it as gcloud beta app deploy -v botgister-0 because I wanted to be sure my code files where going to be used, maybe it’s unnecesary though, it also allows for debugging in the gcloud suite but haven’t done it yet.

Make sure your files don’t have any error, to do that have the latest rasa version, because the dockerfile installs the latest version of rasa, which make my domain file to fail without me realizing.

If you figure out how to expose the action server endpoint from gcloud, please share, that’s where I’m struggling.

I’m trying but google didn’t accept my prepaid mastercard to registry gcp :frowning: Does your bot run normally without actions server?

have you ever tried to deploy actions server separately to another cloud such as heroku or aws? and then invoke it in your endpoint.yml from google cloud platform

It does run without the action server, but just some basic replies that sends according to the stories, these are useless without the action server.

Hi, Can you help me to show all of your dockerfile and root folder in github? I think you can deploy rasa actions server to heroku. and then invoke it from google cloud. you can follow "building chat bots with python " book of Sumit Raj to deploy actions server

how would this differ from running the action server on App Engine, from the logger I can see that it’s running successfully, however I can’t reach the host url from my rasa server; I get this error:

Traceback (most recent call last): File "/opt/venv/lib/python3.6/site-packages/rasa/core/actions/action.py", line 549, in run json=json_body, method="post", timeout=DEFAULT_REQUEST_TIMEOUT File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw return self.gen.throw(type, value, traceback) File "/opt/venv/lib/python3.6/site-packages/rasa/utils/endpoints.py", line 146, in request **kwargs, File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw return self.gen.throw(type, value, traceback) File "/opt/venv/lib/python3.6/site-packages/aiohttp/client.py", line 1012, in __aenter__ self._resp = await self._coro File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw return self.gen.throw(type, value, traceback) File "/opt/venv/lib/python3.6/site-packages/aiohttp/client.py", line 483, in _request timeout=real_timeout File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw return self.gen.throw(type, value, traceback) File "/opt/venv/lib/python3.6/site-packages/aiohttp/connector.py", line 523, in connect proto = await self._create_connection(req, traces, timeout) File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw return self.gen.throw(type, value, traceback) File "/opt/venv/lib/python3.6/site-packages/aiohttp/connector.py", line 859, in _create_connection req, traces, timeout) File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 129, in throw return self.gen.throw(type, value, traceback) File "/opt/venv/lib/python3.6/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection raise last_exc File "/opt/venv/lib/python3.6/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection req=req, client_error=client_error) File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 110, in __next__ return self.gen.send(None) File "/opt/venv/lib/python3.6/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host action-server-dot-weebots.appspot.com:8088 ssl:default [Cannot assign requested address]

Where the port 8088 I’ve been playing with different values, default is 8080 but same error, or setting the action_endpoint without the port gets me the same

This is my entire dockerfile:

FROM rasa/rasa
USER root
ENV BOT_ENV=development
COPY . /var/www
WORKDIR /var/www
RUN pip install --no-cache-dir phonenumbers pgeocode
RUN rasa train nlu
RUN rasa train
# Use this for action_server.yaml deploy
ENTRYPOINT ["rasa", "run", "-vv", "--enable-api", "--debug", "-p", "8088", "actions"]

# Use this for bot deployment using app.yaml
#ENTRYPOINT ["rasa", "run", "-p", "8080", "--debug", "-vv", "--enable-api", "-m", "models", "--cors", "*", "actions"]

I use it for the action server service and the rasa server service, I just comment out and uncomment accordingly.

This is my app.yaml file, for the rasa server service:

runtime: custom
env: flex
#entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  python_version: 3

# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
manual_scaling:
  instances: 1
resources:
  cpu: 2
  memory_gb: 4
  disk_size_gb: 10

This is my action_server.yam file for the action server service, pretty much the same: service: action-server runtime: custom env: flex entrypoint: gunicorn -b :8088 main:app

runtime_config:
  python_version: 3

# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
manual_scaling:
  instances: 1
resources:
  cpu: 2
  memory_gb: 4
  disk_size_gb: 10

The rest of my directory structure is pretty much the same as in the link I shared, I can share it tomorrow.

I will check on the link you shared, thanks :ok_hand:

Oh, and did you check if you can get $300 from Gcloud? I think they give that for the first year on first time accounts.

Thank you. I think you should read that book. I did try to register an gcp but my prepaid mastercard isn’t accepted. Can you give me your email? we can contact by email. If you don’t mind, could you modify your file in cloud and use my data to test it?

okay. I will send you an email

@juansolana May I know is your App Engine deployment running successfully? The dockerfile above with 2 ENTRYPOINT, is it 2 dockerfile needed, one for the main rasa, one for actions server? I had successful deploy rasa server. Error deploy actions server. Please help.

@juansolana I get it works! I use CMD instead of ENTRYPOINT in actions_server’s dockerfile. Below is my Dockerfile:

FROM rasa/rasa-sdk:2.8.2

COPY actions.py /app/actions.py
COPY requirements.txt /app

USER root

RUN pip install --no-cache-dir -r requirements.txt

USER 1001
CMD ["start", "--actions", "actions", "-p", "8080"]