- Flows determine the overall conversation structure (the “what” and “when”).
- Patterns are triggered when users deviate, clarify, or repair parts of the conversation.
- Responses are the assistant’s prompts, messages, or follow-ups.
Ways of Customizing Assistant Tone in Rasa
There are two main ways to adapt your assistant’s messaging style:- Response Rephraser Dynamically rewrites your responses using an LLM prompt. You can instruct the LLM to adopt or maintain a specific personality or tone.
- Conditional Response Variations Predefine different text variations (often for different slot conditions, contexts, or channels). This method is more static, but ensures each user scenario has a hand-crafted, on-brand response.
What Is the Response Rephraser?
The Response Rephraser is an LLM-powered component that takes a templated response (for example, “I’m sorry, I can’t help with that”) and rephrases it while preserving your original meaning and factual content. Its key benefits are:- Dynamically adapting tone: Use a single base response but produce many variations, all preserving your brand guidelines.
- Contextual awareness: The rephraser can read the conversation history and user input, ensuring rephrasings make sense in context.
- Centralized maintenance: If you decide to change your brand style (e.g., become more informal), update the LLM prompt rather than rewriting all your responses.
What Are Conditional Response Variations?
Conditional response variations let you define several static message templates under the same response name but tailor them to different states of the conversation. For example, you might have:- A casual greeting if the
user_is_repeat_customerslot is set totrue. - A more formal greeting otherwise.
When to Use Which?
- Use the Response Rephraser if you want:
- Dynamic, LLM-powered rewording that can adapt to your brand voice, summarizing or refining the text while retaining the original meaning.
- A simpler way to unify tone across your entire assistant, especially for messages that appear in repair patterns or emergent flows.
- Use Conditional Response Variations if you want:
- Strict control over the exact wording in specific contexts or channels (e.g., “VIP members get a special greeting”).
- Variation without an external LLM call, or you need a guaranteed brand-approved statement for certain user segments.
How to Create Conditional Response Variations
- In your domain file, provide multiple responses under the same response name.
- Add a
conditionblock for each variant to specify which slot values must match (or which channel must match). - Always include a default fallback response (with no condition) in case none of the conditions are met.
domain.yml
How to Customize the Response Rephraser
You can configure the Response Rephraser to ensure it outputs messages aligned with your desired personality or brand identity.1. Enabling Rephraser Across All Responses
In yourendpoints.yml file, add:
endpoints.yml
metadata: { rephrase: false } in your domain.
2. Enabling Rephraser for Specific Responses
If you prefer a more selective approach:- Enable
type: rephraseinendpoints.ymlwithout settingrephrase_all: true. - Add
metadata: { rephrase: true }to only the responses you’d like rephrased:
domain.yml
3. Setting a Custom Prompt
You can supply your own Jinja2 prompt template to the rephraser. This is especially important to define a tone or style. For example:endpoints.yml
.jinja2 file, you could add instructions such as:
“Use a casual, friendly tone in second-person. Always address the user by name if available.”You can also override the default prompt for a single response by setting
rephrase_prompt in its metadata (see the reference docs for an example).
How to Test Rephrased Responses?
Because the final assistant message may be partially (or entirely) generated by an LLM, it’s crucial to test for both correctness and style:- Generative Response Is Relevant Ensures the rephrased message is on-topic and aligns with the user’s query.
tests/e2e_test_cases.yml
- Generative Response Is Grounded Ensures the rephrased message remains factually accurate to the original domain response or RAG context.
tests/e2e_test_cases.yml