How do I set a slot when there is no entity?

Hi

How do I set a slot when there is no entity?

To explain this general question, please consider a specific example. In the context of a bot like the financial demo bot, please consider the following NLU data:

How much do I owe?

What I want is to set the slot {"entity":"account_type","value":"credit"} even though there is no specific word in the sentence which is actually an entity.

I worked around this issue by pretending the word “owe” is a synonym for credit, like this:

How much do I [owe]{"entity":"account_type","value":"credit"}?

But this is obviously a hack, since “owe” is not exactly a synonym for “credit”. Is there a way to set the slot without any entity appearing in the sentence above? Even better: if it can be done without python code, only using markup etc.

Thank you

Project               : Rasa Financial Demo
Rasa Version     : 2.1.3
Rasa SDK Version : 2.1.2
Rasa X Version   : 0.35.0
Python Version   : 3.6.9
Operating System : Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-Ubuntu-18.04-bionic
1 Like

Hello @gpn1998

For this you’ll need to define a custom action that returns a SlotSet event, as in this example. You can then write a rule or story that triggers that custom action whenever the intent for “How much do I owe?” appears.

Thank you for your answer @j.mosig !

I worked on this and found an answer that requires no custom code. I used an empty entity in my NLU data. Like this:

How much do I owe[]{"entity":"account_type","value":"credit"}

Can anyone tell me whether an empty entity as above is officially supported or just a hack that may soon break?

In any case this does work with the following versions. I hope others find this useful.

Rasa Version     : 2.1.3
Rasa SDK Version : 2.1.2
Rasa X Version   : 0.35.0
Python Version   : 3.6.9
Operating System : Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-Ubuntu-18.04-bionic

Well, this is not how entities are supposed to be used. I’d expect classification to work better if you use intents and custom actions instead, so your approach might not scale as well to a complicated assistant.

You are right. I discovered that in further testing. Thanks.

1 Like