Triggering a custom action for a particular intent

I am using rasa 1.4.3 and was wondering if this version or any other version has the functionality to insert triggers: custom_action for a certain intent inside domain file.

Yes, this functionality is described here: Policies

1 Like

Thank you very much. Moreover, I will like to explain my situation. I have an intent called “affirm” which basically captures the text like “Ok”, “Yes”, “Sure”. so, I have a story like:

Story: 1

- utter_affirm_response

In addition to that, I have a few specific tasks such as asking about a meeting schedule of a certain person. If a user asks for a meeting schedule of a person say “Sharmila Upadhyaya” and user asks: What is meeting schedule for “Sarmila Upadhyaya” (which is the slightly wrong spelling), then my custom component will detect the word and asks “Do you mean Sharmila Upadhyaya”. In such case.

Story 2:

* meeting{"autocorrect_user":"abc"}
- utter_doyoumean
* affirm
- action_meeting

So I have these sorts of multiple examples. However, every time bot asks do you mean Sharmila Upadhyaya and user response yes(which is intent: affirm), rasa responses with utter_affirm_response, instead of action_meeting. My config file looks like this:

  - name: "autocorrect_entity.AutocorrectNouns"
  - name: "SpacyNLP"
  - name: "SpacyTokenizer"
  - name: "SpacyFeaturizer"
  - name: "RegexFeaturizer"
  - name: "CRFEntityExtractor"
  - name: "SpacyEntityExtractor"
  - name: "EntitySynonymMapper"
  - name: "SklearnIntentClassifier"

  - name: KerasPolicy
    max_history: 5
  - name: AugmentedMemoizationPolicy
    max_history: 5
  - name: MappingPolicy
  - name: "FallbackPolicy"
    nlu_threshold: 0.009
    core_threshold: 0.009
    ambiguity_threshold: 0.01
    fallback_action_name: "action_default_fallback"

What might be the problem? I also tried modifying Story 2 as:

Story 2:

* meeting{"autocorrect_user":"abc"}
- action_some_simple
- utter_doyoumean
* affirm 
  - slot{"autocorrect_user":"abc"}
- action_meeting.

But no luck.

@sarmilaupadhyaya have you tried running rasa test against your stories with your trained model to see if there’s any conflicting stories?

I did it, there are no conflicts. I am trying ways. One of which is to set a slot value to true or false whenever the autocorrection situation is rased. Like: do you mean sharmila? then, slot “autocorrect” will be true by calling a action.

However, I was confused between the difference of slot usage in the story.

story 1

  • affirm{“autocorrect”: true}


story 2

  • affirm
  • slot{“autocorrect”: true}

I used to think the Story 1 “autocorrect” means slot but not set inside the action. Can you clarify? I feel like I am too impatient to read the documentation.

in story 1, that means that the user message contains an entity. in story 2, it means a slot was set. Slots can be set either by an entity in a user message, or a custom action. That being said, if in story 2, there was no entity in the user message, then it’s not a valid story. A custom action would have had to set it, so maybe that’s the issue

1 Like

Yes, so if I set some default slot value say “autocorrect”: false and then use it in story, will it not work??

No that won’t work. It may actually make sense to have the autocorrect happen in a custom action if that’s how you want to use it.