[Solved]Extracting the current intent from a custom action

Is there a way i can extract the current intent using custom actions.

eg,

*greet

  • action_extract_intent

i would like action_extract_intent to know the current intent is greet , so that i may use it according to my wish . Is it possible ? Help is appreciated :slight_smile:

3 Likes

You can get this in custom actions by using tracker.latest_message['intent'].get('name') :slight_smile:

7 Likes

Thanks works for me :slight_smile:

@nicole do you know how to extract entity value ?

I haven’t used entities much but from the code it looks like you can use next(tracker.get_latest_entity_values("my_entity_name"), None) to extract the latest value of entity my_entity_name.

the given code extract the “my_entity_name” from sentence only.

I want extract the entities of the sentence. I do not know which entity will have to be extracted from. I have to a lot of entities, I do not want to list all of them.

ent = tracker.latest_message['entities']


I want to cook noodles.
output: 

('entity', 
[{u'extractor': u'ner_crf', 
u'confidence': 0.787280111194543,
u'end': 19, 
u'value': u'noodles', 
u'entity':
u'Dish',
u'start': 13
}])

I want to have only the value of entity.

this is not working in rasa now tracker.latest_message[‘intent’].get(‘name’)

error: intent = tracker.latest_message[‘intent’].get(‘text’) ^ SyntaxError: invalid character in identifier

could some one tell me how to get intent value

To get the latest intent name inside a custom action:

intent= tracker.latest_message[‘intent’].get(‘name’)

To extract all entity names:

tracker.latest_message[‘entities’]

1 Like

Thx Nikhilcss97

how does one get just a single entity?

Hi @nicole , instead of intent name, I want training example value. example for greet intent hi, hello, howdy these are the examples right, how can we get that values what ever user enter if he enter hi , I will able to get that hi please help me on that.

Thanks in advance