question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forms with Dynamic `required_slots` and slot Mappings in RC02

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ancalitacommented, Nov 19, 2021

Is this intent misclassification due to wrong training data / wrong config and has nothing to do with slot mappings?

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.

this still seems like behavior that’s different than in Rasa 2.x

Yes, action_extract_slots does not have the same extraction behaviour as forms in 2.x, because there’s no asking 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 latest UserUttered.

we may want to warn folks in the migration guide

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 ?

2reactions
ancalitacommented, Nov 17, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found