Build your assistant
In this guide, we are creating an assistant that helps users subscribe to a newsletter. Go through each of the steps below to see how a simple assistant is created:
1. NLU data
What are the various things people might say to an assistant that can help them subscribe to a newsletter?
For an assistant to recognize what a user is saying no matter how the user phrases their message, we need to provide example messages the assistant can learn from. We group these examples according to the idea or the goal the message is expressing, which is also called the intent. In the code block below, we have added an intent called greet, which contains example messages like “Hi”, “Hey”, and “good morning”.
Intents and training examples make up the assistant’s NLU data, which is used to train the NLU model.
Now that the assistant understands a few messages users might say, it needs responses it can send back to the user.
“Hello, how can I help you?” and “what’s your email address?” are some of the responses our assistant will use. You’ll see how to connect user messages and responses in the next steps.
In the code block below, we have listed some responses and added one or more text options for each of them. If a response has multiple text options, one of them will be chosen at random whenever that response is predicted.
Stories are example conversations that train an assistant to respond correctly depending on what the user has said previously in the conversation. The story format shows the intent of the user message followed by the assistant’s action or response.
Your first story should show a conversation flow where the assistant helps the user accomplish their goal in a straightforward way. Later, you can add stories for situations where the user doesn't want to provide their information or switches to another topic.
In the code block below, we have added a simple story where the user and assistant exchange greetings, the user asks to subscribe to the newsletter, and then the user provides their email address in response to the newsletter_form.
There are many situations where an assistant needs to collect information from the user. For example, when a user wants to subscribe to a newsletter, the assistant must ask for their email address.
You can do this in Rasa using a form. In the code block below, we added the
newsletter_form and used it to collect an email address from the user.
Rules describe parts of conversations that should always follow the same path no matter what has been said previously in the conversation.
We want our assistant to always respond to a certain intent with a specific action, so we use a rule to map that action to the intent.
In the code block below, we have added a rule that triggers the
newsletter_form whenever the user expresses the intent “subscribe”.
We’ve also added a rule that triggers the
utter_subscribed action once all the
required information has been provided.
The second rule only applies when the
newsletter_form is active to begin with; once
it is no longer active (
active_loop: null), the form is complete.
Train and talk to your assistant
Once you have reviewed the steps above, you’re ready to train your assistant. The training process generates a new machine learning model based on the training data you’ve provided.
To train the assistant on the NLU data, stories, forms, rules and responses above, click the
Looking for a challenge? Customize your assistant
You can use this page to create an assistant that does something other than helping users subscribe to a newsletter.
Try choosing a simple task for your assistant to do, like ordering a pizza or booking an appointment. Adapt the code blocks at each step to fit the new scenario, then train your assistant again to see it in action.
You have built your assistant! What’s next?
You can download this project and continue building to create a more advanced assistant.
Your prototype was created using a Rasa Open Source 2.0 RC release. Please make sure you've installed at least Rasa Open Source 2.0.0rc1 to develop your project further.
When you train a model, you always want to check that your assistant still behaves as you expect. You can do that by talking to your assistant and seeing that it works. However, as your assistant becomes more complex, you will want to use test stories to ensure your model makes correct predictions.
rasa test to make sure that your assistant passes your tests: