Telegram does not send messages coming from the sub-agent

Hello guys, I’m facing some challenges with Telegram. When the sub-agent is called, the response is not sent via “Send a text message” Node. I feel the problem is simple, but I haven’t found a solution. By the way, I tried to change the Parse Mode and nothing changed

More info:
The message: Error code

400

Full message

{ "ok": false, "error_code": 400, "description": "Bad Request: chat_id is empty" }

n8n Version

2.21.5


@Ali4, good morning!

The error says that chat_id is empty. Since the response comes from the AI Agent/sub-agent, the expression {{ $(‘Telegram Trigger’).item.json.message.chat.id }} may lose the reference to the original item. I would store the chat.id in its own field, such as sessionId or chatId, right after the Telegram Trigger, and then use that field in the final node: {{ $json.sessionId }}.

I’m already doing this, look at Edit fields Node. Anyway, I tried using different expressions, but the problem persists.

Is the chat.id recorded from the beginning? @Ali4
In the JSON/print of the node Send a text message, the preview of the Chat ID field is empty.
The current item coming from the AI Agent no longer has valid access to the item from the Telegram Trigger