Site icon JD Bots

Rasa Tutorial — Part 9: Scoped Instructions: Show Claude Only the Rules That Apply

Featured image for Rasa Tutorial Part 9, Scoped Instructions: Show Claude Only the Rules That Apply. A memory value, topic = loan, keeps the paragraph marked if: topic is loan in skill.md and leaves the paragraph marked if: topic is card out, so only the loan rule reaches what Claude reads; two notes say the paragraphs are checked again on every turn and left out until the topic is set.

Rasa Tutorial Part 9: Scoped Instructions.

Some instructions only make sense in one situation: a rule for loan appointments, another for card appointments. In this part of the Rasa Tutorial, you give each case its own paragraph in a Rasa Mantle skill, marked with an if: line. These scoped instructions reach Claude only while their condition is true, so Claude never reads a rule that doesn’t apply.

By the end, the banking agent from Part 8 will turn down a Saturday loan appointment, because loan advisers work Monday to Friday, and will send card appointments to the branch with the card desk. You’ll see in the Rasa Inspector that Claude reads only the rule for the customer’s topic.

This is Part 9 of the Rasa Tutorial. The parts in Module C, Progressive Control:

All parts of the Rasa Tutorial

Module A: Start Here

Module B: Building Skills

Module C: Progressive Control

Module D: Orchestration

  • Part 12: The Runtime Loop: How Mantle Handles a Turn
  • Part 13: Guarantees and Guardrails
  • Part 14: Skills and Routing
  • Part 15: Context Management

Module E: Agent Setup

  • Part 16: agent.yml: Identity, Persona and Rules
  • Part 17: integrations.yml: Claude, Model Groups and Routing
  • Part 18: MCP Tools
  • Part 19: Hooks
  • Part 20: Build Faster with the Rasa Copilot

Module F: Voice

  • Part 21: Talk to Your Agent in the Browser
  • Part 22: Designing for Voice
  • Part 23: Connect a Phone Line
  • Part 24: Monitor Voice Calls

Module G: Channels

  • Part 25: The REST Channel and a Website Chat Widget
  • Part 26: Microsoft Teams

Module H: Observability

  • Part 27: Tracing with Langfuse
  • Part 28: Metrics and Conversation Events

Module I: Deploy

  • Part 29: Run Your Agent with Docker
  • Part 30: CI/CD for a Rasa Agent
  • Part 31: Deploy to Kubernetes with Rasa’s Helm Chart
  • Part 32: Deploy on AWS
  • Part 33: Deploy on Azure
  • Part 34: Deploy on Google Cloud

Module J: Rasa Studio

  • Part 35: Rasa Studio with a Mantle Agent

Module K: Wrap-up

  • Part 36: Final Project, Cheat Sheet and What to Learn Next

Cost: Rasa’s Developer Edition licence is free. Claude is pay-per-use: Claude Sonnet 5.5, the model this series uses, costs $2 per million input tokens and $10 per million output tokens (Claude pricing). In this part you send seven messages, which make twelve calls to Claude: about $0.08. That’s an estimate: in Part 2, eight calls cost $0.05 on the Claude Console. Training also indexes Part 6’s reference document with Azure OpenAI again, which costs far less than a cent. The confirmation question and the other responses cost nothing: Rasa sends them without calling Claude.

Prerequisites

Step 1: Add a Rule That Applies Only to Loans

Open Terminal, go to your project folder and turn on its virtual environment:

Terminal

cd my-rasa-agent
source .venv/bin/activate

Some rules belong to one kind of appointment only. You could list them all in the instructions and leave Claude to pick the right one, but Rasa’s Scoped Instructions guide warns that with plain prose the model sometimes picks the wrong path or blends two of them. A scoped instruction is a paragraph that Rasa sends to Claude only while its condition is true, so the wrong rule isn’t there to follow.

Open skills/book_appointment/skill.md and add this paragraph at the end of the file, after step 2, with a blank line before it:

skills/book_appointment/skill.md (excerpt)

if: session.book_appointment.topic == 'loan'
Loan advisers work Monday to Friday only. If the customer wants a Saturday,
explain this and ask which weekday suits them instead.

Write each scoped paragraph as a rule or a question for Claude. A paragraph that makes Claude say something before it books, such as “Before you book, tell the customer to bring…”, can make the customer confirm twice: Fixed: Rasa Mantle Asks the Customer to Confirm Twice Before a Tool Runs shows why, and where such a line belongs.

Step 2: Add a Rule for Card Appointments

Each case gets its own if: paragraph. Add the card rule under the loan rule, again with a blank line between them:

skills/book_appointment/skill.md (excerpt)

if: session.book_appointment.topic == 'card'
Card appointments take place only at Riverton Station, where our card desk
is. If the customer chose another branch, explain this and ask whether
Riverton Station suits them.

There’s no else: in instructions: every case is its own if: paragraph, and a topic with no paragraph, such as new_account, simply gets no extra rule. Here’s the whole file now:

skills/book_appointment/skill.md

---
name: Book an Appointment
description: Branch appointments - book a meeting with an adviser at one of our branches

complete_when:
  condition: "session.book_appointment.booking_reference"

tool_constraints:
  - book_appointment:
      requires: >
        session.book_appointment.branch
        and session.book_appointment.topic
        and session.book_appointment.day
      requires_confirmation:
        enabled: true
        utter_for_confirmation: utter_ask_book_appointment_confirmation
        utter_on_user_denial: utter_book_appointment_cancelled

utter:
  - utter_book_appointment_confirmed:
      when: "session.book_appointment.booking_reference"
---

Help the customer book an appointment with an adviser at a branch.

1. Find out which branch they want to visit, what the appointment is about
   and which day suits them. Ask for anything they haven't said, one question
   at a time. Record each answer with `set_memory` as soon as they give it.
2. When you have all three, book it with @tool.book_appointment.

if: session.book_appointment.topic == 'loan'
Loan advisers work Monday to Friday only. If the customer wants a Saturday,
explain this and ask which weekday suits them instead.

if: session.book_appointment.topic == 'card'
Card appointments take place only at Riverton Station, where our card desk
is. If the customer chose another branch, explain this and ask whether
Riverton Station suits them.

Step 3: Train Your Agent

Terminal

rasa train

Rasa checks every if: condition while it trains, so a field name that doesn’t exist stops the training with an error that names it. When it finishes, the last line names your new agent package:

Output (the line that matters)

2026-11-21 18:43:10 INFO     rasa.mantle.model_archive.snapshot  - [info     ] Mantle agent package saved at 'models/20261121-184308-freezing-polarization.tar.gz'.

The INFO notes above it are the same as in Part 8; they aren’t errors.

Step 4: Book a Loan Appointment on a Saturday

Terminal

rasa inspect

When the Rasa Inspector opens in your browser, send I would like to book an appointment with an adviser. Then answer Claude’s questions one at a time: Lakeside, please., It is about a loan. and Saturday, please. When Claude asks for another day, reply Friday, then., and answer your confirmation question with Yes, please.

The loan rule at work: no Saturday, then a normal booking on Friday.

As soon as it knew the topic, Claude mentioned that loan advisers work Monday to Friday. When you asked for Saturday anyway, it turned it down and asked for a weekday, then booked only after your confirmation question from Part 8. Claude’s wording will differ, and your booking reference too.

Step 5: See Which Rule Claude Read

Click the Inspector mode button at the top of the chat and choose Inspect. Then click the LLM call just above Claude’s answer to Saturday, please. The middle panel shows the skill as it stood at that message:

The outlined paragraph is the one whose condition matches memory.

Each if: paragraph is a box with its condition on top. The outlined one matches memory, where the topic is loan.

The LLM call panel on the right shows the whole prompt Rasa sent to Claude. Click the two LLM calls just below It is about a loan. in turn, and find ### Instructions: in each Prompt. The first call, made before the topic was saved, ends at step 2:

Output (the lines that matter)

### Instructions:
Help the customer book an appointment with an adviser at a branch.

1. Find out which branch they want to visit, what the appointment is about
   and which day suits them. Ask for anything they haven't said, one question
   at a time. Record each answer with `set_memory` as soon as they give it.
2. When you have all three, book it with @tool.book_appointment.

The second call, made right after Claude saved the topic, has the loan rule, and only the loan rule:

Output (the lines that matter)

### Instructions:
Help the customer book an appointment with an adviser at a branch.

1. Find out which branch they want to visit, what the appointment is about
   and which day suits them. Ask for anything they haven't said, one question
   at a time. Record each answer with `set_memory` as soon as they give it.
2. When you have all three, book it with @tool.book_appointment.

Loan advisers work Monday to Friday only. If the customer wants a Saturday,
explain this and ask which weekday suits them instead.

Step 6: Try the Card Rule

Choose Preview from the Inspector mode menu, click the circular arrow (Restart conversation) at the top of the chat, and send I need an appointment about my card at Lakeside on Friday.

A card appointment gets the card rule instead.

This time the card rule applied: Claude explained that card appointments happen only at Riverton Station and offered that branch instead of booking Lakeside. The loan rule stayed out of the prompt.

When you’re done, go back to Terminal and press Ctrl+C to stop the agent.

Clean Up

If the agent is still running, press Ctrl+C in Terminal to stop it. Claude and Azure OpenAI both charge only for what your agent uses, so a stopped agent costs nothing.

Keep the my-rasa-agent folder: Part 10 builds on it.

Common Mistakes

MistakeDo this instead
Leaving a blank line between the if: line and its paragraphPut the paragraph right under the if: line. A blank line ends what the condition covers.
Writing else: for the other casesGive every case its own if: paragraph. For “every topic except loans”, Rasa’s Scoped Instructions guide uses not, as in if: not session.book_appointment.topic == 'loan'.
Comparing with a value the field doesn’t allow, such as 'Loan'Copy the value exactly as it appears in the field’s enum_values in memory.yml. Training doesn’t check values, and a paragraph that never matches never reaches Claude.
Starting a paragraph with words that need its condition, such as “In that case…”Claude doesn’t see the if: line, so name the case in the text: “Loan advisers work…”.
Telling Claude to say something before the tool runs, such as “Before you book, tell…”Write rules and questions, and put a line that must always be said into a response. See Fixed: Rasa Mantle Asks the Customer to Confirm Twice Before a Tool Runs.

Troubleshooting

ProblemFix
rasa train stops with “… has a prose ‘if:’ condition referencing memory key ‘book_appointment.topics’ that is not readable while this skill is active”The field name in the condition is wrong. Write session, the skill’s folder name and a field from its memory.yml, as in session.book_appointment.topic.
Claude ignores the ruleIn Inspect mode, open the LLM call and find ### Instructions: in its Prompt. If the paragraph isn’t there, its condition wasn’t true: check that the topic was saved, and that the value matches enum_values exactly.
The customer is asked to confirm twiceA paragraph told Claude to do something before the booking. See Fixed: Rasa Mantle Asks the Customer to Confirm Twice Before a Tool Runs.

FAQ

Does Claude see a scoped paragraph before the field has a value?

Not in Rasa Pro 3.22: as Step 5 shows, both rules were left out until the topic was saved. An unset field counts as None (Rasa’s Conditions reference), so == 'loan' is false. The Scoped Instructions guide says every paragraph is visible while the field is unset, so check what your version does in the Inspector.

Can a condition check more than one field?

Yes. Join conditions with and and or, and turn one around with not, as in Part 8’s requires.

Is a scoped rule a guarantee?

No. It decides what Claude reads, and Claude still decides what to do with it. For something that must never happen, such as a Saturday loan booking, also build it into the tool’s requires condition from Part 8, so Rasa itself blocks the call.

When do I need an ordered block instead?

When part of a skill must branch strictly one way or the other, with a fallback for everything else, or must run its steps in a fixed order. The Scoped Instructions guide points to ordered blocks for that, and Part 10 covers them.

Conclusion

You gave the booking skill two scoped instructions. An if: line on a paragraph makes Rasa send it to Claude only when memory matches, so the loan rule reached Claude only in the loan conversation, and the card rule only for the card appointment. Claude still words every reply, but it no longer has the other topic’s rule to mix up.

← Previous: Part 8: Tool Constraints: Make Your Agent Ask Before It Acts

Coming next: Part 10: Ordered Blocks.

Additional Resources

Related

Rasa, Claude, Azure and other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with or endorsed by Rasa Technologies, Anthropic or Microsoft.

Exit mobile version