RASA FORMS - 'NoneType' object is not iterable

595 views Asked by At

I am creating a bot to help the user search the file based on the name provided and I am using a slot to store the memory of the file name called "SEARCHCONTENT" and I am using the "SEARCH" entity to help the bot identify the different synonyms for the search word. Here is my nlu data to search for the file:

## intent:searchSynonyms
 - [search](SEARCH)
 - [look for](SEARCH)
 - [find](SEARCH)
 - [where is](SEARCH)

## intent:file
- file
- file [bills](SEARCHCONTENT)
- [search](SEARCH) file
- [search](SEARCH) file [mouse](SEARCHCONTENT)
- [search](SEARCH) for a file
- [search](SEARCH) for a file [laptops](SEARCHCONTENT)
- [searching](SEARCH) file
- [searching](SEARCH) file [accounting](SEARCHCONTENT)
- [where is](SEARCH) the file
- [where is](SEARCH) the file [order summary](SEARCHCONTENT) located
- [look for](SEARCH) the file
- [look for](SEARCH) the file [degree planner](SEARCHCONTENT)
- [find](SEARCH) file
- [find](SEARCH) file [design report](SEARCHCONTENT)

In the domain file I have specified the slot name that takes 'text' as an input:

slots:
  SEARCHCONTENT:
    type: text
    auto_fill: false

Then I proceed to create my form:

from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import SlotSet
from rasa_sdk.forms import FormAction
class FormActionFileSearch(FormAction):
    """Custom form action to find file"""

    def name(self) -> Text:
        return "form_action_file_search"

    @staticmethod
    def required_slots(tracker: "Tracker") -> List[Text]:
        return ["SEARCHCONTENT"]

    def slot_mappings(self) -> Dict[Text, Any]:
        return {"SEARCHCONTENT": self.from_entity(entity="SEARCHCONTENT", intent=["file"])}

    def submit(
        self,
        dispatcher: "CollectingDispatcher",
        tracker: "Tracker",
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        search_content = tracker.get_slot("SEARCHCONTENT")
        dispatcher.utter_message("Searching file " + search_content)

For now, all I am trying to do is to print the file name to check if it is correctly extracting the value from the slot or not.
Then I proceed to the domain.yml file to add the form action name:

forms:
  - form_action_file_search

Then I proceed to add the form policy in my config.yml file:

policies:
 - name: FormPolicy

Then I proceed to create the story for the file name search:

## file path affirm
* file{"SEARCHCONTENT":"car budget"}
- form_action_file_search
- form{"name": "form_action_file_search"}
- form{"name": null}
- utter_assistance
* affirm
- utter_askAssistance

Then I add all the intents and the actions to the domain.yml file and this is how it looks:

intents:
- file
- affirm
entities:
- SEARCH
- SEARCHCONTENT
slots:
  SEARCHCONTENT:
    type: text
    auto_fill: false
forms:
  - form_action_file_search
responses:
  utter_assistance:
  - text: Is there anything else you need?
  utter_askAssistance:
  - text: How can I help you?
actions:
- utter_assistance
- utter_askAssistance

When I am running the bot and typing as input "search file account summary" it is giving me the following error:
enter image description here

1

There are 1 answers

1
Gaming God On

Can you try changing your slot type to unfeaturized.

slots:
  SEARCHCONTENT:
    type: unfeaturized
    auto_fill: false