Rasa - Conversational AI Framework Cheatsheet
Rasa is an open-source framework for building contextual conversational assistants. Unlike prompt-only chatbots, Rasa gives you explicit control over dialogue: you define intents, entities, and flows, and the assistant follows business logic you specify rather than whatever the model improvises. Everything runs on your own infrastructure, which matters for regulated domains. Modern Rasa (CALM) blends LLM-based understanding with deterministic flow execution — the model interprets, your flows decide.
Installation
| Method | Command |
|---|
| pip | pip install rasa |
| New project | rasa init |
| Requirements | Python 3.9–3.11 (check current support) |
| Verify | rasa --version |
Project Structure
| Path | Contains |
|---|
domain.yml | Intents, entities, slots, responses, actions |
data/nlu.yml | Training examples per intent |
data/stories.yml | Example conversation paths |
data/rules.yml | Deterministic rules |
data/flows.yml | CALM business-logic flows |
config.yml | NLU/policy pipeline |
actions/actions.py | Custom Python actions |
Core CLI
| Command | Description |
|---|
rasa init | Scaffold a new assistant |
rasa train | Train the model |
rasa shell | Chat with it in the terminal |
rasa run | Start the server |
rasa run actions | Start the custom action server |
rasa test | Run tests against test stories |
rasa interactive | Interactive training/correction |
rasa data validate | Check data consistency |
Defining Intents & Responses
# domain.yml
intents:
- greet
- check_balance
responses:
utter_greet:
- text: "Hi! How can I help?"
slots:
account_id:
type: text
mappings:
- type: from_entity
entity: account_id
actions:
- action_fetch_balance
# data/nlu.yml
nlu:
- intent: check_balance
examples: |
- what's my balance
- how much money do I have
- show account [12345](account_id)
Flows (CALM)
# data/flows.yml
flows:
check_balance:
description: Look up the user's account balance
steps:
- collect: account_id
- action: action_fetch_balance
- action: utter_balance
| Step type | Does |
|---|
collect | Ask for and fill a slot |
action | Run a custom or utter action |
link | Jump to another flow |
set_slots | Assign slot values |
next with if | Conditional branching |
Flows are deterministic: the LLM decides which flow the user wants, but the flow itself executes exactly as written.
Custom Actions
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class ActionFetchBalance(Action):
def name(self) -> str:
return "action_fetch_balance"
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain):
account = tracker.get_slot("account_id")
balance = lookup_balance(account)
dispatcher.utter_message(text=f"Your balance is ${balance}")
return []
Run with rasa run actions (default port 5055).
Testing
rasa test # end-to-end tests
rasa test nlu --cross-validation
rasa data validate # catch domain/data mismatches
| Test type | Checks |
|---|
| NLU tests | Intent/entity accuracy |
| Story tests | Full conversation paths |
| Cross-validation | Generalization of NLU |
Channels & Deployment
| Channel | Note |
|---|
| REST | Default HTTP endpoint |
| Web widget | Embeddable chat |
| Slack / Teams / Telegram | Built-in connectors |
| Voice | Via telephony integrations |
| Deployment | Docker, Kubernetes/Helm, self-hosted |
Rasa vs LLM-Only Chatbots
| Aspect | Rasa | Prompt-only LLM bot |
|---|
| Control | Explicit flows/business logic | Emergent, hard to constrain |
| Predictability | High | Variable |
| Compliance | Auditable paths | Difficult |
| Hosting | Fully self-hosted | Usually API-dependent |
| Best for | Regulated, task-oriented assistants | Open-ended conversation |
For open-ended agents see LangGraph or Mastra; Rasa’s strength is deterministic, auditable task flows.
Resources