How to ask an entity from the user in between custom action

Hi I’m working on a project and I need bot to ask the user for entity i.e. Incident number in between a custom action.

Then user will provide the incident number, and for that incident number bot will get output from SQL and give it as a bot response. I just need help with the bot asking the incident number in between custom action. Please help !!

Here is my action file class ActionMedicalNecessity(Action):

def name(self) -> Text:
    return "action_necessity"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    incident_no = tracker.get_slot("incident_no")
    # reason is fetched from sql and is stored in 'reason' variable 
    reason = 'xyz'
    bot_response = " For {} incident number the medical necessity reason is {}".format(incident_no, reason)

    dispatcher.utter_message(text=bot_response)

    return [SlotSet('incident_no', incident_no)]

and here is my story

## medical necessity path
* medical_necessity
  - action_necessity
  - slot{"incident_no":101}
  - slot{"incident_no":102}
  - slot{"incident_no":103}
  - slot{"incident_no":104}

Hey @Aman10

to ask the user for entity i.e. Incident number in between a custom action.

I don’t think it’s gonna work. I’m afraid you’d have to write the stories another way around, so that you trigger actions once they have the information from the user they need to run.

So I’d split your action into two.

Well I found out the solution, instead of normal action I’ve to use Form action and ask for and missing activity. Most of the cased that I’ve posted here were solved by me and didn’t got any help from anyone.

Well anyway thanks, Form Action is the solution to this case.

1 Like

oh sure, then I misunderstood you, sorry :slight_smile:

Cool that you’ve figured that out!