Contextual Response Rephraser | Rasa Documentation

Build your first agent in just a few minutes with Rasa Copilot.

New in 3.7

The Contextual Response Rephraser is part of Rasa's new Conversational AI with Language Models (CALM) approach and available starting with version 3.7.0.

Key Features

  1. Dynamic Responses: By employing the LLM to rephrase static response templates, the responses generated by your bot will sound more natural and conversational, enhancing user interaction.
  2. Contextual Awareness: The LLM uses the context and previous conversation turns to rephrase the templated response.
  3. Controllable: By starting with an existing template, we specify what the bot will say.
  4. Customizable: The prompt used for rephrasing can be modified and optimized for your use case.

Demo

The following example shows a demo of a chatbot using an LLM to rephrase static response templates. The first example is from an assistant without rephrasing the response templates. The second example is exactly the same assistant, with rephrasing for response templates enabled.

User: can you order me a pizza?

Bot:

Sorry, I am not sure how to respond to that. Type "help" for assistance.

User: can you order italian food instead

Bot:

Sorry, I am not sure how to respond to that. Type "help" for assistance.

No rephrasing: Chatbot handling out of scope requests

Rephrasing messages can significantly improve the user experience and make users feel understood:

User: can you order me a pizza?

Bot:

I'm not sure hot to help with that, but feel free to type "help" and I'll be happy to assist with other requests.

User: can you order italian food instead

Bot:

Unfortunately, I don't have the capability to order Italian food. However, I can provide help with other requests. Feel free to type "help" for more information.

LLM rephrasing: Chatbot with improved out of scope responses

Behind the scenes, the conversation state is the same in both examples. The difference is that the LLM is used to rephrase the bot's response in the second example.

Consider the different ways a bot might respond to an out of scope request like "can you order me a pizza?":

response comment
I'm sorry, I can't help with that stilted and generic
I'm sorry, I can't help you order a pizza acknowledges the user's request
I can't help you order a pizza, delicious though it is. Do you have any questions related to your account? reinforces the assistant's personality

The second and third examples would be difficult to achieve with templates.

Unchanged interaction flow

Note that the way the bot behaves is not affected by the rephrasing. Stories, rules, and forms will behave exactly the same way. But do be aware that user behaviour will often change as a result of the rephrasing. We recommend regularly reviewing conversations to understand how the user experience is impacted.

How to Use the Rephraser in Your Bot

The following assumes that you have already configured your NLG server.

To use the rephraser, add the following lines to your endpoints.yml file:

endpoints.yml

nlg:
  type: rasa_plus.ml.ContextualResponseRephraser

endpoints.yml

nlg:
  type: rephrase

To disable the rephraser completely delete the line from the endpoints.yml file.

Various Ways to Use Rephrasing

Rephrasing a specific response

By default, rephrasing is only enabled for responses that specify rephrase: True in the response template's metadata. To enable rephrasing for a response, add this property to the response's metadata:

domain.yml

responses:
  utter_greet:
    - text: "Hey! How can I help you?"
      metadata:
        rephrase: True

Rephrasing all responses

Instead of enabling rephrasing per response, you can enable it for all responses by setting the rephrase_all property to True in the endpoints.yml file:

endpoints.yml

nlg:
  type: rasa_plus.ml.ContextualResponseRephraser
  rephrase_all: true

endpoints.yml

nlg:
  type: rephrase
  rephrase_all: true

Setting this property to True will enable rephrasing for all responses, even if they don't specify rephrase: True in the response metadata. By default this behaviour is disabled, e.g. by default rephrase_all is set to false.

Rephrasing all responses except for a few

You can also enable rephrasing for all responses except for a few by setting the rephrase_all property to True in the endpoints.yml file and setting rephrase: False in the response metadata for the responses that should not be rephrased:

endpoints.yml

nlg:
  type: rasa_plus.ml.ContextualResponseRephraser
  rephrase_all: true

endpoints.yml

nlg:
  type: rephrase
  rephrase_all: true

domain.yml

responses:
  utter_greet:
    - text: "Hey! How can I help you?"
      metadata:
        rephrase: False

Disable rephrasing for default responses

By default, rephrasing is enabled for all default responses that are part of the default patterns. To disable rephrasing for default responses, override the response in the domain.yml file with a specific utterance.

domain.yml

responses:
  utter_can_do_something_else:
    - text: "Is there anything else I can assist you with?"

This will disable rephrasing for the default response:utter_can_do_something_else and use the specified response instead.

Customization

You can customize the LLM by modifying the following parameters in the endpoints.yml file.

LLM configuration

You can specify the openai model to use for rephrasing by setting the llm.model property in the endpoints.yml file:

endpoints.yml

nlg:
  type: rasa_plus.ml.ContextualResponseRephraser
  llm:
    model: gpt-5.1-2025-11-13

You can specify the openai model to use for rephrasing by setting the llm.model property in the endpoints.yml file:

endpoints.yml

nlg:
  type: rephrase
  llm:
    model: gpt-5.1-2025-11-13

You can specify the openai model to use for rephrasing by setting the llm.model_group property in the endpoints.yml file:

endpoints.yml

nlg:
  type: rephrase
  llm:
    model_group: gpt-5-1-openai-model

model_groups:
  - id: gpt-5-1-openai-model
    models:
      - provider: openai
        model: gpt-5.1-2025-11-13

Defaults to gpt-5.1-2025-11-13. The model name needs to be set to a generative model using the completions API of OpenAI.

If you want to use Azure OpenAI Service, you can configure the necessary parameters as described in the Azure OpenAI Service section.

Using Other LLMs

By default, OpenAI is used as the underlying LLM provider.

The used LLM provider can be configured in the endpoints.yml file to use another provider, e.g. bedrock:

For more information, see the LLM setup page on llms and embeddings

Temperature

The temperature allows you to control the diversity of the generated responses.

You can specify the temperature to use for rephrasing by setting the llm.temperature property in the endpoints.yml file:

endpoints.yml

nlg:
  type: rasa_plus.ml.ContextualResponseRephraser
  llm:
    temperature: 0.3

You can specify the temperature to use for rephrasing by setting the llm.temperature property in the endpoints.yml file:

endpoints.yml

nlg:
  type: rephrase
  llm:
    temperature: 0.3

You can specify the temperature to use for rephrasing by setting the llm.model_group property in the endpoints.yml file:

endpoints.yml

nlg:
  type: rephrase
  llm:
    model_group: gpt-5-1-openai-model

model_groups:
  - id: gpt-5-1-openai-model
    models:
      - provider: openai
        model: gpt-5.1-2025-11-13
        temperature: 0.3

Defaults to 0.3 (this is the default from OpenAI). The temperature is a value between 0.0 and 2.0 that controls the diversity of the generated responses. Lower temperatures result in more predictable responses, while higher temperatures result in more variable responses.

Example using different temperatures

User: can you order me a pizza?

Bot:

Sorry, I am not sure how to respond to that. Type "help" for assistance.

original conversation

User: can you order me a pizza?

Bot:

I'm sorry, I don't know how to do that. Could you type "help" for more information?

User: can you order me a pizza?

Bot:

I'm sorry, I don't understand what you need. If you need help, type "help".

User: can you order me a pizza?

Bot:

Sorry, I'm not quite sure how to help you with that. Can I direct you to our help faq instead?

This examples shows that the temperature is set to high: The response will lead to a user response that is likely not covered by the training data.

Prompt

You can change the prompt used to rephrase the response by setting the prompt property in the endpoints.yml file:

endpoints.yml

nlg:
  type: rasa_plus.ml.ContextualResponseRephraser
  prompt: prompts/response-rephraser-template.jinja2

endpoints.yml

nlg:
  type: rephrase
  prompt: prompts/response-rephraser-template.jinja2

The prompt is a Jinja2 template that can be used to customize the prompt. The following variables are available in the prompt:

User greeted the assistant.
USER: I want to open a bank account
What type of account would you like to open?

You can also customize the prompt for a single response by setting the rephrase_prompt property in the response metadata:

domain.yml

responses:
  utter_greet:
    - text: "Hey! How can I help you?"
      metadata:
        rephrase: True
        rephrase_prompt: |
          The following is a conversation with
          an AI assistant. The assistant is helpful, creative, clever, and very friendly.
          Rephrase the suggested AI response staying close to the original message and retaining
          its meaning. Use simple english.
          Context / previous conversation with the user:
          {{history}}
          {{current_input}}
          Suggested AI Response: {{suggested_response}}
          Rephrased AI Response:

Conversation History

The conversation history used inside the prompt can be configured in two ways:

To switch from summary mode to transcript mode, set the summarize_history property to False in the endpoints.yml file. The number of conversation turns to be used when summarize_history is set to False can be set via max_historical_turns. By default this value is set to 5.

endpoints.yml

nlg:
  - type: rephrase
    summarize_history: False
    max_historical_turns: 5

Security Considerations

The LLM uses the OpenAI API to generate rephrased responses. This means that your bot's responses are sent to OpenAI's servers for rephrasing.

Generated responses are send back to your bot's users. The following threat vectors should be considered:

More detailed information can be found in Rasa's webinar on LLM Security in the Enterprise.

Observations

Rephrasing responses is a great way to enhance your chatbot's responses. Here are some observations to keep in mind when using the LLM:

Success Cases

LLM shows great potential in the following scenarios:

Limitations

While the LLM delivers impressive results, there are a few situations where it may fall short:

Known Issues

Workarounds:

  1. Disable rephrasing for the utter_can_do_something_else response (see section Disable rephrasing for default responses).
  2. Set the summarize_history property of the rephraser to False (see section Conversation History).