Getting started with Rasa: a practical guide

devops入门16 分钟阅读2026/6/30

Last month, I was tasked with building a customer support bot for a fintech app. We started with a simple prompt-based approach—just throwing user messages at an LLM and hoping for the best. It worked fine for basic Q&A, but the moment we needed the bot to actually do things, like execute money transfers or update account details, everything fell apart. The LLM would hallucinate transaction amounts, skip confirmation steps, or silently fail to collect required information. We needed something that could handle fluid, natural conversation while strictly adhering to business logic. That's when I finally gave Rasa a serious look.

Rasa is an open-source framework for building conversational AI that operates at what they call "Level 3"—meaning it can actually understand context and execute multi-step workflows, not just parrot responses. Here's how I got it up and running, and what I learned along the way.

The Setup: Less Painful Than Expected

First, the prerequisites. Rasa Pro (the version with the LLM-powered features) requires a license key. You can grab a free Developer Edition license from Rasa's site—no credit card required, which I appreciated.

pip install rasa

That's it for the core install. Now, the LLM piece is interesting. Rasa provides a fine-tuned model hosted on HuggingFace for tutorials, but you can also run it locally if you don't want your data hitting a third-party API. For this walkthrough, I used their hosted deployment to save time, but in production, you'd absolutely want to swap that out.

Once installed, initialize a new project:

rasa init --template llm

This scaffolds a project with the LLM-powered assistant structure already in place. You'll get a directory with several YAML files—this is where Rasa lives.

Defining the Flow: Where Rasa Shines

The core concept that clicked for me is that Rasa separates what the bot can do from how it talks about it. You define your business logic as a flow, and the LLM handles the conversational wrapping.

Let's build that money transfer flow. Open flows.yml and define the process:

flows:
  transfer_money:
    name: transfer money
    description: Send money to another person
    steps:
      - collect: recipient
      - collect: amount
      - action: action_transfer_money

That's it. Three steps: collect the recipient, collect the amount, execute the transfer. The description field is crucial—it's what the LLM uses to understand when this flow should be triggered.

Now, here was my first surprise. I expected to write a bunch of training phrases like "I want to send cash" and "transfer funds to Joe." You don't have to. The LLM interprets user intent on the fly based on that description field. I was skeptical, but it genuinely works.

The Action: Making It Real

The action_transfer_money is a custom action where your actual business logic lives. Create a file actions.py:

from rasa.sdk import Action
from rasa.sdk.executor import CollectingDispatcher
from typing import Any, Text, Dict, List

class ActionTransferMoney(Action):
    def name(self) -> Text:
        return "action_transfer_money"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Dict[Text, Any],
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        
        recipient = tracker.get_slot("recipient")
        amount = tracker.get_slot("amount")
        
        # Your actual payment API call goes here
        # process_payment(recipient, amount)
        
        dispatcher.utter_message(
            text=f"All done. ${amount} has been sent to {recipient}."
        )
        
        return []

This is where you'd integrate with your real payment processor. The tracker object gives you access to all the collected slots—recipient and amount in our case.

The Magic: Fluid Conversation Meets Rigid Logic

Here's where I became a believer. Let me show you the actual conversations this setup handles:

The happy path (one piece at a time):

User: I want to send money
Bot: Who would you like to send money to?
User: to Jen
Bot: How much would you like to send?
User: $50
Bot: Please confirm: you want to transfer $50.0 to Jen?
User: yes
Bot: All done. $50.0 has been sent to Jen.

All info given at once:

User: I want to send 100 dollars to Joe
Bot: Please confirm: you want to transfer $100.0 to Joe?
User: yes.
Bot: All done. $100.00 has been sent to Joe.

Change of mind mid-conversation:

User: I need to send $50
Bot: Who would you like to send money to?
User: Jen
Bot: Please confirm: you want to transfer $50.0 to Jen?
User: actually no 60
Bot: Ok, I corrected the amount.
Bot: Please confirm: you want to transfer $60.0 to Jen?
User: yes.
Bot: All done. $60.00 has been sent to Jen.

That third scenario is where pure LLM approaches completely break down. The user contradicts themselves mid-flow, and Rasa handles it gracefully—correcting the slot value and re-confirming. No hallucinated transactions, no skipped steps.

Training and Testing

With your flow and action defined, train the model:

rasa train

Then start the action server in one terminal:

rasa run actions

And the bot in another:

rasa shell

This opens an interactive session where you can test conversations directly in your terminal. I spent a good hour throwing edge cases at it—typos, slang, changing my mind mid-sentence—and it handled most of them surprisingly well.

My first mistake: I initially forgot to start the action server separately and couldn't figure out why the transfer action wasn't firing. The bot would just go silent after collecting the slots. Don't be like me—always run both processes.

Practical Tips and Honest Limitations

Tips:

  1. Write good descriptions. The LLM relies heavily on your flow descriptions to route conversations. "Send money to another person" works infinitely better than "money_transfer."
  2. Test the weird paths. Users will say things like "send my roommate like 50 bucks maybe" and your bot needs to handle the uncertainty. Test these cases early.
  3. Use the confirmation step. For any action with real-world consequences, always add a confirmation step before execution. Rasa makes this easy to add to your flow.
  4. Slot validation is your friend. Define validation rules for collected slots—amounts should be positive numbers, recipients should match your user database, etc.

Limitations:

  1. The learning curve is real. Rasa's YAML-based configuration has a lot of depth, and the documentation, while comprehensive, can feel overwhelming. Expect to spend a weekend just understanding the architecture.
  2. LLM dependency means latency. Every user message hits the LLM for intent classification and response generation. In production, you'll need to think carefully about model hosting and response times.
  3. Debugging flows can be opaque. When a conversation goes off the rails, figuring out why the LLM made a particular routing decision isn't always straightforward. The Rasa X visualization tool helps, but it's an extra layer of complexity.
  4. The free tier has limits. The Developer Edition is great for learning, but you'll need a paid license for production use.

Rasa solved the exact problem I had: building a conversational bot that can chat naturally while respecting strict business rules. It's not the right tool for a simple FAQ bot—there are lighter solutions for that. But when you need a bot that can walk users through multi-step processes, handle their digressions, and never skip a critical confirmation step, Rasa is worth the investment in learning.

相关 Agent

D

Devin

Cognition AI 的自主 AI 软件工程师

了解更多 →