How to do conditional FAQ

I’m trying to do some FAQ with conditions. For example, if ask ‘How to deal with A’, the system would reply with buttons of ‘condition 1’ and ‘condition 2’, once user picks one condition, then the system will reply the solution of condition n of A. Pre-defined data as below:

data = {
  'question_1' : {
    "condition_1": solution11_url,
    "condition_2": solution12_url
  },
  'question_2' : {
    "condition_1": solution21_url,
    "condition_2": solution22_url
  }

}

I’m wondering what’s the best way to do it in Rasa.

So far, I wrote a action to handle this as below:

class ActionConditionFaq(Action):
	def name(self) -> Text:
		return "action_condition_faq"
	def run(self, dispatcher, tracker, domain) -> List[EventType]:
		q = tracker.get_slot("question")
		btns = data[q]
		buttons = []
		for b in btns:
			buttons.append(make_button(b, '/choose_condition{{"condition":"{0}"}}'.format(b)))
		dispatcher.utter_message("please choose one related condition", buttons)
		cd = tracker.get_slot("condition")
		if q and cd:
			dispatcher.utter_message('guide as below {0}:'.format(data[q][cd]))
		return []

My question is that how to make sure, after generating the btns, the system will get reply from user, then the system can show solution url based on question and user chosen condition.

Thanks!

What’s the use-case you’ve got in your mind? I can imagine that a lot of FAQ questions can be answered directly without the need for a submenu of buttons. Do all FAQ questions that you have require buttons?

@koaning Thanks for your attention. I’m building some rasa app for real world practice. One question has to face is that there is no guarrentee that the language material is enough to train FAQ question, so there’re always inappropriate answers from FAQ. The best way to deal with problem (I can think of) might be that after the user question, the system list the top questions based on confidence then let the user to choose one or none of them, then show the answer. I’ve seen some websites are using the stratege.

With rasa, I’m not sure how to get the top confidence list of FAQ answer candidates, and then list them out to let user choose.

Some people suggested to use elasticsearch to deal with FAQ, but I prefer rasa to handle this issue if possible.

Thanks again!

If you have many questions to query then elasticsearch might make more sense.

It’s a seperation of concerns I suppose. Rasa is great for handeling the conversational parts of the problem here but it is not built to be a retreival engine. But nothing is stopping you from combining both tools. In your case it’s perhaps better to create a custom action in Rasa that can proxy the query to elasticsearch. This way, elasticsearch does what it is good it (retreival) and Rasa can still be used to handle the conversational parts.

@koaning Thanks for your suggestion. If there is an example of showing how to proxy queries to elasticsearch, that whould be great. I’ve learned a lot from rasa examples, such as how to combine rasa with knowledge graph database grakn.

i’ve done the job by using bert-as-service. Oh yeah!