Rasa
Rasa is an active open-source machine learning framework (version 3.6.21) designed to automate text and voice-based conversations. It provides tools for Natural Language Understanding (NLU) and dialogue management, enabling developers to create contextual chatbots and voice assistants that can integrate with various platforms like Slack and Facebook. The project maintains a regular release cadence with frequent updates.
Common errors
-
ModuleNotFoundError: No module named 'rasa'
cause Rasa is not installed in the current Python environment, or the virtual environment is not activated, or the system is using a different Python interpreter than where Rasa was installed.fixEnsure your virtual environment is activated (`source .venv/bin/activate` on Linux/macOS, `.venv\Scripts\activate` on Windows). If Rasa is not installed, run `pip install rasa` within the activated environment. -
Couldn't connect to the server at 'http://localhost:5055/webhook'. Is the server running?
cause The Rasa action server, which hosts custom actions, is not running or is not accessible at the configured address (default: `http://localhost:5055/webhook`). This is common in Docker setups or when running components separately.fixIn a separate terminal, navigate to your Rasa project directory and run `rasa run actions`. If using Docker, ensure your `docker-compose.yml` correctly exposes and links the action server, and that the `endpoints.yml` inside the Rasa container points to the correct service name/IP within the Docker network (e.g., `action_endpoint: url: "http://action_server:5055/webhook"`). -
Error when trying to connect to 'mongod' tracker store. Using 'InMemoryTrackerStore'' instead. The causing error was: localhost:21476: [Errno 111] Connection refused
cause Rasa failed to connect to the configured external tracker store (e.g., MongoDB, Redis). This usually means the database server is not running, is inaccessible, or there are incorrect connection details/credentials in `endpoints.yml`.fixVerify that your database server (e.g., MongoDB or Redis) is running and accessible from where Rasa is launched. Check the `endpoints.yml` file for correct `url`, `port`, `db`, `username`, and `password` settings. Ensure necessary network ports are open if connecting remotely or across Docker containers.
Warnings
- breaking Rasa 3.6.21 introduced a model breaking change by replacing `pickle` and `joblib` with safer alternatives like `json`, `safetensors`, and `skops` for component serialization. Models trained with older versions will not be compatible.
- gotcha Rasa 3.x has specific Python version requirements. The `rasa` PyPI package currently requires Python <3.11, >=3.8. Using incompatible Python versions can lead to `ModuleNotFoundError` or other installation issues.
- deprecated Rasa X, the UI for Rasa, does not support Rasa Open Source versions 3.x and above. Attempting to use `rasa x` with Rasa 3.x will result in an error.
- breaking Rasa 3.0 introduced a major architecture revamp, transitioning from a sequential training pipeline to a graph architecture. This significantly changed how NLU and policy components interact and can affect custom components, particularly the `process` method signature for NLU components (now accepting `List[Message]` instead of `Message`).
Install
-
pip install rasa -
pip install 'rasa[full]'
Imports
- Agent
from rasa.core.agent import Agent
- Action
from rasa_sdk import Action
- CollectingDispatcher
from rasa_sdk.executor import CollectingDispatcher
- TrackerStore
from rasa.core.tracker_store import MongoTrackerStore
from rasa.core.tracker_store import TrackerStore
- Interpreter
from rasa_nlu.model import Interpreter
from rasa.nlu.model import Interpreter
Quickstart
import os
# Ensure you are in an empty directory for this quickstart
# In a real project, replace 'tutorial' with your desired template or omit for default
# os.system('rasa init --template tutorial')
# os.system('rasa train')
# os.system('rasa shell')
print("To start a new Rasa project, open your terminal and run:")
print("1. rasa init --template tutorial")
print("2. cd <your-project-name>")
print("3. rasa train")
print("4. rasa shell")
print("For custom actions, run 'rasa run actions' in a separate terminal after step 3.")