How to SetSlot with Extracted Entity in Custom Action depending on the intent?

Hi everyone.

I use Duckling as Entity Extractor. Now I am stuck in situation where I extract time for different purposes in different cases. For example I need to extract time both when user wants to schedule a meeting and when user schedules feed update (but there may be another cases in future too, so I can’t handle this by just resetting slot in a custom action). Obviously I can’t have one slot for it, as when user first schedules time for feed update, my “time” slot fills with that entity (auto_fill: true) and further I forcefully use it in meeting scheduling (I have a if else clause that checks whether “time” slot is not None).

So generally my questions are the following:

  • Is it possible to set a slot with extracted entity inside a custom action?
  • Is it possible to handle slot filling based on intent and handle it with stories?
  • Is it possible to set a slot with extracted entity inside a custom action?

Yes! For example, here we check if any entities named entity (confusing, i know, it’s the name of the entity in this case) was picked up, and then we set the entity_to_extract slot based on it.

  • Is it possible to handle slot filling based on intent and handle it with stories?

Well, yes and no. It’s not possible to set a slot just based on the intent that comes in, as the slot event in the story actually represents a SlotSet event that has to occur (either by entity auto-fill into slots, or in a custom action, e.g. as a result of your first question)

However, if you want to do something different based on the intent just via the stories, you don’t need a slot event to do so! Instead of changing the path based on the slot value, you can change the path based on the intent.

note that if you want to change the story based on the value of the slot, be sure that the slot type is featurized – you probably want bool or categorical.

Thanks for the answers! I worked it out the first way as my slot values are continuous and unbounded.

1 Like

This is 404’d.

In fact, it seems like the majority of links, mostly to Github, posted here in the forums are all 404’d. It would be good if someone could clean up this situation, and it’s pretty much making Google searches on Rasa questions useless.