Form Based on Slot value

HI , This is my 2nd post in rasa :slightly_smiling_face: .

I have a scenario

  1. User asks the bot to create Requisition order: “Can you help me to create Purchase requisition order for ABCD1”
  2. Bot recognizes ABCD1 as item code. & this is mapped to a slot[item].
  3. What if a user only says “Can you help me to create a Purchase requisition order” in This case, the bot should ask for Item number & quantity.

Is there any way this can be achieved? Can forms be used to trigger based on slot value? i.e if slot[item] = ‘null’ then call item form else only call quantity form ?

Or is there a better way?

Regards, Mayank Pande

Hello @mayank2288 and that’s a very tricky questions and personally I not implemented but I’m trying to give some pointers, please cross check with doc and some other threads too.

  1. You need to use FormValidation, check the example mention in Rasa Doc: Forms how in this example we are matching the slot value and return the response, that you can archived whilst using If else statement with return. If the slot value match it will return else trigger the new form action.

  2. In your else statement, you can trigger the new form using Followup Action, please see this thread: even you can play around with intents and entities for the same.

Scenario 1:

User: Can you help me to create Purchase requisition order for [ABCD1]

Bot: Sure let me see from my record please

Bot: ABCD1 here it Item code

Scenario 2:

User: Can you help me to create a Purchase requisition order

Bot: Sure! Which Item number number you want to order and how much quantity.

Bot: Please give me a detail for : 1. Item Number 2. How much quantity

User: ABZY2 and 5 qt

In this scenario we will trigger the Followup action with form.

Note: This is only my suggestion, as I told you I not implemented this use case and such scenario. Please think and implement as per your requirement.

I hope this will help you.

Thanks, Nik202. This helped me.

What I did was to create the form

        - item
        - itemqty
        - moreline

& slot as

    type: text
    influence_conversation: true
    - type: from_entity
      entity: item

What happens is that if an entity is not recognized by Bot, then the bot asks for these values from the user. This is working as expected.

But now If the user says (3rd Slot) that additional lines need to be added. In this case, is there any way to store existing values in the list & retrigger form to capture new lines?

Regards, Mayank Pande

Not get you at all on this, can you share some scenario or screenshot of bot/user?,and What is this moreline (adding new line? next line? is that what you meant ??

Yes Nik. I want Bot to ask user if new lines needs to be created. If user confirms than same form should be called to collect information.

I am not able to figure out this part.

Regards, Mayank

What is the significance of the new line? How you display in the chatbot also imagine how it will look like, can you share some example, I even asked you in my previous post. Thanks.

HI Nik202, Sorry for missing previous post.

Lets take example of Ticket Booking services.

User: I want to book ticked from Mumbai to Delhi.
Bot: Sure, I can cehck available flights from Mumbai to Delhi. Can you share passenger names?
Bot: First Name?
User: Mayank
Bot: Last Name?
User: Pande
Bot: Age of Mayank Pande
User: 33
Bot:any other traveler?
User: Yes , 2 more.

In this case, i want same form for First name, Last name & age should be repeated twice. or is there any better way to achieve this??

I hope it’s clear.

Regards, Mayank Pande

@mayank2288 please can you confirm me that its related to the original issue which you mentioned in the topic, is that issue resolved?

@mayank2288 you asked me for the newline? where that concept vanish? me confused now :thinking:

Always mention @ and nik202 for fast reply Thanks.

@nik202 : Thanks. I was not aware of ‘@’ issue is still there. I just tried to explain issue in generic terms. As my original issue is Procurement domain specific.

That’s why I tries to expain similar issue with gerniric use case,

Basically , I need to create order. One Order can have multiple lines. I have created form to capture information for lines. But I need form to repeat till User says that all lines are finished. .

In above example: User wants to book ticket for 3 persons(line in my case). Bot should ask First name, Last name & Age 3 times to user.

Regards, Mayank Pande