Set the slot value using regular expression

I want to set my slot value using regular expression. any one please help me on that.

My slot was movie name, can’t train all movie names so i used regular expression pattern.

here my regular expression nlu data:

- regex: moviename
  examples: |
    - (.*)
- intent: movies
  examples: |
    - [dabangg](moviename)
    - [sholay](moviename)
    - [pink](moviename)
    - [stalin](moviename)
    - [racha](moviename)

here is my slot in domain.yml:

intents:
- movies:
    use_entities: []
entities:
- moviename
slots:
  movie:
    type: text
    influence_conversation: false
  requested_slot:
    type: text
    influence_conversation: false

here is my actions.py:

class ActionMovieName(Action):
    def name(self):
        return "action_movie_name"
    def run(self, dispatcher, tracker, domain):
        movie = tracker.latest_message['text']
        return [SlotSet("movie", movie)]

Here is my story path:

- story: happy path
  steps:
  - intent: greet
  - action: action_ask_movie_name
  - slot_was_set:
    - requested_slot: movie
  - intent: movies
  - action: action_movie_name

Hello @mounika2

I’d use a form for this, where the movie name is picked up first by entity and second by text:

forms:
  movie_form:
    movie:
      - type: from_entity
        entity: movie_name
        intent: provide_movie_name
      - type: from_text  # see https://rasa.com/docs/rasa/next/forms#from_text

Then give a few examples for some provide_movie_name intent, such as

- i watched [The Dark Knight](movie_name)
- [Contact](movie_name) perhaps?
...

where the movie title can be inferred from the surrounding words. If the user gives only the title (no surrounding words), then the from_text slot mapping should kick in. You can also use not_intent to handle cases where the user doesn’t provide a movie name.

1 Like

Hey, @j.mosig

Thanks for your information.

Hi, @j.mosig,

please help me on stories and rules, I f write story path using forms I am getting error like this

InvalidRule: Contradicting rules or stories found :rotating_light:

  • the prediction of the action ‘action_movie_db’ in story ‘happy path’ is contradicting with rule(s) ‘’ which predicted action ‘action_listen’.
    Please update your stories and rules so that they don’t contradict each other.

Hello sir, I am Daddy. i am facing an issue while I am excuting my slots.While i am excuting my bot ask for intent , i gave an input to it and it again asks for intent.could you please give suggestion to overcome this problem?

1 Like

From any given dialogue state (what has been said so far), only one particular action can follow. The InvalidRule message appears when you have a story that says one thing, and a rule that says another, so Rasa cannot learn what to do. To give you more help, please post your rules and your story named “happy path”.

@alludaddy Welcome to the forum! Your question seems to be unrelated to the current thread. Can you please post it in a separate thread?