Is it possible to access the tracker of a conversation through a NLU custom component?

Hi there Rasa community,

I’m currently developing a bot using Rasa and I was wondering if it’s possible to access the tracker of a conversation with a custom nlu component?

I already saw the docs and examples for a custom nlu component and saw that the “process” method of the Component Class has a “message” input as argument, so I was wondering if we have access to the tracker through the component?

If it’s not possible, is there a workaround?



I’ve read a PR in the github discussing about putting tracker into the NLU components. I read the Rasa main code and I see that the Agent and Processor class are passing tracker to the Core’s NaturalLanguageInterpreter parse method, but inside that class, the tracker isn’t being passed to the NLU’s Interpreter class and I’m not sure why. I haven’t tried this myself, but one user in the forum is handling it like this: Providing conversation context to the NLU using microservices

Other ways you can do is probably to create custom NaturalLanguageInterpreter and Interpreter class, and pass it to the Agent when you initiate Agent class.

Thanks for your response @tomgun132 , I will definitely check out what you are saying!

@tomgun132 can you please provide the code of this solution? I have created a custom component but I am unable to define Tracker inside any of the implemented methods. I want to access the metadata of the user message through tracer but unable to do it. Please please help

@jsgilberto did this solution work for you ? can u please give me the code for your solution

Hi, I haven’t really worked on that because 1. The training data will be different from standard Rasa NLU format and more similar to Rasa stories instead, 2. Since the sentence that requires context for chatbot might be quite rare, I think for now it’s better to use the end-to-end story instead.

If you still want to do this, as I said, I think you can create custom NaturalLanguageInterpreter and Interpreter class. I think you can pass the tracker here, put the metadata here, and you need to replace agent.interpreter as well.