CustomAction listen to user input and then redirect to other custom action

HI everybody :wink:! Thank you so much for creating this open assistant, it’s been quite a ride!

I’m currently using Rasa 1.10.10 and this issue is haunting me for a long time. I’ve drilled the forum, Google, GitHub, and StackOverflow but there’s no answer to this problem.

I’m currently building a very custom form. This means that I need to extract values from the database and return custom payloads in almost every utter.

I’m stuck in a part in which I need to gather a user input (I send a list of options, numbers from 1 - 10 and the user must select among them) in a custom action and then send it to another custom action regardless of user input. I know these are kind of against the principles of conversational UI, but there are so many options, and buttons would cramp the UI too much.

I’ve tried so many things to no avail. I can’t use forms as one slot value depends on the other one (Based on the previous value, it needs to find it in the DB, and then return a list of options). And in stories the intents get tangled up, having one custom action fired up before the other one… It’s a mess.

I’ve tried:

  • welcome
    • action_availability
    • action_listen
    • action_time_availability
    • action_listen
    • action_interaction_medias
    • action_listen
    • action_consult_result

But when it reaches the action_listen, nothing gets fired. If I do it per intent, then it gets tangled up, as action_availability, action_time_availability, and action_interaction_medias are all options set from 1 - 10 (They can vary in range!).

* welcome
  - action_availability
* time_availability
  - action_time_availability
* interaction_medias
  - action_interaction_medias
* consult_result
  - action_consult_result

I have also tried laying them out one after the other, but then, they get fired simultaneously:

  • welcome
    • action_availability
    • action_time_availability
    • action_interaction_medias
    • action_consult_result

Hi @superjose!

Could you please explain your story/use case in a bit more detail like what is the conversation flow that you have in mind for which you are writing this story?

Absolutely! We’re in the process of building a patient-doctor interaction platform. The chatbot consists of acquiring certain information from the patient and finally scheduling a medical consultation.

Its process is not in a conversational fashion, but more like a series of steps by steps.

Here’s the entire flow:

* welcome
  - action_greet_user
* tos
  - action_tos
* birth_date
  - action_birth_date
* gender{"birth_date": "08/21/1992"}
  - utter_ask_gender
* province{"gender": "male"}
  - action_province
* conditions{"province": "azua", "municipality":"azua"}
  - action_conditions
* symptoms{"conditions": [1,2, 3]}
  - action_symptoms
* verify{"symptoms": "tos"}
  - action_verify
* consult
  - action_consult
  - user_contact_form
  - form{"name": "user_contact_form"}
  - form{"name": null}
* date_availability
  - action_availability
* time_availability
  - action_time_availability
* interaction_medias
  - action_interaction_medias
 * consult_result
  - action_consult_result
  • action_greet_user sends two utterances and a button.
  • action_tos sends two utterances and a button (payload maps to birth_date intent)
  • action_birthdate sends a custom date payload (which I have to manually implement in rasa-webchat) and redirects to gender. Payload maps to gender
  • utter_ask_gender sends a utterance and three buttons. Paylod maps to province
  • action_conditions sends a custom checkbox payload (which I have to manually implement in rasa-webchat) and redirects to symptoms
  • action_symptoms sends a custom checkbox payload (similar to action_conditions) and redirects it to verify.
  • verify sends a confirmation button that redirects it to consult.
  • Consult is a form that gathers: first name, last name, phone, national id, and email.
  • Then, I need it to go to action_availability, in which I’m going to present a list of the available dates (1 - 10 max. Can be lower) which the user can use to type the number in which he wants to make it available.
  • With that number, I need to search in the database for the available time slots during that day. Then present the user back with a list of options.
  • Finally I’m going to present the user with a series of buttons so he can select the way he can be contacted.

My problem is when presenting the list of options, that the chatbot gets lost, and I need to prevent another intent from firing up. I’d like to avoid having to develop another custom object as rasa-webchat is very tedious to extend.

Thanks :slight_smile:

Bump*

Bump * 2

@saurabh-m523

Bump 3

Bump 4.

Hi @superjose! Sorry for late reply.

So what I got from this is that you are asking the user a bunch of questions before starting the “consult” form. After that, the user enters a number (for option 1-10) and this is where you are having a problem because the bot is predicting some intent for the entered number and you need to start a custom action regardless of the intent of the entered number.

If this is the problem you are facing then it can be easily solved with a form action and custom slot mapping.

Basically, you can add one more required_slot to your “consult” form. Let’s call this slot “option”. Now you can define a custom slot mapping for the “option” slot to accept free text input and then once you have this input you can write a validation function to perform a database lookup and get back to the user with the list of options.

On a different note, I think you can do the initial question-asking in a single form instead of writing a lot of intents and custom actions. Any particular reason why you are not doing that? :slightly_smiling_face:

Hahah don’t worry. I’ve been trying to crack the nut by myself. I think I’ll end up resorting to alternatives. The reason why I don’t use the form is that I need to make a call into the database per slot value and based on its value I need to make a secondary call, and to my knowledge, the form doesn’t let me do that.

1 Like

I know I’m using Rasa the other way around. We are supposed to let the user chat freely and then validate its input. We’re doing it the other way as the user doesn’t necessarily know its input.