Stuck on slot value extraction

I have included FormAction and there are three slots that are required to complete the form.

**slots: ** - ticket_number - resolution_code - resolution_description

I want to fill resolution_description with complete sentence which user is passing. How can I take complete senetence as value for slot?

For example

bot : Please provide updated resolution description

user : This is example text. I have changed the settings for user x and y. Please proceed the ticket.

my slot resolution_description should have value β€œThis is example text. I have changed the settings for user x and y. Please proceed the ticket.”

Hi @dhara,

Welcome to Rasa Community !

Try

self.from_text()

More on custom-slot-mappings

1 Like

Hi @MuraliChandran14

It worked. Thanks.

getting new error - i want my slot values to reset to None once i compelte the story

How should I do this? Do you have any idea?

for exmple:

i have provided all the form values and called API and completed my execution. Now when I am trying to do the action again it is taking previous slot values instead the bot asking form values again.

@dhara

you can do it on submit method on FormAction

def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        """Define what the form has to do
            after all required slots are filled"""
    
      ##After all operations are done

        return [
            SlotSet("ticket_number ", None),
            SlotSet("resolution_code ", None),
            SlotSet("resolution_description", None)
            ]
**Your input** ->  hi     
                                                                                                                                                                
? Hey! I am bot , How can I help you?  1: Close Tickets (/inform_close_ticket_query) 
                                                                                                 
Please provide Ticket number
**Your input** ->  INC14564   
                                                                                                                                                          
Please provide Resolution code
**Your input** ->  RC4 
                                                                                                                                                                   
Please provide Resolution description
**Your input** ->  Please proceed with ticket closing i have updated the fields  
                                                                                                                        
Please confirm the details 
 -Ticket number : INC14564
 -Resolution Code : RC4
 -Resolution Description : Please proceed with ticket closing i have updated the fields
 -press yes to confirm else no to change the details
**Your input** ->  yes 
                                                                                                                                                                   
I have successfully closed the ticket :INC14564

**Your input** ->  hi                                                                                                                                                                         
? Hey! I am bot , How can I help you?  1: Close Tickets (/inform_close_ticket_query)                                                                                                      
Please confirm the details 
 -Ticket number : INC14564
 -Resolution Code : RC4
 -Resolution Description : /inform_close_ticket_query
 -press yes to confirm else no to change the details
    indent preformatted text by 4 spaces

Hi @MuraliChandran14

Above solution is not helping as the slots are getting previous values.

When I am again saying Hi , Bot should again ask for all the form fields. This is my ActionFormInfo function.

class ActionFormInfo(FormAction):
    def name(self) -> Text:
        """Unique Identifier of the form"""
        return "ticket_info_form"

    @staticmethod
    def required_slots(tracker: Tracker) -> List[Text]:
        """A list of required slots that the form has to fill"""
        return ["ticket_number","resolution_code","resolution_desc"]

    def submit(
            self,
            dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text,Any],
        ) -> List[Dict]:

        dispatcher.utter_message(template="utter_ask_confirmation",
                                 ticket_number=tracker.get_slot('ticket_number'),
                                 resolution_code=tracker.get_slot('resolution_code'),
                                 resolution_desc=tracker.latest_message['text'])
        return [
            SlotSet("ticket_number ", None),
            SlotSet("resolution_code ", None),
            SlotSet("resolution_desc", None)
            ]


    def slot_mappings(self) -> Dict[Text, Union[Dict,List[Dict]]]:

        return {
            "ticket_number": self.from_entity(entity="ticket_number",intent="inform_ticket_number"),
            "resolution_code": self.from_entity(entity="resolution_code",intent="inform_resolution_code"),
            "resolution_desc": [self.from_entity(entity="resolution_desc"),self.from_text()]
        }

Hi @dhara

Try

return [AllSlotsReset()] from rasa_sdk.events import AllSlotsReset

    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        dispatcher.utter_message(template="utter_ask_confirmation",
                                ticket_number=tracker.get_slot('ticket_number'),
                                resolution_code=tracker.get_slot(
                                    'resolution_code'),
                                resolution_desc=tracker.latest_message['text'])

        return [AllSlotsReset()]
1 Like

@MuraliChandran14

It worked. Thanks :grin: