# Tutorial: Building Assistants

After following the basics of setting up an assistant in the [Rasa Tutorial](/content/docs/rasa/user-guide/rasa-tutorial/index.html), we’ll now walk through building a basic FAQ chatbot and then build a bot that can handle contextual conversations.

## Building a simple FAQ assistant

FAQ assistants are the simplest assistants to build and a good place to get started. These assistants allow the user to ask a simple question and get a response. We’re going to build a basic FAQ assistant using features of Rasa designed specifically for this type of assistant.

In this section we’re going to cover the following topics:

- [Responding to simple intents](https://legacy-docs-v1.rasa.com/1.10.24/user-guide/building-assistants/respond-with-memoization-policy) with the MemoizationPolicy
- [Handling FAQs](https://legacy-docs-v1.rasa.com/1.10.24/user-guide/building-assistants/faqs-response-selector) using the ResponseSelector

To prepare for this tutorial, we’re going to create a new directory and start a new Rasa project.

mkdir rasa-assistant
    rasa init

Let’s remove the default content from this bot, so that the `nlu.md`, `stories.md` and `domain.yml` files are empty.

### Memoization Policy

The MemoizationPolicy remembers examples from training stories for up to a `max_history` of turns. For the purpose of a simple, context-less FAQ bot, we only need to pay attention to the last message the user sent, and therefore we’ll set that to `1`.

You can do this by editing your `config.yml` file as follows:

policies:
      - name: MemoizationPolicy
        max_history: 1
      - name: MappingPolicy

### Defining Stories

Now that we’ve defined our policies, we can add some stories for the `goodbye`, `thank` and `greet` intents to the `stories.md` file:

## greet
    * greet
      - utter_greet

## thank
    * thank
      - utter_noworries

## goodbye
    * bye
      - utter_bye

We’ll also need to add the intents, actions and responses to our `domain.yml` file in the following sections:

intents:
      - greet
      - bye
      - thank

responses:
      utter_noworries:
        - text: No worries!
      utter_greet:
        - text: Hi
      utter_bye:
        - text: Bye!

Finally, we’ll copy over some NLU data from Sara into our `nlu.md` file:

## intent:greet
    - Hi
    - Hey
    - Hi bot
    - Hey bot
    - Hello
    - Good morning

## intent:bye
    - goodbye
    - goodnight

## intent:thank
    - Thanks
    - Thank you

You can now train a first model and test the bot by running the following commands:

rasa train
    rasa shell

This bot should now be able to reply to the intents we defined consistently, and in any order.

### Response Selectors

The [ResponseSelector](https://legacy-docs-v1.rasa.com/1.10.24/nlu/components/#response-selector) NLU component is designed to handle FAQ messages in a simple manner. By using the ResponseSelector, you only need one story to handle all FAQs, instead of adding new stories every time you want to increase your bot’s scope.

People often ask Sara different questions surrounding the Rasa products, so let’s start with three intents: `ask_channels`, `ask_languages`, and `ask_rasax`.

We’re going to copy over some NLU data from the [Sara training data](https://github.com/RasaHQ/rasa-demo/blob/master/data/nlu/nlu.md) into our `nlu.md`:

## intent: faq/ask_channels
    - What channels of communication does Rasa support?

## intent: faq/ask_languages
    - What language does Rasa support?

## intent: faq/ask_rasax
    - I want information about Rasa X

Next, we define the responses associated with these FAQs in a new file called `responses.md` in the `data/` directory:

## ask channels
    * faq/ask_channels
      - We have a comprehensive list of [supported connectors](/content/docs/core/connectors/index.html).

Now that we’ve defined the NLU side, we need to make Core aware of these changes. Open your `domain.yml` file and add the `faq` intent:

intents:
      - greet
      - bye
      - thank
      - faq

We also need to add a retrieval action:

actions:
      - respond_faq

Next, we’ll write a story so that Core knows which action to predict:

## Some question from FAQ
    * faq
        - respond_faq

Once everything is set up, train a new model and test the modified FAQs:

rasa train
    rasa shell

With these features, you can build a context-less assistant. When you’re ready to enhance your assistant with context, refer to the [Building a contextual assistant](https://legacy-docs-v1.rasa.com/1.10.24/user-guide/building-assistants/#tutorial-contextual-assistants) section.

### Handling unexpected user input

All expected user inputs should be managed by the form previously defined. Users can behave differently, and it's necessary to handle various forms of unexpected input. You can define generic interjections, like greetings or FAQs, using the Mapping Policy, which predicts the same action for an intent.

### Failing gracefully

Even if the bot is well-designed, users might say unexpected things. It’s crucial to handle these situations gracefully. Implementing a TwoStageFallbackPolicy is a common failure handling tactic, which manages low NLU confidence by prompting users to rephrase their messages.

### More complex contextual conversations

Not all user goals will fit under business logic. You can use stories and contexts to train your assistant to help users achieve their goals.

By utilizing these features and guidelines, you can build a robust assistant that responds effectively to both frequent and unexpected queries.
