Forms with Dynamic `required_slots` and slot Mappings in RC02
See original GitHub issueI wonder if the form described in this youtube tutorial is no longer compatible in Rasa 3.0.
I had this form that would add a slot if a name appeared that we believe is spelled incorrectly.
import yaml
import pathlib
from typing import Text, List, Any, Dict, Optional
from rasa_sdk import Tracker, FormValidationAction
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.types import DomainDict
names = pathlib.Path("data/names.txt").read_text().split("\n")
class ValidateNameForm(FormValidationAction):
def name(self) -> Text:
return "validate_name_form"
async def required_slots(
self,
slots_mapped_in_domain: List[Text],
dispatcher: "CollectingDispatcher",
tracker: "Tracker",
domain: "DomainDict",
) -> Optional[List[Text]]:
first_name = tracker.slots.get("first_name")
if first_name is not None:
if first_name not in names:
return ["name_spelled_correctly"] + slots_mapped_in_domain
return slots_mapped_in_domain
async def extract_name_spelled_correctly(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> Dict[Text, Any]:
intent = tracker.get_intent_of_latest_message()
return {"name_spelled_correctly": intent == "affirm"}
The reasoning here is that I would only ask about the spelling of the name if there was a reason to ask for it. That’s why the user isn’t bothered with extra questions. That’s why the slot was dynamically added here. Is such a pattern possible now that we have predefined slot mappings? It feels like I cannot use this dynamic trick anymore.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Allow slots added dynamically to a form via ... - GitHub
Problem description: A slot with a global slot mapping that is added dynamically to a form can be set by ActionExtractSlots in rasa...
Read more >Forms - Rasa
As of 3.0, slot mappings are defined in the slots section of the domain. ... You can update the required slots of your...
Read more >Slot mapping | Amplience Developer Portal
The Dynamic Content integration supports two types of SFCC content slots: global slots and category slots. A Dynamic Content slot is mapped to...
Read more >Conversational AI with Rasa: Custom Forms - YouTube
In this episode of Conversational AI with Rasa, Vincent Warmerdam will continue to go more in-depth in discussing forms, a quick and easy ......
Read more >Problem when filling slots with custom form (Failed to extract ...
You don't define slot_mappings , so it's going to assume that it should set the slot from an entity of the same name....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The nlu training data in the repo indeed doesn’t have an intent defined + examples for when a name is given in an user utterance, so yes that could be a problem, however I haven’t followed that route especially that I remembered Akela saying that not all utterances containing information given to the bot have their own intents which is why
from_text
mapping gets used most often.Yes,
action_extract_slots
does not have the same extraction behaviour as forms in 2.x, because there’s noasking
of slots in the default action, it runs through all slots and their mappings to check if any mapping is applicable with information gathered from latestUserUttered
.I’ll have a think of how I’ll phrase this, maybe as a caution note to double-check behaviour when
FormValidationAction
is used and then link it to the default action page, I’ll see if that section may also need improving? Could you please submit a tiny docs issue for this @koaning ?Yup, I’ve added in the PR for slot mappings update (right at the bottom of the migration guide), not yet merged: https://github.com/RasaHQ/rasa/pull/10011/files