Problem on “Rewrite” agent to feedback new message to user.
Describe the problem/error/question
I build a workflow to connect to Telegram, and AI agent help to generat 60 words story
case:
- User input: e.g A super hero
- AI agent will generate a 60 words story about ‘super hero’
- Then the story will feedback to Telegram to ask user OK, End Process or NOT OK,
- Then Text classifier will split OK, End Process or NOT OK to do different process respectively
- If NOT OK, then Rewrite agent will help to rewrite the story again and feedback to telegram to ask user again
My problem is the Rewrite Agent is able to generate a new story, but when it feeds back to Telegram to ask chat user, it cannot show the new generate story.
How can I fix this problem. I also try to specify {{ $(‘Rewrite’).item.json.output }}, but it seems cannot recognise this node.
Can any body help ?
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and pa{
"nodes": [
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.2,
"position": [
0,
144
],
"id": "317634b8-2116-44d2-af52-43879975b5af",
"name": "Telegram Trigger",
"webhookId": "ea5cd90d-93ad-4d44-83b0-e01b0cf52cc9",
"credentials": {
"telegramApi": {
"id": "1twgKWsg6g1Dtqzn",
"name": "Telegram n8n forida Training"
}
}
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.message.text }}",
"options": {
"systemMessage": "You are a blog writer. Write a 60 words short story based on the user input. Output only the blog content and nothing else.\n"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
224,
144
],
"id": "e7daf30a-c4ae-42bb-bc99-28102bd6cb85",
"name": "AI Agent"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",
"typeVersion": 1,
"position": [
224,
480
],
"id": "6d33cd6d-824f-4df4-ac19-aabb3e1e331d",
"name": "DeepSeek Chat Model",
"credentials": {
"deepSeekApi": {
"id": "ZFjXFjQ2DqoWlQJ7",
"name": "DeepSeek account"
}
}
},
{
"parameters": {
"operation": "sendAndWait",
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"message": "=This is a proposed message by AI, please confirm you OK or NOT OK (Click the \"Response\" button):\n{{ $('AI Agent').item.json.output }}\n\n",
"responseType": "freeText",
"options": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
576,
144
],
"id": "e0f77902-0974-4dc2-a3ad-ea70a44d004b",
"name": "Send message and wait for response",
"webhookId": "9a705097-0021-4c67-b678-b7f1aa7d85e5",
"credentials": {
"telegramApi": {
"id": "1twgKWsg6g1Dtqzn",
"name": "Telegram n8n forida Training"
}
}
},
{
"parameters": {
"inputText": "={{ $json.data.text }}",
"categories": {
"categories": [
{
"category": "true",
"description": "you agree the blog output"
},
{
"category": "end",
"description": "user want to end the process"
},
{
"category": "false",
"description": "user disagree the blog output and want modification"
}
]
},
"options": {
"systemPromptTemplate": "The user is deciding whether to send a blog or not. They will provide you with a decision in the form of text.\n\nPlease classify the text provided by the user into one of the following categories: {categories}, and use the provided formatting instructions below. Don't explain, and only output the json."
}
},
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"typeVersion": 1.1,
"position": [
800,
16
],
"id": "f950fba7-ce26-4dfb-9a69-aa5ec9be699c",
"name": "Text Classifier"
},
{
"parameters": {
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"text": "no problem, AI will send the blog out 👍",
"additionalFields": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1216,
-192
],
"id": "0d146b7f-efce-4e11-8e16-95707c611655",
"name": "AI Blog idea accept by user",
"webhookId": "f0ee3ace-5724-4bc9-8ffc-b14c09453441",
"credentials": {
"telegramApi": {
"id": "1twgKWsg6g1Dtqzn",
"name": "Telegram n8n forida Training"
}
}
},
{
"parameters": {
"chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
"text": "Chat discard 😉",
"additionalFields": {
"appendAttribution": false
}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1216,
0
],
"id": "f0cd84b4-1836-47c7-9411-922b640740ff",
"name": "Chat discard",
"webhookId": "82671f04-8913-4dac-b926-110e587b3261",
"credentials": {
"telegramApi": {
"id": "1twgKWsg6g1Dtqzn",
"name": "Telegram n8n forida Training"
}
}
},
{
"parameters": {
"promptType": "define",
"text": "=AI generated blog:\n {{ $('AI Agent').item.json.output }}\n\nUser request:\n{{ $('Send message and wait for response').item.json.data.text }}",
"options": {
"systemMessage": "You are a reviewer agent. You take the initial AI generated blog and the User request, and update the blog content accordingly\n"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
1152,
240
],
"id": "59b9bdd2-cb97-4fa1-b2d1-c2d4bab033a5",
"name": "Rewrite"
}
],
"connections": {
"Telegram Trigger": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Send message and wait for response",
"type": "main",
"index": 0
}
]
]
},
"DeepSeek Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Text Classifier",
"type": "ai_languageModel",
"index": 0
},
{
"node": "Rewrite",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Send message and wait for response": {
"main": [
[
{
"node": "Text Classifier",
"type": "main",
"index": 0
}
]
]
},
"Text Classifier": {
"main": [
[
{
"node": "AI Blog idea accept by user",
"type": "main",
"index": 0
}
],
[
{
"node": "Chat discard",
"type": "main",
"index": 0
}
],
[
{
"node": "Rewrite",
"type": "main",
"index": 0
}
]
]
},
"Rewrite": {
"main": [
[
{
"node": "Send message and wait for response",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "6a0047fe2b9c895f71f01671e5ed78f15429728631ff5ee2f135076afdde178a"
}
}ste the workflow.)
Share the output returned by the last node
Information on your n8n setup
- n8n version: 2.2.6



