Compare value with the intent in action.py

Hello,

I have a following line of code in my action.py file:

if tracker.get_slot('answer') == "Yes":
     // some logic...
     return []

If the slot value matches to “Yes”, we perform some action. But the user can input any variant of answer from “Yes”, “Yeah”, “Yes Please”… etc. How can I compare the slot value to intent from nlu.md. For me, the intent looks like:

## intent:boolean_answer_yes
   - yes
   - yeah
   - yep
   - please
   - please do
   - sure
   - indeed
   - of course
   - that sounds good

The condition needs to be like:

if tracker.get_slot('answer') == intent(boolean_answer_yes):
  // some logic...
  return []

Thanks :slight_smile:

You can check for the latest intent like this:

state = tracker.current_state()
intent = state["latest_message"]["intent"]["name"]