How can I get intent_ranking in custom channel?


How can I return intent_ranking from my custom channel? Like below(Copied from http://localhost:5005/model/parse API response sample): { “entities”: [ { “start”: 0, “end”: 0, “value”: “string”, “entity”: “string”, “confidence”: 0 } ], “intent”: { “confidence”: 0.6323, “name”: “greet” }, “intent_ranking”: [ { “confidence”: 0.6323, “name”: “greet” } ], “text”: “Hello!” }

Currently, custom channels like facebook, twilio etc are all returning a list of messages. I’ve seen this: RASA NLU return list of intents in order of confidence . But it need agent object which I don’t know how to obtain from my custom channel either. Or do I need to do more customization other than custom channel?


Sorry, I realized I have asked a stupid question. I’m not familiar with python. Below are the solution which may be helpful for someone like me.

We can get agent by

and then current_state = to get current state of the sender.


Hi Jack,

I am also new to python and I have the same case, could you explain or show me examples of the code to understand your solution.


Hi :smiley:

You need to put this code inside your

Example with default custom connectors

@custom_webhook.route("/webhook", methods=["POST"])
        async def receive(request: Request) -> HTTPResponse:
            sender_id = request.json.get("sender") # method to get sender_id 
            text = request.json.get("text") # method to fetch text
            input_channel = # method to fetch input channel
            metadata = self.get_metadata(request) # method to get metadata
            collector = CollectingOutputChannel()
            current_state =


I tried using this code sample within my custom channel current_state = and I received the following error:

AttributeError: ‘Sanic’ object has no attribute ‘agent’

Any thoughts on why this may be occurring? Thank you!

1 Like

Hello, I am facing the same issue.

Did you bypass that error? can you help please