I need to make a Custom Action that can be configured through parameters. I have been unable to use slots for my use case. For example, I have a custom action that can open a web page in browser. But, I want it to open a different webpage on different occasions. So, I can write a story like this:
- story: First time I want to open google.com. Second time I want to open facebook.com
steps:
- intent: open_browser
- action: action_open_browser
- intent: open_browser
- action: action_open_browser
You can see that I am trying to use the same custom action for different use cases. Making multiple custom actions doesn’t makes sense because only the URL will be different and adding more URLs will make it impossible to scale up.
Now, what I want is to set a slot myself in the story. Or use some other technique so that I can pass in a value to my custom action to decide which URL to open. Following is an invalid story but demonstrates what I want to achieve:
- story: First time I want to open google.com. Second time I want to open facebook.com
steps:
- intent: open_browser
- set_slot: {url: google.com}
- action: action_open_browser
- intent: open_browser
- set_slot: {url: facebook.com}
- action: action_open_browser
Basically, the user (talking to the bot) cannot tell which page to visit. So, I cannot extract entities and set slots like that. I need to integrate this logic myself in stories/rules.
Your use case is currently not possible in the training data. Would setting the slot in the custom action itself be an option? Depending on your different use cases, you could maintain some sort of state in the action server, and decide which URL to open after the previous N ones.
Setting the slots in the custom action won’t be helpful because the flexibility of changing URLs need to be with the person writing stories/YAML files. So, I was looking for something simple that won’t require much changes in the action server for different use cases.
Seems like maintaining states in action server is the only option for now.
I faced the same challenge and was looking for a way to pass parameters to a custom actions in order to set a slot value to a URL to be used in the conversation flow. I did not find a way to pass parameters however I was able to use the tracker object to figure out the ‘intent’ calling into the custom actions and since the intent is unique to the value I need to map the relevant URL: str(tracker.get_intent_of_latest_message(True)).
There should be a way to set slots in stories and pass parameters to custom actions in my opinion.