Getting data from user without processing

I’m working on a chatbot, which functions like this:

  1. asks name
  2. asks phone number
  3. asks problem

Now the thing is I can train my chatbot for asking name and phone number. But what about asking problem, problem is something like anything. I’m taking the input from the user, and how will I do this, that when user will enter his problem, and it directly goes to a class named ActionGetProb(Action).

Hi @Mayankgbrc, just to make sure I understood you question correctly:

You want your chatbot to ask the user for their name, their phone number, and then ask them what their problem is, to which the user will enter an arbitrary string. You then want to run a custom with the string the user has entered. Is this correct?

Yes, Suppose bot asked name, user entered his name bot processed it and find it as intent ‘name’ and this is saved in ‘name’ slot, and same for phone number, and then bot asked “what is Your problem”, now suppose user entered “Mayank”, now my bot will take this “Mayank” as a name, but I have to store this in problem slot. Now what I have to do ?

You could try setting up your file so that the user is first asked their name, then their phone, and then use a custom FormAction (link) to ask what the problem is. The form will only need to fill in one slot, problem:

class ActionAskProblem(FormAction):
    def name(self) -> Text:
        return "problem_form"

    def required_slots(tracker: Tracker) -> List[Text]:
        """A list of required slots that the form has to fill"""

        return ["problem"]

    def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
        """A dictionary to map required slots to
            - an extracted entity
            - intent: value pairs
            - a whole message
            or a list of them, where a first match will be picked"""

        return {
            # Use the entered text as value for the problem slot
            "problem": [self.from_text()]

    def submit(
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        """Define what the form has to do
            after all required slots are filled"""
        return []
1 Like