chemssou
chemssou

Reputation: 7

Train rasa_core to predict the next intent according to stories.md

Need help for this one. I want to know how can I train my bot to predict the next intent according to what I have in stories.md.

To be clear: I have an intent ‘problem’ in this intent I don’t know what the user could tape. It can be every thing that the user qualify that it’s a problem for him. All what I know is that this intent will occur in a certain phase of the conversation . for example:

## story1
* greet
    - utter_greet
* confirm
    - utter_step1
* probleme
    - action_SendIntentProbleme
    - utter_probleme_site

So here I know that always after utter_step1 the user will give me his problem, and I don’t need to understand it I just need the bot to qualify it as intent problem to be able after this to execute action_sendintentproblem and then utter_problem_site. The bot answer for this intent is general. no matter what is the content of this intent.

I want my bot when listening to the user after Utter_step1 to know that the next input will be intent ‘probleme’, can I specify this in my data.md file? or do I need to add this in the configuration file and how?

Thank you for your help

Upvotes: 1

Views: 810

Answers (1)

Tobias
Tobias

Reputation: 1910

You could use forms for this use case.

The story should look like:

## story1
* greet
    - utter_greet
* confirm
    - utter_step1
    - problem_form
    - form{"name": "problem_form"}
    - form{"name": null}
    - action_SendIntentProbleme
    - utter_probleme_site

In your domain file add:

intents:
  ...

slots:
  problem_message
    type: unfeaturized
  ...

forms:
  - problem_form

actions:
  - utter_ask_problem_message

templates:
  utter_ask_problem_message:
    text: "What is your problem?"

In your core policy configuration add the forms policy:

policies:
  - name: FormPolicy
  ...

And then have a form like:

from rasa_core_sdk.forms import FormAction

class ProblemForm(FormAction):
    """Accept free text input from the user for suggestions"""

    def name(self):
        return "problem_form"

    @staticmethod
    def required_slots(tracker):
        return ["problem_message"]

    def slot_mappings(self):
        return {"problem_message": self.from_text()}

    def submit(self, dispatcher, tracker, domain):
        return []

This form will call utter_ask_problem_message until the slot is filled by the user. As we call self.from_text() the slot will be filled with the whole message.

Upvotes: 1

Related Questions