FAQ Bot / Knowledge Base


I am currently working on a chatbot that is beginning as an FAQ bot. I was wondering if there is any inbuilt implementation of FAQ chatbots at the moment in Rasa?

I have a large CSV file acting as a knowledge base for these FAQs. This CSV consists of a column for the intent that the question maps to, and a column for the answer to that question.

For my FAQs, many of the requests are simple question-answer conversations. For this reason, in my version of Rasa Core I have written a bypass which, when an intent is passed into Rasa Core, skips the prediction of the next action if the intent is found in the FAQ CSV. Instead, a custom action is called which retrieves the answer corresponding to the intent in the CSV.

For example:

User: Hello

  • Intent: greet
  • Bot checks CSV for greet intent; intent not found
  • Bot continues as normal with predicting next action

Bot: Hello, how can I help? User: How do I send an email?

  • Intent: inform_send_email
  • Bot checks CSV for inform_send_email intent; intent found in CSV
  • Bot executes custom action which sends answer from CSV

Bot: To send an email, press the Envelope icon in the top left corner.

As this is an example of a simple question-answer interaction, I did not need to write a story for this intent, as the intent has an automatic response from the CSV. Should any of these FAQs have follow-up questions, it is easy to create a story for the intent. This has taken out the work of having to write a story for each intent, and also only requires one custom action for several intents.

As I can’t find any existing implementations of knowledge bases with Rasa, I was hoping to share this and to hear if anyone else has approached building an FAQ bot differently? If not, is there potential for Rasa to benefit from this kind of optional knowledge base?

Thanks in advance!

1 Like

I would say two things , you have two types of FAQs -

A general one which doesn’t typically answer a specific user query rather quite generic answer like

Q: My card is lost. what should I do?
A: Contact Helpdesk at 00000 

A rather personalised FAQ would handle the same query differently

Q: My card is lost. What should I do?
A: Can you provide your card number?
A: I have reported it stolen and will send you a replacement in 2 days

So rasa core imo is really useful if you are handling something like the second case, where context is important.

In your case, I would rather focus on Rasa NLU, try to classify the intent of the user and then write an application or use Botkit to execute something like If Intent == X Search CSV Reply to Channel Else I don’t understand

You can use a number of solutions out there to execute this - Botkit and Chatfuel from the top of my head.

Rasa Core helps you with contextual chatbots

Thanks for your response.

I see what you mean with contextual conversations. My end goal would be to create a chatbot that both pulls information from a knowledge base for some intents, and uses Rasa Core for contextual conversations for other intents.

Would you suggest instead building my own layer before Rasa Core that deals with CSV intents, and then redirects to Rasa Core to handle requests outside of the CSV’s scope?

1 Like

I think you should use Rasa Core in both cases if you have them.

But rather execute actions at your end instead. use rasa core as a server with action_factory:remote

for some generic intents use actions like lookupCSV, extract the intent name from the tracker which you receive back from the API and look up your csv for answer so your story will look like

* generic_intent
- lookup_csv

for contextual intents, you have your specific stories

* specific_intent
- do_action
* specific_intent
- slot
- do_action_1

We execute both outside of rasa in an intermediate layer. We also do lookups for generic answer and build contextual conversations using some specific intents that can execute a transaction for example.

But yes we have an intermediate layer( Botkit)

Sorry I’m not sure what you mean by generic_intent - do you mean every intent that doesn’t require a specific story?

My first attempt of this bot was to write a similar story to your first one for every intent, but having a story for every FAQ intent made the training extremely slow, so this is what I was trying to avoid. Or are you saying that I could somehow group all of my FAQ intents into one ‘generic_intent’?

no no, you should provide all the intents that don’t need a specific story and write up stories for each. since they will use the Memoization Policy , it will match up exactly. So for every intent for your FAQ, you should have one generic action basically look it up and for every specific intent, you should have a story that relates which will take Keras Policy to predict the next action.

So for the moment, if you don’t have any specific story and every FAQ intent basically goes to the same action, just use the Memoization Policy instead, it will speed up your training.

For contextual conversation you should use both Memoization and Keras policies as you are not sure how a conversation might go with context.

Ok I see, I’ll have a go with the Memoization Policy for now. Thanks for all your help :slight_smile:

Also note you have to realise that your sole purpose of using rasa core is based on the assumption that in the future you will have contextual conversations as well. So when you add both types FAQ and conversational intents in your stories, It will slow down your training process but that really depends on what machine are you training, how many intents do you have ,and when you mix FAQs with specific intents , there will be crossover so you will need to clean

We have close to 90 intents including dialogflow chitchat and it takes a maximum of 10-15 mins. I can live with that. I have a MacBook Pro with 16gb though my docker is using only 6gb of it, so with 6gb memory this is my performance

Hey, I think you said somewhere else that you use spacy for intents? Have you tried tensorflow embedding for those 90 intents?

How many examples do you have per intent? I wonder how diverse you intents are. Is the difference in one intent just like one keyword? For good classification you should have diverse sentence structure per intent, right? I experiuenced that the balance of types of sentences per intent play also some role for tensorflow embedding…

If i need to do a check, i suppose there are over 10-20 examples for each intents, this comes from actual customer complaints.

Unfortunately i no longer make the decision on the pipeline since we are scaling the product internally and we have now Data scientists who decides on what is the optimal pipeline. So i am not sure whether they will go for tensorflow or not.

So at the moment, we are using spaCy for intent classification and based on the evaluation so far, we are in the process of cleaning our training data A LOT.

Hi Nicole, I’m facing a similar challenge and wonder how you’ve progressed this? I have several hundred FAQs with simple intent/utterance stories and also some more complex contextual conversations. In this setup the training takes a looooong time and also I’ve seen quite a bit of randomness in predicting the next action. I’m looking into consolidating my FAQs into a single story - maybe the story has intent OR intent OR intent and then maps to an action where I pull out the intent manually.

How did you do the ‘bypass’ you referred to above? Is that the way you went in the end?

Hi Duncan,

I did end up going with a ‘bypass’ of sorts. It means that I now don’t have to write a story for any single question/single answer exchanges, so has massively sped up my training time.

I am using the scalableminds web chat component. This involves creating an Input Channel on the bot’s server side that collects messages. Usually, the message/payload goes straight to the Rasa Core message handler, but now I have a layer before this called faq_handler. This takes in a message, uses the trained agent’s interpreter to get the intent from the message, and checks if that intent is in my FAQ CSV file. If it does not, the FAQ handler returns False and the message is passed to Rasa Core. If it does, the FAQ response is sent, and I used some code from Rasa Core to log that action being executed. This is to handle any Rasa Core stories I have that contain follow-ups from this FAQ.

In this way, the FAQ handler relies on extra Rasa NLU training rather than Rasa Core, and doesn’t slow Rasa Core training.

Thanks Nicole, that’s a very sensible approach - I think I’ll end up with something similar. It doesn’t seem worth bogging rasa-core down with simple faq question/answer pairs that can easily be done in a simpler way.

Hi Nicole , Can you explain a little bit more. I am also building same kind of bot and stuck with the same issue.

There is a simple way to build an FAQ with the Rasa Addons package with just one story and one action, avoiding to retrain when questions are added or changed

You create an intent substitution rule like this:

  - intent: (faq.*)
    with: faq
      - name: intent
        value: '{intent}'

This rule will match all intents starting with faq (e.g.: faq.how_do_i_create_a_faq) This will change the dialog act to {intent: "faq", entities: [{intent: "faq.how_do_i_create_a_faq"}]}

In Core you create ONE story:

## FAQ
* faq
  - action_faq

And one action

class ActionFAQ(Action):

    def name(self):
        return "action_faq"

    def run(self, dispatcher, tracker, domain):
         # get the original intent from tracker.latest_message and retrieve the correct answer

The benefit of this approach is you have only ONE story for all your questions, so if your Q&A are stored externally you don’t have to retrain your bot when adding/changing questions. Since you have only one story for potentially 100’s of questions, this means you can better handle side questions in more complex dialogs.


Hi znat,

Thank you for your advice to use rasa_addons library! For some reasons it doesn’t work for me. May I kindly ask you to share with me small pieces of your codes (like rules file, domain, dialogs and python script), how you did it?

Thanks in advance!

May be you could describe how you use it and exactly what’s not working. Feel free to post an issue on the repo to avoid cluttering the discussion here with technical details

Hello, we build a faq bot based rasa, it can work well in some simple environments.

1 Like

Interesting repo. bot crashes when bert large is used on like a I9 Mac. On what config was this tested?

Hello Nicole,

That is an interesting approach, thank you for sharing ! I am trying to create a similar Chatbot that handles both FAQ questions and contextual ones but don’t know exactly how to proceed. Can you please give more details about your files & code ?

Thanks a lot.