Building AI Chatbots with Rasa
1. Architecture Overview (Rasa Stack)
Wiki topics:
🏛️ · Architecture
Building AI Chatbots with Rasa
1. Architecture Overview (Rasa Stack)
Rasa consists of two primary subsystems:
- Rasa NLU → intent classification + entity extraction
- Rasa Core → dialogue management (policies + state machine)
Key internal components:
- Pipeline (NLU processing chain)
- Stories / Rules (dialogue supervision)
- Domain (schema: intents, entities, slots, actions)
- Tracker (conversation state)
- Policies (decision logic)
2. Environment Setup
2.1 System Requirements
- Python 3.8–3.11 (strict compatibility matters)
- pip / venv (or Conda)
- Optional: Docker for containerization
2.2 Create Virtual Environment
python -m venv rasa-env
source rasa-env/bin/activate # Linux/macOS
rasa-env\Scripts\activate # Windows
2.3 Install Rasa
pip install rasa
Verify:
rasa --version
3. Initialize a Rasa Project
rasa init
This generates:
.
├── data/
│ ├── nlu.yml
│ ├── stories.yml
│ └── rules.yml
├── domain.yml
├── config.yml
├── actions/
│ └── actions.py
├── endpoints.yml
└── credentials.yml
4. NLU Pipeline Configuration
Edit config.yml.
Example pipeline (DIET-based modern setup):
pipeline:
- name: WhitespaceTokenizer
- name: RegexFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: DIETClassifier
epochs: 100
- name: EntitySynonymMapper
Explanation:
- Tokenizer → splits input text
- Featurizers → convert text → vectors
- DIETClassifier → multitask transformer (intent + entities)
5. Define Domain
domain.yml is the schema layer.
intents:
- greet
- goodbye
- ask_weather
entities:
- location
slots:
location:
type: text
responses:
utter_greet:
- text: "Hello! How can I help?"
actions:
- action_get_weather
6. Create Training Data
6.1 NLU Data (data/nlu.yml)
nlu:
- intent: greet
examples: |
- hi
- hello
- hey there
- intent: ask_weather
examples: |
- what's the weather in Zagreb
- weather in London
6.2 Stories (data/stories.yml)
stories:
- story: weather path
steps:
- intent: ask_weather
- action: action_get_weather
6.3 Rules (data/rules.yml)
rules:
- rule: respond to greeting
steps:
- intent: greet
- action: utter_greet
7. Custom Actions (Business Logic)
Install SDK:
pip install rasa-sdk
Edit actions/actions.py:
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
class ActionGetWeather(Action):
def name(self):
return "action_get_weather"
def run(self, dispatcher, tracker, domain):
location = tracker.get_slot("location")
dispatcher.utter_message(text=f"Weather in {location} is sunny.")
return []
Run action server:
rasa run actions
8. Training the Model
rasa train
Artifacts:
models/
└── model.tar.gz
9. Testing the Chatbot
9.1 Interactive Shell
rasa shell
9.2 Test NLU Only
rasa shell nlu
9.3 Automated Testing
rasa test
10. Dialogue Policies
In config.yml:
policies:
- name: RulePolicy
- name: MemoizationPolicy
- name: TEDPolicy
max_history: 5
epochs: 100
Key notes:
- TEDPolicy → transformer-based dialogue prediction
- MemoizationPolicy → exact story recall
- RulePolicy → deterministic flows
11. Slots and Context Handling
Slots maintain conversation memory.
Example:
slots:
location:
type: text
influence_conversation: true
Used by policies for context-aware predictions.
12. Forms (Structured Conversations)
Example use case: collecting user info.
forms:
weather_form:
required_slots:
- location
13. Integrations (Channels)
Configure credentials.yml:
rest:
14. Deployment Options
14.1 Local Server
rasa run --enable-api
14.2 Docker Deployment
docker run -p 5005:5005 rasa/rasa:latest
15. Tracker Store & Persistence
In endpoints.yml:
tracker_store:
type: SQL
dialect: "postgresql"
url: "localhost"
db: "rasa"
17. Evaluation & Metrics
rasa test nlu
rasa test core
Outputs:
- Precision / Recall / F1
- Confusion matrix
- Story accuracy
21. Minimal Production Blueprint
User → Channel (Slack/Web)
→ Rasa Server (NLU + Core)
→ Action Server (Python logic)
→ External APIs (weather, DB, etc.)
22. When to Use Rasa
Use Rasa if:
- You need on-premise NLP
- You require custom dialogue control
- Data privacy is critical
Avoid if:
- You want plug-and-play SaaS (consider alternatives like Dialogflow)
메타데이터
- post_id
- d7482db60ecb
- slug
- building-ai-chatbots-with-rasa-d7482db60ecb
- url
- https://medium.com/@juricavoda/building-ai-chatbots-with-rasa-d7482db60ecb
- canonical_url
- https://medium.com/@juricavoda/building-ai-chatbots-with-rasa-d7482db60ecb
- author_url
- https://medium.com/@juricavoda
- status
- ok
- fetched_at
- 2026-06-21 07:44:09