Access rasa_nlu custom components from rasa_core


I’ve added custom components to the rasa_nlu pipeline. I’d like to access these components while handling messages in my custom actions classes (in rasa_core), tracker.get_slot() only returns entities recognized by the default NER.

when the parse method is called, my nlu interpreter outputs the following:

{ ‘intent’: {‘name’: ‘random_intent’, ‘confidence’: 0.9103693962097168}, ‘entities’:[{‘start’: random_int, ‘end’: random_int, ‘value’: ‘random_value’, ‘entity’: ‘random_entity_type’, ‘confidence’: 0.5957161849460332, ‘extractor’: ‘ner_crf’}], ‘Component_1’: [‘random_string_1’, ‘random_string_2’], ‘Component_2’: [‘random_string_1’, ‘random_string_2’]}

Unlike entities, the elements of both lists are strings (not dictionaries). I need access to these strings from rasa_core. How is this done?

anyone? @akelad?

Any help would be appreciated

Did you register your custom component? can you check the config.yml in your model folder and see if the custom is there or not.

This is my config file

language: “en”


  • name: “nlp_spacy”
  • name: “tokenizer_spacy”
  • name: “CustomExtractor.KeyWords”
  • name: “CustomExtractor.Regex”
  • name: “CustomExtractor.Crf”
  • name: “intent_featurizer_count_vectors”

“stop_words”: “english”

“min_df”: 0.2

“min_ngram”: 1 “max_ngram”: 3

“max_features”: 100

  • name: “intent_classifier_tensorflow_embedding” intent_tokenization_flag: true intent_split_symbol: “+”

Ok, I understand, your inference pipeline is working fine, you have issues accessing the tracker object

you also have a method to get latest entity as well

Not quite. I’ve just taken another look at the source code. If you go to, the method _handle_message_with_tracker takes arguments (message, and tracker) now in this function, the tracker is updated via tracker.update.

tracker.update(UserUttered(message.text, parse_data[“intent”], parse_data[“entities”], parse_data))

As you can see, only ‘intent’ and ‘entities’ are passed. I haven’t really taken the time to fully conclude how the code in rasa_core actually works, but I’m assuming that my conclusion is right, It’s not possible to access custom components from the tracker as they are never passed to it. Please let me know if you’ve actually managed to access custom components from the tracker. I could be wrong!

for that you need to update the API response of Rasa NLU

in Rasa NLU API it returns the following

  • Intent classification
  • Entity extraction

The API returns these two parts, so all components in your pipeline are typically doing the following

  • Preprocessing
  • Featurization
  • Classification
  • Entity Extraction

so, let’s say if you want Rasa NLU API to return Features as well then you need to update NLU parse API

at the moment, I suppose it returns what was classified using a classifier and what has been extracted using the different entity extraction components (ner_spacy, ner_crf, ner_duckling)

If your custom component let’s say does entity extraction it should return the value in

{ ‘intent’: {‘name’: ‘random_intent’, ‘confidence’: 0.9103693962097168}, ‘entities’:[{‘start’: random_int, ‘end’: random_int, ‘value’: ‘random_value’, ‘entity’: ‘random_entity_type’, ‘confidence’: 0.5957161849460332, ‘extractor’: ‘ner_crf’},{‘start’: random_int, ‘end’: random_int, ‘value’: ‘random_value’, ‘entity’: ‘random_entity_type’, ‘confidence’: 0.5957161849460332, ‘extractor’: ‘your_custom_component’}], }
1 Like

Great one, thanks! I managed to get it to work by passing my data to entities

message.set(“entities”, [{‘keywords’: rasa_format}], add_to_output=True)

i still have to test it with rasa_core but i imagine it will work


Hi Sam, did you test the code ? Did it work?

yes, that was a while back… You can find more information here