Reminder bot doesn't work when deployed in docker compose

Hello everyone,

I have tested the reminder bot example and it works perfectly when I deploy it locally using the following commands:

rasa train ### To train the model
rasa run actions ### To run the action server
rasa run --enable-api --endpoints endpoints.yml -m models -vv --cors '*' --debug ### To run Rasa OSS
python callback_server.py ### To run the CallbackInput

Nevertheless, when I want to deploy it in docker compose I get problems with the callback server and I don’t get the reminder messages (should get: Remind me to call John!) to the callback channel nor to the telegram channel integration. The other actions that I execute, do work for me ( e.g. executing an external event or asking for the channel ID).

When I type “Remember to call John!”, then the bot answer to me “I will remind you in 5 seconds.”, but nothing happens after five seconds :frowning:

I attach my configuration files and the error and debug traces at the end of the post in case someone can help me or if they are useful to someone in case the where they don’t need the reminders.

I have been several days with this problem and I have tried everything. At first I thought it was a communication problem, so I checked the connection between the three containers (rasa, action server and callback).

I have been several days with this problem and I have tried everything. At first I thought it was a communication problem, so I checked the connection between the three containers (rasa, action server and callback). Then I thought it was because of the environment variables, so I also tested it by typing the urls without the environment variables. Without any success, I thought about deploying the callback server without docker (locally) and connecting it to the other containers through the docker IP on the host (172.17.0.1) but that didn’t work either. So I’m a bit desperate and looking for someone to guide me with the problem. Thanks in advance :slight_smile:

  • credentials.yml
telegram:
  access_token: ${TELEGRAM_API_TOKEN}
  verify: ${TELEGRAM_BOT_ID}
  # Rasa Bot url
  webhook_url: ${RASA_URL}/webhooks/telegram/webhook

callback:
  # URL to which Core will send the bot responses
  # url: "http://localhost:5034/bot"
  url: "http://sanic:8888/bot"
  • endpoints.yml
action_endpoint:
   url: ${RASA_ACTION_SERVER_URL}/webhook
  • Environment variables(without showing the real ones):
RASA_URL=
RASA_ACTION_SERVER_URL=http://action-server:5055

TELEGRAM_API_TOKEN=
TELEGRAM_BOT_ID=

REDIS_PASSWD=
  • Docker-compose:
version: '3.0'
services:
  rasa:
    image: rasa/rasa:main-full
    ports:
      - 5005:5005
    user: root
    volumes:
      - ./:/app
    command: ["run", "-m", "models", "-vv", "--enable-api", "--cors", "'*'", "--debug"]
    networks:
      - group-assistant-network
    env_file:
      - .env
    environment:
      - TZ=Europe/London
      - RASA_URL=${RASA_URL}
      - REDIS_PASSWD=${REDIS_PASSWD}
      - TELEGRAM_API_TOKEN=${TELEGRAM_API_TOKEN}
      - TELEGRAM_BOT_ID=${TELEGRAM_BOT_ID}

  action-server:
    build: ./actions
    # image: rasa/rasa-sdk:latest
    ports:
      - 5055:5055
    expose: 
      - 5055
    user: root
    depends_on:
      - rasa
    volumes:
      - ${PWD}/actions:/app/actions
    networks:
      - group-assistant-network
    environment:
      - TZ=Europe/London

  redis:
    image: redis:latest
    # command: >
    #   --requirepass ${REDIS_PASSWD}
    expose:
      - 6379
    # healthcheck:
    #   test: ["CMD", "redis-cli", "ping"]
    #   interval: 5s
    #   timeout: 30s
    #   retries: 50
    restart: always
    networks:
      - group-assistant-network
    env_file:
      - .env
    environment:
      - REDIS_PASSWORD=${REDIS_PASSWD}

  sanic:
    build: 
      context: .
      dockerfile: Dockerfile.callback_server
    ports:
      - "8888:8888"
    restart: always
    networks:
      - group-assistant-network

  # nginx-sanic:
  #   image: nginx:1.13.6-alpine
  #   ports:
  #     - "80:80"
  #   depends_on:
  #     - sanic
  #   volumes:
  #     - ./ngnix-sanic.conf:/etc/nginx/conf.d/ngnix-sanic.conf
  #   restart: always
  #   networks:
  #     - group-assistant-network

volumes:
  actions:

networks:
  group-assistant-network:
    driver: bridge
  • Dockerfile.callback_server:
FROM python:3.10

WORKDIR /code

ADD callback_server.py /code/callback_server.py
RUN pip3 install git+https://github.com/sanic-org/sanic

EXPOSE 8888

CMD ["python", "/code/callback_server.py"]
  • callback_server.py:
from sanic import Sanic, response
from sanic.request import Request
from sanic.response import HTTPResponse


def create_app() -> Sanic:

    bot_app = Sanic("callback_server", configure_logging=False)

    @bot_app.post("/bot")
    def print_response(request: Request) -> HTTPResponse:
        """Print bot response to the console."""
        bot_response = request.json.get("text")
        print(f"\n{bot_response}")

        body = {"status": "message sent"}
        return response.json(body, status=200)

    return bot_app


if __name__ == "__main__":
    app = create_app()
    port = 8888

    print(f"Starting callback server on port {port}.")
    app.run("0.0.0.0", port)
  • Trace of docker container when I type “Remember to call John!”, then the bot answer to me “I will remind you in 5 seconds.”, but nothing happens after five seconds.
group-assistant-bot-rasa-1           | [state 3] user intent: ask_remind_call | previous action name: action_listen
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.policies.rule_policy  - There is a rule for the next action 'action_set_reminder'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.engine.graph  - Node 'select_prediction' running 'DefaultPolicyPredictionEnsemble.combine_predictions_from_kwargs'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.policies.ensemble  - Made prediction using user intent.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.policies.ensemble  - Added `DefinePrevUserUtteredFeaturization(False)` event.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.policies.ensemble  - Predicted next action using RulePolicy.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.processor  - Predicted next action 'action_set_reminder' with confidence 1.00.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'action_set_reminder'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.processor  - Policy prediction ended with events '[<rasa.shared.core.events.DefinePrevUserUtteredFeaturization object at 0x7f56fdb345e0>]'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.processor  - Action 'action_set_reminder' ended with events '[BotUttered('I will remind you in 5 seconds.', {"elements": null, "quick_replies": null, "buttons": null, "attachment": null, "image": null, "custom": null}, {}, 1663794154.7684476), <rasa.shared.core.events.ReminderScheduled object at 0x7f56fdb75580>]'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.processor  - Current slot values: 
group-assistant-bot-rasa-1           | 	PERSON: None
group-assistant-bot-rasa-1           | 	session_started_metadata: None
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    urllib3.connectionpool  - https://api.telegram.org:443 "POST /bot123:ABC/sendMessage?chat_id=1&text=I+will+remind+you+in+5+seconds. HTTP/1.1" 200 285
group-assistant-bot-rasa-1           | /opt/venv/lib/python3.8/site-packages/apscheduler/util.py:436: PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
group-assistant-bot-rasa-1           |   return tzinfo.localize(dt)
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.engine.runner.dask  - Running graph with inputs: {'__tracker__': <rasa.shared.core.trackers.DialogueStateTracker object at 0x7f56fdbb69a0>}, targets: ['select_prediction'] and ExecutionContext(model_id='71dad8046d7b436f8d6cf4f1f3e9cbca', should_add_diagnostic_data=False, is_finetuning=False, node_name=None).
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.engine.graph  - Node 'rule_only_data_provider' running 'RuleOnlyDataProvider.provide'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.engine.graph  - Node 'domain_provider' running 'DomainProvider.provide_inference'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.engine.graph  - Node 'run_RulePolicy0' running 'RulePolicy.predict_action_probabilities'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.policies.rule_policy  - Current tracker state:
group-assistant-bot-rasa-1           | [state 1] user intent: greet | previous action name: action_listen
group-assistant-bot-rasa-1           | [state 2] user intent: greet | previous action name: utter_what_can_do
group-assistant-bot-rasa-1           | [state 3] user intent: ask_remind_call | previous action name: action_listen
group-assistant-bot-rasa-1           | [state 4] user intent: ask_remind_call | previous action name: action_set_reminder
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.policies.rule_policy  - There is a rule for the next action 'action_listen'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.engine.graph  - Node 'select_prediction' running 'DefaultPolicyPredictionEnsemble.combine_predictions_from_kwargs'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.policies.ensemble  - Predicted next action using RulePolicy.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 1.00.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.processor  - Policy prediction ended with events '[]'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'.
group-assistant-bot-rasa-1           | 2022-09-21 21:02:34 DEBUG    rasa.core.lock_store  - Deleted lock for conversation '1'.