Users asking follow up questions - recommended approach?

Looking for a recommended approach for follow up questions or more specifically refinement/modification of slots and re-execution of the past action.

Example:

  • (User) What were my blue widget sales last month?
  • (Chatbot) Blue widget sales were 9000. [<- This works great for me!!]
  • (User) OK, what about Red ones? [<- Not sure how to implement this?]

The first intent & response example is working perfectly for me. Both Blue and Widget are entity based slots submitted via form to a custom, in this case, ‘sales’ action.

I ‘sort of’ got the follow up question working by creating an intent to a separate custom action. The custom action triggers the previous action by looping through the tracker event and returning a FollowupAction. It triggers the original custom action twice for some reason (maybe since the ‘sales’ action expects to be part of a story). This makes me think there is potentially a better way.

I could have lots of intents/actions that the users might want to refine the results for so I am looking for a good pattern to follow. Is there a recommended approach for something like this? Based on my research it sounds like the Story can be written to support this but I have not found any real examples so far.

Any suggestions would be appreciated.

Handling follow-up questions and slot refinement in Rasa can be achieved effectively with a well-structured conversation flow using stories, actions, and slots. Here’s a recommended approach to handle such follow-up questions:

  1. Use Slots for Context: Ensure that the relevant information, such as the type of product (“Blue” or “Red” widget), is stored in slots. When the user asks a follow-up question, the slot values act as context.
  2. Use Stories: Create stories that capture the expected conversation flow. For your example:
  • story: User wants to know blue widget sales steps:

    • intent: inform entities:
      • product: “blue widget”
    • action: sales
  • story: User wants to know red widget sales steps:

    • intent: inform entities:
      • product: “red widget”
    • action: sales
  1. These stories set the context for the “sales” action.
  2. Custom Action for Slot Modification: You can create a custom action that captures the user’s request for refinement. For instance, if the user says, “What about Red ones?” The bot can extract the new product (“Red widget”) and modify the corresponding slot.
  3. Follow-up Intent: Create an intent for follow-up questions that are meant for slot modification. This intent should be mapped to your custom action.
  • intent: refine_sales examples:

    • What about Red ones? Refinement Action: Create a custom action to handle the user’s refinement request and update the corresponding slots. For instance: class RefineSalesAction(Action): def name(self): return “action_refine_sales”

    def run(self, dispatcher, tracker, domain): # Extract the refinement request, e.g., “Red ones” product = tracker.latest_message.get(‘text’) # Update the product slot return [SlotSet(“product”, product)] Handling the Refinement in Stories: Update your stories to include the steps for handling slot refinements. For example:

yamlCopy code

  • story: User refines the product steps:
    • intent: refine_sales
    • action: action_refine_sales
    • action: sales With this approach, you can maintain context through slots, and stories guide the conversation flow. When a user refines their query, the custom actions are responsible for slot updates, and the refined information is used in the “sales” action.

This structured approach allows for flexibility and scalability when handling vario us follow-up questions or slot refinements in your Rasa chatbot. Also read : Rasa Pro InstallationGolang Course

Thank you.

Thanks for the reply, that does help. I was looking at the options outlined so at least I wasn’t missing anything obvious.

I am have an issue with Stories since the number refinements is not limited. Works great as long a the user interaction matches a story ‘template.’

The separate Intent/Custom Action is what I was trying and it seems to work but fires the action twice for some reason. I will continue to troubleshoot it - hopefully just something in my configuration. I have to find the last event name since the Refine Intent could be triggered in multiple situations.

  • (User) What were my blue widget sales last month?
  • (Chatbot) Blue widget sales were 9000.
  • (User) OK, what about Red ones? [<- Refinement Intent]

OR

  • (User) What is my blue widget inventory?
  • (Chatbot) You have 200 Blue widgets.
  • (User) OK, what about Red ones? [<- Refinement Intent]

Thanks