Custom 'actions.py' file not triggered on Rasa X

Hi,

I’ve been building a chatbot and ran into issues with getting the actions.py file to trigger when it needs to.

20%20pm

See screenshot. It is indicating that the action has been triggered on the backend, but the message is not displaying in the chat.

I have read through the other posts related to this issue, and it doesn’t seem like there has been a satisfactory answer.

I have also tested my code locally on my computer where I can spin up a local server for the actions.py file, and it works fine.

So I don’t know what I am missing in order to get this to work. The below are some relevant posts earlier.

Here are the relevant files.

docker-compose.yml

version: "3.4"

x-database-credentials: &database-credentials
  DB_HOST: "db"
  DB_PORT: "5432"
  DB_USER: "${DB_USER:-admin}"
  DB_PASSWORD: "${DB_PASSWORD}"
  DB_LOGIN_DB: "${DB_LOGIN_DB:-rasa}"

x-rabbitmq-credentials: &rabbitmq-credentials
  RABBITMQ_HOST: "rabbit"
  RABBITMQ_USERNAME: "user"
  RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}

x-redis-credentials: &redis-credentials
  REDIS_HOST: "redis"
  REDIS_PORT: "6379"
  REDIS_PASSWORD: ${REDIS_PASSWORD}
  REDIS_DB: "1"

x-duckling-credentials: &duckling-credentials
  RASA_DUCKLING_HTTP_URL: "http://duckling:8000"

x-rasax-credentials: &rasax-credentials
  LOCAL_MODE: "false"
  RASA_X_HOST: "http://rasa-x:5002"
  RASA_X_USERNAME: ${RASA_X_USERNAME:-admin}
  RASA_X_PASSWORD: ${RASA_X_PASSWORD:-}
  RASA_X_TOKEN: ${RASA_X_TOKEN}
  JWT_SECRET: ${JWT_SECRET}
  RASA_USER_APP: "http://app:5055"
  RASA_PRODUCTION_HOST: "http://rasa-production:5005"
  RASA_WORKER_HOST: "http://rasa-worker:5005"
  RASA_TOKEN: ${RASA_TOKEN}

x-rasa-credentials: &rasa-credentials
  <<: *rabbitmq-credentials
  <<: *rasax-credentials
  <<: *database-credentials
  <<: *redis-credentials
  <<: *duckling-credentials
  RASA_TOKEN: ${RASA_TOKEN}
  RASA_MODEL_PULL_INTERVAL: 10
  RABBITMQ_QUEUE: "rasa_production_events"

x-rasa-services: &default-rasa-service
  restart: always
  image: "rasa/rasa:${RASA_VERSION}-full"
  expose:
    - "5005"
  command: >
    x
    --no-prompt
    --production
    --config-endpoint http://rasa-x:5002/api/config?token=${RASA_X_TOKEN}
    --port 5005
    --jwt-method HS256
    --jwt-secret ${JWT_SECRET}
    --auth-token '${RASA_TOKEN}'
    --cors "*"
  depends_on:
    - rasa-x
    - rabbit
    - redis

services:
  rasa-x:
    restart: always
    image: "rasa/rasa-x:${RASA_X_VERSION}"
    expose:
      - "5002"
    volumes:
      - ./models:/app/models
      - ./environments.yml:/app/environments.yml
      - ./credentials.yml:/app/credentials.yml
      - ./endpoints.yml:/app/endpoints.yml
      - ./logs:/logs
      - ./auth:/app/auth
    environment:
      <<: *database-credentials
      <<: *rasa-credentials
      SELF_PORT: "5002"
      DB_DATABASE: "${DB_DATABASE:-rasa}"
      RASA_MODEL_DIR: "/app/models"
      PASSWORD_SALT: ${PASSWORD_SALT}
      RABBITMQ_QUEUE: "rasa_production_events"
      RASA_X_USER_ANALYTICS: "0"
      SANIC_RESPONSE_TIMEOUT: "3600"
    depends_on:
      - db

  rasa-production:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "production"
      DB_DATABASE: "tracker"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  rasa-worker:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "worker"
      DB_DATABASE: "worker_tracker"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  app:
    restart: always
    image: "rasa/rasa-x-demo:${RASA_X_DEMO_VERSION}"
    expose:
      - "5055"
    depends_on:
      - rasa-production

  db:
    restart: always
    image: "bitnami/postgresql:11.3.0"
    expose:
      - "5432"
    environment:
      POSTGRESQL_USERNAME: "${DB_USER:-admin}"
      POSTGRESQL_PASSWORD: "${DB_PASSWORD}"
      POSTGRESQL_DATABASE: "${DB_DATABASE:-rasa}"
    volumes:
      - ./db:/bitnami/postgresql

  rabbit:
    restart: always
    image: "bitnami/rabbitmq:3.7.17"
    environment:
      RABBITMQ_HOST: "rabbit"
      RABBITMQ_USERNAME: "user"
      RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}
      RABBITMQ_DISK_FREE_LIMIT: "{mem_relative, 0.1}"
    expose:
      - "5672"

  duckling:
    restart: always
    image: "rasa/duckling:latest"
    expose:
      - "8000"
    command: ["duckling-example-exe", "--no-access-log", "--no-error-log"]

  nginx:
    restart: always
    image: "rasa/nginx:${RASA_X_VERSION}"
    ports:
      - "80:8080"
      - "443:8443"
    volumes:
      - ./certs:/opt/bitnami/certs
      - ./terms:/opt/bitnami/nginx/conf/bitnami/terms
    depends_on:
      - rasa-x
      - rasa-production
      - app

  redis:
    restart: always
    image: "bitnami/redis:5.0.5"
    environment:
      REDIS_PASSWORD: ${REDIS_PASSWORD}
    expose:
      - "6379"

docker-compose.override.yml

version: '3.4'
services:
  action_server:
    image: 'rasa/rasa-sdk:latest'
    volumes:
      - './actions:/app/actions'
    ports:
      - '5055:5055'
    depends_on:
      - rasa-production

endpoints.yml

action_endpoint:
  url: http://action_server:5055/webhook

actions.py

from typing import Any, Text, Dict, List, Union

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction

class ActionIntroDataScience(Action):
    def name(self) -> Text:
        return "action_intro_ds"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        dispatcher.utter_message(
            text="Data science is a field that combines ideas from statistics and computer science.\nIt involves building data pipelines, data analysis, building models and applying these models for prediction or inference."
        )
        return []
1 Like

Hey @slurbeaker are there any logs in the rasa-production or rasa-app containers related to this?

@akelad @erohmensing @stephens
Failed to run custom action 'action_courses'. Couldn't connect to the server at 'http://app:5055/webhook'. Is the server running? Error: Cannot connect to host app:5055 ssl:default [No address associated with hostname]

These are my rasa-production logs, I seem to be facing the same error. I followed the tutorial illustrated here. Could you please guide me?

My docker-compose.override.yml file looks like this

version: '3.4'
services:
  rabbit:
    ports:
      - "5672:5672"
  app:
    image: 'rasa/rasa-sdk:latest'
    volumes:
      - './actions:/app/actions'
    expose:
      - '5055'
    depends_on:
      - rasa-production

@karman1102 which Rasa X version are you on? And can you check the logs of the app container with docker-compose logs app?

Hello everybody!

Unfortunately I have the same problem. To date, it has worked for me. I followed the tutorial from the Rasa Masterclass. Today I downloaded the new update of Rasa X via the one-line deploy script. Since then my actions.py file is no longer recognized. I don’t get any errors in the app container. For that I get a lot of mistakes in the production container:

/opt/venv/lib/python3.7/site-packages/rasa/core/brokers/pika.py:294: FutureWarning: Your Pika event broker config contains the deprecated `queue` key. Please use the `queues` key instead.self.queues = self._get_queues_from_args(queues, kwargs)

2020-06-24 14:39:37 ERROR pika.connection - Connection closed while authenticating indicating a probable authentication error

2020-06-24 14:39:37 WARNING rasa.core.brokers.pika - Connecting to ‘rabbit’ failed with error ‘ConnectionClosedByBroker: (403) ‘ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.’’. Trying again.

2020-06-24 14:39:37 ERROR pika.adapters.utils.connection_workflow - AMQPConnector - reporting failure: AMQPConnectorAMQPHandshakeError: ProbableAuthenticationError: Client was disconnected at a connection stage indicating a probable authentication error: (“ConnectionClosedByBroker: (403) ‘ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.’”,)

2020-06-24 14:39:37 ERROR pika.adapters.utils.connection_workflow - AMQPConnectionWorkflow - reporting failure: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorAMQPHandshakeError: ProbableAuthenticationError: Client was disconnected at a connection stage indicating a probable authentication error: (“ConnectionClosedByBroker: (403) ‘ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.’”,); first exception - None

2020-06-24 14:39:37 ERROR pika.adapters.base_connection - Full-stack connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorAMQPHandshakeError: ProbableAuthenticationError: Client was disconnected at a connection stage indicating a probable authentication error: (“ConnectionClosedByBroker: (403) ‘ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.’”,); first exception - None

2020-06-24 14:39:37 ERROR pika.adapters.base_connection - Self-initiated stack bring-up failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorAMQPHandshakeError: ProbableAuthenticationError: Client was disconnected at a connection stage indicating a probable authentication error: (“ConnectionClosedByBroker: (403) ‘ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.’”,); first exception - None

2020-06-24 14:40:24.371281: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: UNKNOWN ERROR (303)

@Jenny could you please create a new post? Helping multiple people in the same thread can get confusing

Hi @akelad, thanks for the prompt reply. I am currently on 0.29.1 I am yet to update the version of rasa but if this seems to be the main impediment; I’ll do that before completing rest of the steps.

and my logs of the app container are as follows: (I am aware of an import error which I have cropped out of the image)

This log went on for a few iterations before finally coming to rest

Then you’ll need to fix the import error to get the image up and running

Oh I get it now. It’s just like a python file failing to compile. Should have guessed it earlier. Thought the behavior must have been different for a docker file, apologies for the foolish doubt.