I created new files for Rasa: nlu.yml, rules.yml, stories.yml, actions.py. How do I proceed?
Assistant
Creating new files for a Rasa project is the initial step in developing a conversational AI with Rasa. After creating nlu.yml, rules.yml, stories.yml, and actions.py, there are several steps you should follow to develop, train, and interact with your Rasa chatbot. Here’s a structured way to proceed:
1. Populate Your Files
nlu.yml: Add examples of intents and entities here. This is crucial for the model to understand what users want.
actions.py: Implement custom actions here. You might need to run a custom server for actions if you use them.
python
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class ActionHelloWorld(Action):
def name(self) -> Text:
return "action_hello_world"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text="Hello World!")
return []
2. Train Your Model
After populating your files with relevant data, it’s time to train your model. Use the terminal or command prompt for this.
sh
rasa train
This command looks for data in your nlu.yml, stories.yml, and rules.yml files and creates a model for you.
3. Test Your Chatbot in Shell
Post-training, you can test your chatbot directly in the terminal.
sh
rasa shell
If you have custom actions, make sure to start the action server in a new terminal window.
sh
rasa run actions
And then in another terminal, start the Rasa shell.
4. Interacting and Iterating
Based on the interactions, you might find areas for improvement or further scenarios to cover. Update your .yml files and actions.py as needed and repeat the training process to enhance your chatbot's capabilities.
5. Debugging and Testing
You can debug issues by carefully looking at the log outputs when interacting with your chatbot. Rasa also provides a way to test your bot against a set of test conversations. This can be done by adding tests in the tests directory and then running:
sh
rasa test
6. GUI Tools
For a more GUI-based approach to training and testing, consider using Rasa X. Rasa X helps in sharing, testing, and improving your bot with real users:
sh
rasa x
This workflow should help you proceed with developing your Rasa project. Remember, building a conversational AI is iterative. Constantly test with real users, gather feedback, and refine your bot for the best user experience.
User
UserWarning: Parsed an intent 'ask_health_question' which is not defined in the domain. Please make sure all intents are listed in the domain.
More info at https://rasa.com/docs/rasa/domain
Assistant
The warning you've encountered indicates that the intent ask_health_question mentioned in your training data (likely within nlu.yml) is not defined in your domain file (domain.yml). The domain file is crucial as it informs Rasa about all the intents, entities, slots, responses, and actions that your bot recognizes and can perform.
To resolve this warning, you need to:
Check and Update Your Domain File: Ensure that the ask_health_question intent is listed under the intents section of your domain.yml. If it's missing, you need to add it. Your domain file should look something like this:
yaml
intents:
- greet
- goodbye
- ask_health_question # Make sure this is included
responses:
utter_greet:
- text: "Hello! How can I help you today?"
utter_goodbye:
- text: "Goodbye!"
actions:
- utter_greet
- utter_goodbye
Adjust the content based on your actual intents and responses.
Verify File Consistency: Ensure there are no typos in the intent names across different files (nlu.yml, domain.yml, stories.yml, and rules.yml). All the intent names must exactly match across these files.
Review the Indentation: YAML files are sensitive to indentation. Verify that your domain.yml file, as well as other YAML files, follow the correct structure and indentation. Improper indentation can lead to elements being incorrectly interpreted or ignored.
Re-train Your Model: Once your domain file includes the ask_health_question intent and you've verified the consistency across files, re-train your Rasa model by running:
bash
rasa train
This will take into account the updated domain and other files to properly include the ask_health_question intent in your model's understanding.
Test Your Bot: After training, test your bot to make sure it correctly recognizes and responds to the ask_health_question intent. You can test it in the shell first by running:
bash
rasa shell
If there are custom actions related to the new intent, remember to also run your action server in a separate terminal:
bash
rasa run actions
Following these steps should resolve the warning and integrate the ask_health_question intent into your chatbot's functionality. Regularly updating the domain file whenever new intents or functionalities are added is a good practice for maintaining and developing your Rasa bot.
User
This is my domain.yml , please update it:
intents:
greet
set_reminder
affirm
inform
entities:
time
actions:
utter_greet
utter_ask_for_time
utter_affirm
action_set_reminder
responses:
utter_greet:
text: “Hello! How can I help you today?”
utter_ask_for_time:
text: “When would you like me to remind you?”
utter_affirm:
text: “Got it. Your reminder is all set!”
Assistant
Based on your provided domain.yml and the goal to include the ask_health_question intent (from your earlier message), here’s how you can update the domain.yml file:
yaml
intents:
- greet
- set_reminder
- affirm
- inform
- ask_health_question # Added intent
entities:
- time
actions:
- utter_greet
- utter_ask_for_time
- utter_affirm
- action_set_reminder
# Ensure any custom or required action related to ask_health_question is also listed
responses:
utter_greet:
- text: "Hello! How can I help you today?"
utter_ask_for_time:
- text: "When would you like me to remind you?"
utter_affirm:
- text: "Got it. Your reminder is all set!"
# You can add a response related to ask_health_question if needed
# For example:
utter_ask_health_question:
- text: "What health question do you have?"
Notice the changes:
The ask_health_question intent is added under intents.
A response utter_ask_health_question has been included under responses. Add or modify this response based on how you plan to use the ask_health_question intent.
If ask_health_question requires a custom action or a specific response, make sure to define that action under actions and provide the corresponding response under responses.
Remember, for the new intent to work as expected:
Ensure there are training examples for ask_health_question in your nlu.yml file.
If this intent involves any dialogue management, update your stories.yml or rules.yml with relevant paths including this intent.
After making these updates, re-train your Rasa model by running rasa train.
This should effectively integrate the ask_health_question intent into your chatbot, resolving any domain-related warnings and enabling your bot to recognize and respond to health-related queries.
User
I ran rasa train, rasa shell, rasa run actions. How do i test the added functionality?
Assistant
Testing the added functionality of your Rasa chatbot after running rasa train, rasa shell, and rasa run actions involves engaging with the bot in a conversation to verify that it properly understands and responds to the inputs related to the newly added functionality. Here’s how to proceed:
1. Interact Through the Rasa Shell
After training, use the rasa shell command to start a conversation with your bot in the command line. Type inputs that are related to your newly added intent (in this case, ask_health_question) and observe the responses. For example:
plaintext
Your input -> What health question do you have?
If you've set up a response or a specific action for this intent, the bot should respond accordingly.
2. Testing with Specific Examples
Specifically test examples that you've added to the nlu.yml for the ask_health_question intent. Try various paraphrases or ways a user might express the intent to see if the bot can still understand and respond appropriately.
3. Use rasa shell --debug for More Insight
If the bot isn't responding as expected, use the debug mode by running rasa shell --debug. This provides more detailed logs about how Rasa is interpreting the conversation, including which intent is being recognized and which action is being predicted. This can help in identifying if the bot misinterprets the intent or if there's an issue with the dialogue management.
bash
rasa shell --debug
4. Testing Custom Actions
If your newly added functionality includes custom actions, make sure the action server is running by using:
bash
rasa run actions
Then, while interacting with your bot, specifically trigger conversations that would invoke these custom actions to ensure they are executed and respond as expected.
5. Review and Refine Based on Logs
Pay close attention to the logs in both the shell and the action server. If there are errors or the actions do not execute as anticipated, the logs can offer insights into what went wrong, such as connection issues, coding errors in your actions.py, or misconfiguration in the domain.yml.
6. Automated Testing
User
UserWarning: Parsed an intent 'emergency_help' which is not defined in the domain. Please make sure all intents are listed in the domain.
More info at https://rasa.com/docs/rasa/domain
Assistant
The warning you're seeing occurs when Rasa encounters an intent in your NLU data or stories that hasn't been declared in the domain.yml file. To resolve this issue, you need to ensure that the intent emergency_help is properly defined in your domain.yml. Here’s a step-by-step guide on how to do this:
1. Locate Your domain.yml
Find your domain.yml file in your Rasa project's directory. This file contains configurations for intents, entities, actions, and responses used by your chatbot.
2. Add the Missing Intent
Open the domain.yml file in a text editor and add emergency_help under the intents section. If the intents section doesn’t exist, you’ll need to create it. Here's an example of how you might structure it with the newly included intent:
yaml
intents:
- greet
- goodbye
- emergency_help # Add this line
3. (Optional) Add Associated Actions or Responses
If your new intent requires specific actions or responses, you should add those to the domain.yml file as well. For example, if you have a response that should be triggered when the emergency_help intent is detected, you might add something like:
yaml
responses:
utter_emergency_help:
- text: "I'm sending help right away!"
And ensure you also declare utter_emergency_help under actions if you're going to use it in stories or rules:
yaml
actions:
- utter_emergency_help
4. Save the Changes
After making the necessary additions, save your domain.yml file.
5. Re-train Your Rasa Model
With the domain file updated, you'll need to re-train your Rasa model to incorporate these changes. You can re-train your model by using the following command in your terminal:
bash
rasa train
6. Testing
Once training is complete, test your bot to ensure it now correctly recognizes and responds to the emergency_help intent. You can test it using:
bash
rasa shell
If you've defined custom actions for this intent, don't forget to start your action server with:
bash
rasa run actions
By following these steps, you should be able to resolve the warning about the emergency_help intent not being defined in the domain and properly integrate this intent into your chatbot's functionality.
User
Please update:
intents:
greet
set_reminder
affirm
inform
ask_health_question # Added intent
entities:
time
actions:
utter_greet
utter_ask_for_time
utter_affirm
action_set_reminder
Ensure any custom or required action related to ask_health_question is also listed
responses:
utter_greet:
- text: “Hello! How can I help you today?”
utter_ask_for_time:
- text: “When would you like me to remind you?”
utter_affirm:
- text: “Got it. Your reminder is all set!”
You can add a response related to ask_health_question if needed
For example:
utter_ask_health_question:
- text: “What health question do you have?”
Assistant
To include the emergency_help intent along with related actions and responses, as well as correct the quotes around the text in the responses (since they appear to be curly quotes which can cause issues), here’s an updated version of your domain.yml:
yaml
intents:
- greet
- set_reminder
- affirm
- inform
- ask_health_question
- emergency_help # Newly added intent
entities:
- time
actions:
- utter_greet
- utter_ask_for_time
- utter_affirm
- action_set_reminder
- utter_emergency_help # Assuming you have or will have a response for emergency help
responses:
utter_greet:
- text: "Hello! How can I help you today?"
utter_ask_for_time:
- text: "When would you like me to remind you?"
utter_affirm:
- text: "Got it. Your reminder is all set!"
utter_ask_health_question:
- text: "What health question do you have?"
utter_emergency_help: # Response for the emergency_help intent
- text: "If this is an emergency, please call emergency services!"
Notes for Further Actions:
If you require specific behavior when the emergency_help intent is detected, such as sending alerts or performing actions beyond sending a message, you might need to create a custom action in actions.py.
Ensure any custom action related to emergency_help is listed under actions.
After modifying the domain.yml, re-train your model with rasa train.
Verify the functionality by testing it with rasa shell and remember to start the action server with rasa run actions if you're using custom actions.
This update ensures that your Rasa project's domain configuration includes support for identifying and responding to emergency help requests, improving the interaction capabilities of your chatbot.
User
how do I test it now?
Assistant
After updating your domain.yml and including new intents, actions, or responses (such as emergency_help), follow these steps to test and ensure your Rasa chatbot is performing as expected:
1. Re-train Your Model
First, you need to re-train your Rasa model to incorporate the changes you've made to the domain.yml. Use the following command in your terminal:
bash
rasa train
This command tells Rasa to prepare a new model that understands and reacts to the updates, such as recognizing the new emergency_help intent.
2. Run Your Action Server (If Using Custom Actions)
If your new features involve custom actions (e.g., utter_emergency_help or any action that involves code execution in actions.py), you need to start the action server. Open a new terminal window and run:
bash
rasa run actions
This command starts the action server, allowing your bot to perform the custom actions you've defined.
3. Interact with Your Bot through Rasa Shell
With your model trained and your action server running (if applicable), it's time to converse with your bot to test the new functionality:
bash
rasa shell
Alternatively, use the --debug flag to get more detailed output about how Rasa interprets each message:
bash
rasa shell --debug
4. Testing Specific Intents
To test the newly added emergency_help intent, you can input messages that are similar to the examples you’ve provided in your NLU data for this intent. For instance:
code
I need emergency assistance.
The bot should recognize the intent and provide an appropriate response based on your configuration in the domain.yml and possible custom actions.
5. Assessing the Response
Observe how the chatbot responds. If there's a specific response associated with the emergency_help intent in your domain.yml, the bot should reply accordingly. If you've set up a custom action, ensure that it's executed and the expected outcome is achieved.
6. Iterate as Needed
User
I asked: I need emergency assistance, and bot`s answer was: great carry on
Assistant
If your bot responds unexpectedly to the input "I need emergency assistance" with "great carry on," it indicates there's a mismatch between what the bot is trained to recognize and its responses. To address this, let's go through a structured troubleshooting and refining process:
1. Check NLU Training Data
Ensure your nlu.yml file contains enough examples of the emergency_help intent, and the examples are representative of the phrases users might input. It should look something like this:
yaml
nlu:
- intent: emergency_help
examples: |
- I need emergency assistance
- It's an emergency
- Urgent help needed
- Please help me immediately
- I require urgent assistance
If the intent isn't properly represented or lacks examples, the model may not learn to recognize it accurately.
2. Review the Domain Configuration
Double-check the domain.yml file to ensure the emergency_help intent is listed and correctly linked to an appropriate response or action. For example:
yaml
intents:
- emergency_help
responses:
utter_emergency_help:
- text: "If this is an emergency, please call emergency services!"
3. Examine Stories or Rules
Look at your stories.yml or rules.yml to ensure you have a story or rule that uses the emergency_help intent and leads to the desired action:
yaml
# In stories.yml
stories:
- story: emergency assistance story
steps:
- intent: emergency_help
- action: utter_emergency_help
or
yaml
# In rules.yml
rules:
- rule: Emergency Help
steps:
- intent: emergency_help
- action: utter_emergency_help
Make sure the actions match what you've defined in your domain.yml.
4. Validate Custom Actions
If the response to emergency_help is handled by a custom action, confirm the action server is running and the action is correctly implemented in . For instance:
User
how do i test the functionality?
Assistant
To effectively test the functionality of your chatbot, especially after making changes or additions like the emergency_help intent, you can employ several strategies. These strategies range from manual testing using Rasa's interactive tools to automated tests that can help ensure your bot behaves as expected across various conversational scenarios. Here's how to proceed:
1. Manual Testing with Rasa Shell
Start by testing your bot in the Rasa shell. This is a good way to manually check how your bot understands and responds to inputs in real-time.
Start the Rasa Shell: Open a terminal and navigate to your Rasa project directory. Use the following command to interact with your bot via the command line:
bash
rasa shell
Use the Debug Mode: For more detailed output that shows how intents are being classified and actions are chosen, use the --debug flag:
bash
rasa shell --debug
Simulate User Input: Type phrases that you expect to trigger the emergency_help intent, such as "I need emergency assistance". Observe the bot's responses to ensure they align with your expectations.
2. Testing with Rasa Interactive
Rasa Interactive provides a more guided way to test your bot by allowing you to correct intents and actions in real-time, which can be especially helpful for refining your bot's training data.
Start Rasa Interactive: In your terminal, run:
bash
rasa interactive
Step Through Conversations: You'll be able to step through a conversation with your bot, correcting any wrong intent classifications or actions. This is especially useful for training your bot to handle specific scenarios correctly.
3. Automated Testing
Automated tests allow you to validate your bot’s behavior without manually interacting with it every time. Rasa allows you to write test stories in a similar format to your training stories but intended for testing purposes.
Write Test Stories: In your project's tests folder, write or update stories in test_stories.yml with scenarios that include your new emergency_help intent. Here's an example of what a test story might look like:
User
lets get back to initial idea
Assistant
Certainly! Let's refocus on your initial scenario involving the development of a Rasa chatbot. You've created the essential files such as nlu.yml, rules.yml, stories.yml, and actions.py, and you're interested in how to proceed further, particularly emphasizing the process of testing and ensuring newly added functionalities, like the emergency_help intent, are correctly recognized and actioned upon by the bot.
Below is a condensed guide to recap and guide you through the process from development to testing:
Step 1: Populate Your Files
Ensure each file is correctly populated with the necessary data:
nlu.yml: Includes examples for intents and entities.
stories.yml: Contains stories that guide the conversation flow.
rules.yml: Holds rules for how the bot should respond to specific intents.
actions.py: Defines custom actions that your bot can execute.
For example, to add and test the emergency_help functionality, you'd include:
nlu.yml
yaml
- intent: emergency_help
examples: |
- I need help
- It's an emergency
- Urgently need assistance
stories.yml
yaml
- story: emergency help story
steps:
- intent: emergency_help
- action: action_emergency_help
rules.yml
You may also define rules for more predictable interactions.
actions.py
Define action_emergency_help if it involves executing something more complex than a basic response.
Step 2: Train Your Bot
With the data in place, train your model:
bash
rasa train
Step 3: Testing Manually
Start the Rasa shell to interact with it directly. Use rasa shell for a basic test or rasa shell --debug for more detailed output.
Invoke the intent you're interested in testing, like emergency_help, by typing messages that should trigger it and observing the bot's responses and actions.
User
how do i test the emergency help
Assistant
Testing the emergency_help functionality in your Rasa chatbot involves several steps, including manual and automated testing methods. Below is a methodical approach to ensure your chatbot responds correctly to the emergency_help intent.
1. Manual Testing with Rasa Shell
First, you'll want to manually test your bot's response to ensure it understands and acts on the emergency_help intent correctly.
Start the Rasa Shell: Run rasa shell from your command line to interact with your chatbot in a terminal-based interface.
bash
rasa shell
Try Different Utterances: Input different phrases that should trigger the emergency_help intent, such as “I need emergency help” or “This is an emergency.”
Observe the Behavior: Pay attention to how your bot responds. It should recognize the intent and execute any associated actions or responses you've defined for emergency_help.
Debug Mode: If the response isn’t what you expect, run rasa shell --debug to see more detailed information about how your input is being interpreted. This can help you understand if the correct intent is being identified and if the subsequent actions are being triggered as expected.
bash
rasa shell --debug
2. Testing with Rasa Interactive
For a deeper understanding and to make real-time corrections, use Rasa's interactive training mode.
Start Interactive Mode: Using the command rasa interactive, you can step through a conversation interactively in the terminal, correcting the bot’s understanding and actions as you go.
bash
rasa interactive
Guide the Conversation: Input phrases related to emergency_help and follow the prompts to correct any misinterpretations or actions.
3. Automated Testing
Automated tests allow you to ensure your bot behaves as expected without manual input each time.
Write Test Stories: In your Rasa project, under the tests directory, add or update a test_stories.yml file including tests for the scenario. Here’s an example story:
User
I wrote: emergency help, and the bot said: great, carry on
Assistant
If your bot is responding incorrectly to the "emergency help" input with an unrelated response like "great, carry on," it likely indicates a misclassification of the intent or an error in your conversation management logic. Here’s how you can systematically address and fix the issue:
Step 1: Verify the Intent in NLU Training Data
Check your nlu.yml file to ensure that the emergency_help intent is well-defined with sufficient and varied examples. If the examples are too few or not diverse enough, the model might not recognize similar phrases correctly.
yaml
nlu:
- intent: emergency_help
examples: |
- emergency help
- I need emergency assistance
- This is an emergency
- Help in an emergency
- urgent help
Step 2: Confirm Intent and Actions in Domain
Ensure that the emergency_help intent is listed in your domain.yml file, and that you have an appropriate response or action linked to this intent.
yaml
intents:
- emergency_help
responses:
utter_emergency_help:
- text: "If this is an emergency, please contact local emergency services immediately."
actions:
- utter_emergency_help
Step 3: Check Stories or Rules
Review your stories.yml or rules.yml to confirm that you have a story or rule that captures the conversation flow for the emergency_help intent correctly.
yaml
# In stories.yml
stories:
- story: Emergency help story
steps:
- intent: emergency_help
- action: utter_emergency_help
Or, if you’re using rules:
yaml
# In rules.yml
rules:
- rule: Provide emergency help
steps:
- intent: emergency_help
- action: utter_emergency_help
Step 4: Re-train Your Model
After making any necessary changes, re-train your Rasa model to ensure it reflects the latest data and conversation logic.
bash
rasa train
User
I did everything, typed : urgent help, but bot said: great, carry on
Assistant
If you've followed all the suggested steps for training your Rasa chatbot to recognize and correctly respond to "urgent help" or similar phrases, but it still responds incorrectly, here are additional troubleshooting and debugging tips you can explore:
1. Double-Check the Intent and Examples in NLU Data
Make sure that the intent emergency_help (or a similar intent for dealing with urgent help requests) is correctly listed in your NLU training data with varied examples, including the phrase "urgent help".
yaml
nlu:
- intent: emergency_help
examples: |
- text: "urgent help"
- text: "I need emergency help"
- text: "It's an emergency"
- text: "Please help me immediately"
…
2. Review and Expand Intent Examples
Add more diverse examples to the emergency_help intent to cover different phrasings. The AI model learns from examples, so the more varied your examples are, the better the model can generalize.
3. Inspect Domain, Stories, and Rules Configuration
Make sure the domain.yml includes the intent and an appropriate response.
Review your stories.yml and rules.yml for logic that handles the emergency_help intent. Ensure that there's a clear pathway that leads to the desired response or action.
4. Ensure Proper Training and Testing
Retrain your model using rasa train and test it using rasa shell --debug to observe how the intent is classified and which policy is triggered.
5. Use Rasa Interactive
Using rasa interactive, you can manually correct the bot’s predictions and actions. This tool will also help you refine your training data by allowing you to directly influence the model’s learning process.
6. Examine the NLU Model Confidence
When you test the bot (especially in debug mode), pay attention to the confidence levels of the intent classification. If "urgent help" is being recognized as an incorrect intent with higher confidence, it might indicate the need for more distinct examples or that this utterance is too similar to examples of another intent.
7. Testing Specificity in Training Data
If your training data for different intents is very similar or not specific enough, the model may get confused. Ensure that the training data for each intent is distinct and clear to minimize overlap.
User
Today we are going to build an Agent named Robotron. This agent will be avatar of me and my personality. Ask me a series of 20 questions so you better understand my influences, work history, motivations, and skills. Ask a question of me, wait for my response, and then ask the next question until you have asked 20 questions. After identifying these key characteristics, ask me a series of 10 questions to further refine this agent and ensure it embodies my personality and traits.
Assistant
That sounds like an exciting project! Let's start building Robotron, the avatar that will embody your personality, influences, and skills. I'll begin with the first question:
What inspired you to embark on your current career or work path?
Not yet included in a published release.
For a more thorough testing process, consider writing end-to-end tests in your tests directory using story format. This way, you can use rasa test to run through these test conversations automatically and validate the behavior of your bot.
7. Interactive Learning with Rasa X
Consider using Rasa X for an interactive way to talk to your bot, see how it's interpreting your messages, and easily correct any misinterpretations. It's a powerful tool for refining your bot based on real interactions.
8. Collecting Feedback from Users
If possible, allow real users to interact with your bot and collect their feedback. This can be invaluable in identifying issues that may not have been apparent during development and testing.
Following these steps should help you thoroughly test the added functionality of your Rasa chatbot and ensure it's performing as expected.
If the bot doesn’t respond as expected:
Review the domain.yml to ensure the intent, actions, and responses are correctly defined.
Check nlu.yml to ensure you have adequate example phrases for the new intent.
Examine stories.yml or rules.yml to confirm you have included stories or rules that involve the new intent.
If using custom actions, review actions.py for any errors in the code related to your new action.
Repeat the training and testing process after making adjustments.
7. Automated Testing
For more thorough testing, consider writing end-to-end tests in your tests directory and use rasa test to run them. This way, you can automate the testing of your bot’s understanding and responses.
These steps should help you effectively test your Rasa bot’s new functionalities and ensure your updates are working as intended.
actions.py
python
class ActionEmergencyHelp(Action):
def name(self) -> Text:
return "action_emergency_help"
async def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text="If this is an emergency, please call emergency services!")
return []
Ensure this action is listed in your domain.yml under actions.
5. Re-train Your Model
After making changes to your NLU data, domain, stories/rules, or actions, re-train your model:
bash
rasa train
6. Test Again Using Rasa Shell
Launch the Rasa shell with the --debug flag to get detailed output about the model's decisions:
bash
rasa shell --debug
Then test again by inputting "I need emergency assistance." The debug output will show you which intent is being recognized and which action is being taken.
7. Iterate as Needed
Based on the outcome, you may need to iterate on your training data, stories, and domain configuration. The --debug information provides valuable insights into why the bot might be responding incorrectly, often pointing towards misclassification of intents or selection of unintended responses.
By following these steps, you should be able to correct the issue and ensure your bot responds appropriately to requests for emergency assistance.
yaml
- story: test emergency help response
steps:
- intent: emergency_help
- action: utter_emergency_help
Run Your Tests: Use the rasa test command to run your test stories against the trained model:
bash
rasa test
This will generate a report that shows how well your bot is performing across the test scenarios you've defined.
4. Using Rasa X for Testing
Rasa X is a tool that helps you review conversations, annotate them, and improve your bot based on real interactions. It's a helpful way to gather feedback from real users or team members testing your bot.
Invite Test Users: Share your bot with test users and collect interaction data.
Review and Annotate Conversations: Use the Rasa X interface to review conversations, correct misclassifications, and add valuable training data to your bot.
Between these methods, you should be able to thoroughly test the functionality of your emergency_help intent, ensuring that your bot reacts appropriately to user inputs and that any necessary improvements are identified and implemented.
Step 4: Automated Testing
Write test stories in your tests directory to automatically validate whether the bot behaves as expected in predetermined scenarios.
yaml
- story: test emergency help
steps:
- intent: emergency_help
- action: action_emergency_help
Run your tests with:
bash
rasa test
Step 5: Iterative Improvement
Based on your testing outcomes, you may need to refine your intents, stories, rules, and custom actions. The cycle of development, training, testing, and refining is iterative and crucial for enhancing the bot's capabilities and user experience.
Step 6: Using Rasa X
For a more in-depth analysis and to improve your bot based on real conversations, consider using Rasa X. It's a tool designed to help you review and annotate conversations, understand how real users interact with your bot, and refine its training data based on those interactions.
By following these steps, you can systematically develop, test, and refine your chatbot, ensuring that new functionalities like emergency_help are integrated and function as intended. This approach helps in creating a more responsive, accurate, and helpful chatbot for your users.
emergency_help
yaml
- story: test emergency help response
steps:
- intent: emergency_help
- action: utter_emergency_help
Run the Tests: Use rasa test to run through your test stories and assess the bot’s performance.
bash
rasa test
Review the Results: Check the output and report generated by the test command to see if there are any failures or if the emergency_help tests pass as expected.
4. Using Rasa X for Deeper Analysis
Rasa X is a tool designed for testing, sharing, and improving your chatbots. It allows you to review real conversations, correct misunderstandings, and annotate data more efficiently.
Deploy Rasa X: Follow Rasa’s documentation to get Rasa X installed and set up.
Review Conversations: Use Rasa X to review conversations that involve the emergency_help intent. You can correct any wrong intent predictions or actions, providing your model with more accurate training data directly from real user conversations.
Through a combination of these testing methods, you can accurately assess and improve how your Rasa chatbot understands and responds to requests for emergency help. This iterative process of testing and refinement is crucial for developing a reliable and helpful chatbot.
Step 5: Test Again in Debug Mode
Run rasa shell --debug to interact with your bot and get detailed debug information about how it's interpreting and responding to input. Test with "emergency help" again and observe:
bash
rasa shell --debug
The --debug flag will provide insights into how Rasa NLU classified the intent and which action Rasa Core decided to take. If the intent is still being misclassified, or if the wrong action is being taken, the debug output should give you clues as to why.
Step 6: Iterative Improvement
Based on the debug information, you may need to:
Add more NLU examples for the emergency_help intent if it’s consistently being misclassified.
Refine your stories or rules to better guide the conversation when this intent is detected.
Custom Actions: If a custom action is intended but not triggered, ensure your actions.py is correctly set up and that the action server is running.
Remember, building a chatbot is an iterative process involving continuous testing and refinement. Misclassifications and unexpected responses offer valuable learning opportunities for improving your bot's understanding and interactions.
8. Policy Configuration
Review your config.yml to ensure you're using an appropriate policy configuration. Sometimes, adjusting the policies (for instance, increasing the priority of certain policies, or switching to a policy that better fits your use case) can resolve issues with intent recognition and action selection.
9. Custom Action Conditional Checks
If the response involves a custom action, ensure that the conditions within the custom action (actions.py) correctly handle the emergency_help intent without mistakenly continuing or ignoring the intent.
10. Check for Typographical Errors
Make sure there are no typographical errors in your intent names, actions, or utterance examples across your training data and action scripts. Such errors can lead to unexpected behavior.
If, after exploring these steps, you continue to experience issues, it may be helpful to share specific configurations (like parts of your nlu.yml, stories.yml, rules.yml, and config.yml) for more targeted advice. Additionally, consulting the Rasa community and documentation can offer further insights and solutions.