From action never ask to fill slot if it is already filled

I am facing problem while filling slot. I have following scenario -

 User - search book
 Bot- What is the title?
 User - Science fiction
 Bot- Here is book with science fiction

Now when user asks again to bot ‘search book’, then bot does not prompt again to fill title slot as it finds slot which was filled in last conversation. But when new form policy is activated, it should prompt again for asking title. What is the reason for this? How do I make sure whenever new form policy is activated it should ask again for title

slots:
  book_title:
    auto_fill: false
    type: unfeaturized

I have even set auto_fill to false.

Slot mapping function is below -

def slot_mappings(self):
    # type: () -> 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 {"book_title": [self.from_text(),
                             self.from_entity(entity='book_title' )]}

In this function it is mentioned, slot will be extracted either from entity or from entire message, then why it is taking slot value being set during previous conversation.

1 Like

I’m facing the same issue that the bot is remembering the slot value. I deal with this by applying SlotSet('slot_name', None). I don’t know if this is the right way but it definitely works. Once I’m done with using the slot value in my form, I just reset them.

I don’t want to set slot to none because I need it later during conversation. so this is not possible solution. It should happen automatically, if new conversation is started, slot should be asked again if it is not provided by user.

By a new conversation, do you mean a new story?

Also, I think the required_slots() method gets executed before and it sees that all the slots are already filled from the previous conversation so it skips over the slot_mappings() method.

@akelad can you please help with this? It would help my use case as well.

You can add - action_restart to upon completion of ‘search book’ story.

I don’t want to reset tracker state. I want slot to be overwritten when new information is asked. But here bot is not uttering to ask for new info, if it finds that slot is already set.

Does anybody have any idea why form is behaving this way and how can I change its behaviour?

@r4sn4 I’m not 100% sure what your expectation is when you’re asking for the title of the second book. Above you said

But if the user is asked for the name of the second book, it would override the title slot any way. Thus, after asking for the second time, you’ll always lose the title of the first book. Can’t you just reset the slot once the later during the conversation part is done?

1 Like

It is not asking for title again… that is the problem… when I start conversation for new user, only first time it asks for slot and then it never ask for title… I checked the same communication again after one day for the same user, it is not asking for title ever… For new user bot asks to fill book_title slot for the first time only, then it never asks again when I initiate fresh conversation for the same user.

So you want only some slots to be reset and the rest have to retain the value throughout the conversation, right?

You can split the slots and reset the ones you need new value. That way your tracker is still maintained and the required slot will still have a value. I’m assuming that you will be using the slot values in some custom action later, so once you are done with the value, reset the ones you need to be updated.

This is not what I want. My scenario is this -

1st conversation -

User - search book
Bot- What is the book title?
User - Science fiction
Bot - Here is  your book with title science fiction

2nd conversation -

User - Now, search book with title warrior
Bot- Here is your book with title warrior

3rd conversation -

User - search book
Bot - Here is your book with title warrior

Here, what happening is, when user says search book for the first time, bot prompt to ask book title. when user respond with book title science fiction, bot shows him science fiction book which is fine.

Now in 2nd conversation when user says - search book with title warrior, bot says - here is your book with title warrior which is again fine.

Now in 3rd conversation, User again says search book. This time bot is not asking for title because it takes value from prefilled book_title slot which is not fine. If user is not providing book title in conversation, then bot should again prompt for title.

4th conversation

 User - show my last book
 Bot- no book found

Now in 4th conversation, if have set book_title slot to None after the conversation is finished, bot will get None for book_title slot, so will it not respond what was the last book user interacted with.

Okay, so maybe you can take two slots.

So here have two slots, one will be current_slot and the other previous_slot. Every time the user asks for a new book title fill both slots. When the user asks for the last book use the previous_slot value.

Your stories will have to be something like this

# story 1
* book search
  - action_book_search
  - action_reset_current_slot

# story 2
* book search
  - action_book_search
  - action_reset_current_slot

# story 4
* book search previous
  - action_book_search_previous

Thanks this seems fine… will implement this…

@r4sn4 You probably want to reset the current slot in your form’s submit method by returning an additional SlotSet('current_slot', None) event rather than having a action_reset_current_slot. I personally think this should be part of your bot’s logic rather than trying to train your bot to reset it (even though with most policies it won’t be a problem).

@smn-snkl Yes, I did this way only. I reset slot at the end of submit method

In case somebody is suffering from the issues discussed here and applying the “solution” mentioned above, I want to note that this solution is not 100% safe either.

Resetting slots in the submit method doesn’t prevent forms being filled automatically without asking for user input in situations like this:

* user_likes{"item": "strawberries"}  # "I like strawberries"
  - utter_user_likes
* order_food
  - form_food
  - form{"name": "food"}
  - form{"name": null}

Where the user will not be asked for the slot item again, just because an entity matching the slot was mentioned somewhere in the conversation before.

Discussing this here