Free Form Text without Slots and Intent Prediction

Hey Everyone,

I am trying to implement a functionality in my bot which sends a mail when a particular intent is hitted. Currently I can send the mail using Shell Script and Python Connection, but the mail is totally static, i.e. some predefined mail format with fixed Subject,Body. Our intention is that when the particular mailing_intent is predicted, the user should get the feasibility of writing a free text which is independent of any intent prediction and that is captured using tracker.latest_message[‘text’] and can be used in the body of the mail.

Right now, we can pass the latest message of the mailing intent but I have no idea as how to fetch the free flow text which is independent of any intent prediction

Anyone can help me on this?

@akelad , I went through free text type, but couldn’t find it helpful in my case.

Please note: I am not using any entities or slots, just normal intent hitting and then required to get a free flow text.

Hi @mishra-atul5001!

You can use Forms to get free text input. Although a form will fill a slot with the free text input, but I guess that should not be a problem (?)

You can trigger this form on receiving the mail intent, ask the user for free text, and then finally in the submit() method of the form you can send the email.

Hope that helps. :slightly_smiling_face:

@saurabh-m523, I get it what you’re trying to say!. But just one clarification I need is that the slot which will be captured has to be defined in nlu file. Without defining the slot, it won’t work. In that case, we have to fill up the slot values with some random data. But free text can go out of the section also. Or is it possible that we do not define any intent with respect to that slot, and just mention it in domain.yml file and while defining the form, catch an undefined empty slot?

If you have any example regarding this, it would be helpful!!

No need to mention the slot in NLU. Actually NLU does not have slots at all, they are called entities. Slots can be of the same name as entities and are defined in domain.yml file.

So, you can just define an unfeaturized slot in the domain.yml and then fill this slot in your FormAction.

Awesome. Loved the response. Will try it today and let everyone know about the same!:v:t2:

class SystemDBMailingForm(FormAction):
"""Example of a custom form action"""

def name(self) -> Text:
    """Unique identifier of the form"""

    return "action_mailing"

def required_slots(tracker: Tracker) -> List[Text]:
    """A list of required slots that the form has to fill"""
    return ["mailing_slot"]

def submit(
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
) -> List[Dict]:
    f = open('json_input.json',)
    df_we_need = pd.read_json(f, lines=False)
    username_we_need = 'B211256'
    row_we_need = df_we_need[(df_we_need['UserName'] == username_we_need)]
    row_we_need = row_we_need.sort_values(by = 'LogonTime',ascending = False).head(1)
    email_id = row_we_need.UserEmail.values.item()
    email_id = ''
    #message = tracker.latest_message['text']
    #message = 'Hi'
    message = tracker.get_slot('mailing_slot')
    running_mail_direct_to_team(email_id,message) # Till here we have drafter the mail and composed it. Called it in python and it is working fine!
    # Next we need to pass the variables containing CC and BODY.!
    # We have passed the CC 
    dispatcher.utter_message(text="We have drafted the mail and copied you in CC. \nDropping the mail..!!")
    return []

And I have defined the slot mailing_slot as unfeaturized. But when I run the same, I am getting

2020-06-15 12:06:30 DEBUG rasa_sdk.forms - Trying to extract requested slot ‘mailing_slot’ …

2020-06-15 12:06:30 DEBUG rasa_sdk.forms - Got mapping ‘{‘type’: ‘from_entity’, ‘entity’: ‘mailing_slot’, ‘intent’: [], ‘not_intent’: [], ‘role’: None, ‘group’: None}’

2020-06-15 12:06:30 DEBUG rasa_sdk.forms - Failed to extract requested slot ‘mailing_slot’

2020-06-15 12:06:30 ERROR rasa_sdk.endpoint - Failed to extract slot mailing_slot with action action_mailing

Here is the screenshot from --debug and actions server!

Hi @mishra-atul5001!

You want free text input right?

So you should use slot mappings. From the docs:

self.from_text(intent=intent_name) will use the next user utterance to fill the text slot slot_name regardless of user intent if intent_name is None else only if user intent is intent_name

Hi @mishra-atul5001, did you get this working , i have the same problem and unable to find a solution. Please let me know if find a fix.