Is it possible to populate a form or slot memory directly from a component or action?

The documentation is clear that forms seem to be for custom actions, and if a slot is not filled, it looks for an utterance to fill a slot from a user. But what if you want to populate a form from a custom action?

Maybe it is a separate question, but is it better a custom component you could use to fill slots or forms from a custom extractor?

Heya @Hendler. I hope you gone though doc. I’d recommend to see these videos link to :

For Slots: Memory and Slots in Rasa | Rasa Tutorial - YouTube

I hope this will help you for better understanding. Good Luck!

Thanks NiK! The youtube channels and documentation I have reviewed fairly in-depth.

My question is fairly specific to populating slots (slots and not forms because I want to persist between sessions). I see that there is a way to create entities from custom components but no direct slot access. Custom Slot Set in NLU/Custom NLU Component This approach seemed quite complicated https://github.com/RasaHQ/rasa/issues/2294

Is there not a better approach that populating a form with a custom component, and using that form to populate slots"?

At least one of the Udemy courses is closed BTW.

You can populate slots from a custom action by using the SlotSet event.

Wherever your slots are being populated from (MySQL, JSON file, etc.), I suggest converting that data to a list of tuples representing slot-value pairs like:

[('name', 'Chris'), ('age', 23), ('country', 'Lebanon')]

Then, in your custom action, build a list of SlotSet events with it:

data = getDataFromDatabase()              # data = [('name', 'Chris'), ('age', 23), ('country', 'Lebanon')]
return [SlotSet(x, y) for (x, y) in data] # return [SlotSet('name', 'Chris'), SlotSet('age', 23), SlotSet('country', 'Lebanon')]

Perfect. Thank you @ChrisRahme. And to confirm SlotSet can not be used from a component. You must use entities to be captured by forms.

The reason I ask I have custom classifier and that can extract entities. Sometimes I’d like to populate a form, sometimes I’d like to populate a slot. Sounds like I’d do form capture with entities in the component, then slot capture in a custom component.

Glad to be of help :slight_smile:

I’m pretty sure that you can’t use SlotSet specifically, but there may be a way to set a “slot” in general, in the metadata the component will produce.

1 Like