Suggestions for a Q&A bot

Hello,

I am trying to implement a Q&A bot. But I am not able to figure out how my NLU data and stories should be generated in such a way that saves memory about is previous questions.

Consider the following example:

user: Hi

Bot: Hello

User: what is rasa?

Bot: Rasa is a cool AI chatbot development tool.

user: Ok. How does it work?

Here, what would be the best practice to make sure the bot understands that ‘it’ stands for ‘Rasa’(important when the bot has to handle multiple topics).

Do I use one entity called topics and values being different topics, I use a categorical slot to train stories? Or use different entities for each topic and train the stories, Or anything else.?

Any help appreciated. Thank you,

I don’t know if this is the best way, but here’s how we are doing it for a QA bot. Create a story with two intents and actions… For example, lets say you have these intents:

# intent:whats-rasa
 - what is rasa?
 - explain rasa

#intent:rasa-works
 - tell me more
 - how does it work?

And a couple of templates:

utter_what-is-rasa:
    - Rasa is a cool AI chatbot development tool.

utter_how-rasa-works:
    - Rasa has two main modules: NLU for understanding user messages 
      and Core for holding conversations and deciding what to do next.

You can create a story something like this:

## rasa-story
* whats-rasa
    - utter_what-is-rasa
* rasa-works
    - utter_how-rasa-works

The second intent will return a high accuracy while in the context of the rasa-story story.

Hello @samscudder

Thanks a lot for replying!!

I had approached my problem in a very similar way and it works very well when there is only one topic the bot has to answer. But in my case, I am trying to build a bot which can handle multiple topics. For example

User: hi

Bot: hello

User: what is rasa? 

Bot: Rasa is an open-source platform for developing chatbots

User: How does it work? 

Bot: Rasa has two main modules: NLU for understanding user messages and Core
 for holding conversations and deciding what to do next.

User: OK, what is rasa x? 

Bot: Rasa X is a tool to learn from real conversations.

User: How does it work? 

Bot: Similar to rasa, but it has some extra functionalities like Annotating Conversations. 

Here, we can see that the questions for asking about the working for both rasa and rasa X are the same but actions are varying. So what would be a good approach to distinguish the two questions?

One way to approach the problem is by using entities. But I am confused about what type of slots would fit this scenario.

For this, I am using a slot to check my current product categories. I defined an entity as product categories and use a slot to capture it.

in domain file:

entities:
     - phone_brands 

slots:
   phone_brands:
      type: text

then in my nlu training files; I write

## intent:search_brand
- Tell me about [Apple](phone_brands)
- How about [Samsung](phone_brands)
- any ideas about [Nokia](phone_brands)
- I am really interested in [apple's](phone_brands:Apple) product

## synonym:Apple
- apple
- Apple's
- Aple
- Apppple

the last line is a synonym mapping, I also added some misspelling inside to ensure extracted keyword is always ‘Apple’

Then I designed a custom Action to give a reply based on the obtained slots.

You will need to edit your stories flows to make your action logic is included in your main logic flow.

This is rather tedious, but I can give a dynamic reply to users.

You only need slots if you have to recover info at a later time after switching stories.

Rasa and Rasa-x are too similar for my setup to differentiate, but I don’t know if it’s because of language (I’m running in Portuguese) or training (I’m still a bit of a noob). If the NLU can differentiate between subjects, there’s no need for slots, so if you are looking for something like this:

Your input-> What's a plane?
A plane flies.
Your input-> How's it work?
Lift is generated by air moving faster across the top of the wing.
Your input-> What's a helicopter?
A helicopter is a rotary winged aircraft that can take-off and land vertically.
Your input-> How's it work?
It beats the air into submission.

You get a different response depending on which story is running. Try something like this with rasa shell --debug to see which stories are running. That example could be accomplished by something like this in your stories.md:

## plane-story
    * whats-plane
        - utter_what-is-plane
    * how-works
        - utter_how-plane-works

## helicopter-story
    * whats-heli
        - utter_what-is-heli
    * how-works
        - utter_how-heli-works

Note the same intent (how-works) in both stories, but with different actions.

You could also have different results depending on where it is in the story:

## helicopter-story
    * whats-heli
        - utter_what-is-heli
    * how-works
        - utter_how-heli-works
    * how-works
        - utter_explain-controls

Could give you something like this:

Your input-> What's a helicopter?
A helicopter is a rotary winged aircraft that can take-off and land vertically.
Your input-> How's it work?
It beats the air into submission.
Your input-> How's it work?
You have anti-toque pedals, a collective and cyclic controls.