Personalized AI assistant for Substack 🚀🤖 (JSON)
Turn your latest posts and notes into new ideas with an AI sidekick powered by n8n and ChatGPT
This workflow powers a personalized AI assistant that helps brainstorm newsletter ideas using your own Substack content. It works by:
Listening to messages on Telegram 📲
Using GPT-4.1 🤖 with memory 🧠 for smart, contextual replies
Fetching Substack notes and posts 📰📚
Copy the JSON into n8n, add your OpenAI, Substack, and Telegram API keys 🔑, and you’ll have your own content-focused AI assistant ready to go! 🚀
🤖📚 If this helped you, help someone else. Share the post and let more creators discover how easy it is to build their own AI assistant.
{
“nodes”: [
{
“parameters”: {
“model”: {
“__rl”: true,
“value”: “gpt-4.1”,
“mode”: “list”,
“cachedResultName”: “gpt-4.1”
},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.2,
“position”: [
80,
208
],
“id”: “7b2104f9-cc60-4f6a-9838-eba6bc44778a”,
“name”: “OpenAI Chat Model”,
“credentials”: {
“openAiApi”: {
“id”: “dT0K0OLLepjTBJZR”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“sessionIdType”: “customKey”,
“sessionKey”: “={{ $json.message.chat.id }}”
},
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“typeVersion”: 1.3,
“position”: [
224,
208
],
“id”: “e08ae5f8-17e0-483b-b42f-63967497e125”,
“name”: “Simple Memory”
},
{
“parameters”: {
“promptType”: “define”,
“text”: “={{ $json.message.text }}”,
“options”: {
“systemMessage”: “=You are a helpful personal assistant focused on content creation.\nYour role is to help brainstorm new ideas for upcoming newsletters by reviewing and drawing inspiration from recently published content.\nYou can use the following tools:\n* `Get recent notes`: Fetch the user’s latest notes (default: last 15).\n* `Get recent posts previews`: Retrieve previews of the most recent posts, including their IDs. You use those IDs to fetch complete content of a post if needed.\n* `Get full post by ID`: Fetch the complete content of a specific post, given its ID. You obtain an ID from post preview if needed.\n\nAlways use these tools when helpful to provide context, summaries, and inspiration.\nToday is {{ $now }}.”
}
},
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 2.2,
“position”: [
208,
0
],
“id”: “f6453c5d-a9bb-4131-87cf-d7ec8c47c71f”,
“name”: “Personal Assistant”
},
{
“parameters”: {
“chatId”: “={{ $(’Receive message’).item.json.message.chat.id }}”,
“text”: “={{ $json.output }}”,
“additionalFields”: {}
},
“type”: “n8n-nodes-base.telegram”,
“typeVersion”: 1.2,
“position”: [
1184,
16
],
“id”: “0e12808d-ad2e-4270-8fec-a8cfd76380b8”,
“name”: “Respond to the user”,
“webhookId”: “3f959fc5-bde7-4192-b109-cda3504fda07”,
“credentials”: {
“telegramApi”: {
“id”: “g0ZPqCipP2D23k0A”,
“name”: “Telegram account”
}
}
},
{
“parameters”: {
“updates”: [
“message”
],
“additionalFields”: {}
},
“type”: “n8n-nodes-base.telegramTrigger”,
“typeVersion”: 1.2,
“position”: [
0,
0
],
“id”: “df654210-0d17-4e24-97eb-4d3dd423ee1d”,
“name”: “Receive message”,
“webhookId”: “689ae2dc-bc14-44bf-b304-61015b346234”,
“credentials”: {
“telegramApi”: {
“id”: “g0ZPqCipP2D23k0A”,
“name”: “Telegram account”
}
}
},
{
“parameters”: {
“resource”: “post”,
“operation”: “getPostById”,
“postId”: “={{ /*n8n-auto-generated-fromAI-override*/ $fromAI(’Post_ID’, ``, ‘string’) }}”
},
“type”: “n8n-nodes-substack.substackTool”,
“typeVersion”: 1,
“position”: [
512,
208
],
“id”: “eba5fcbc-d110-433a-ac7a-98dd7c368429”,
“name”: “Get full post by ID”,
“credentials”: {
“substackApi”: {
“id”: “S0ZbGy9f6anXZDSu”,
“name”: “Substack account”
}
}
},
{
“parameters”: {
“resource”: “note”,
“limit”: “={{ /*n8n-auto-generated-fromAI-override*/ $fromAI(’Limit’, ``, ‘number’) }}”
},
“type”: “n8n-nodes-substack.substackTool”,
“typeVersion”: 1,
“position”: [
368,
208
],
“id”: “e5857bc9-4bdf-4d08-acd3-a13dec65cffe”,
“name”: “Get recent notes”,
“credentials”: {
“substackApi”: {
“id”: “S0ZbGy9f6anXZDSu”,
“name”: “Substack account”
}
}
},
{
“parameters”: {
“resource”: “post”,
“limit”: “={{ /*n8n-auto-generated-fromAI-override*/ $fromAI(’Limit’, ``, ‘number’) }}”
},
“type”: “n8n-nodes-substack.substackTool”,
“typeVersion”: 1,
“position”: [
656,
208
],
“id”: “5f4a15ab-a0f6-4c12-b978-843a90f7abf2”,
“name”: “Get recent posts previews”,
“credentials”: {
“substackApi”: {
“id”: “S0ZbGy9f6anXZDSu”,
“name”: “Substack account”
}
}
},
{
“parameters”: {
“jsCode”: “const inputText = $input.first().json.output || \”\”;\nconst lines = inputText.split(\”\\n\”);\n\nlet output = [];\nlet currentChunk = \”\”;\n\nfor (const line of lines) {\n if ((currentChunk + line + \”\\n\”).length > 1000) {\n if (currentChunk) output.push(currentChunk.trim());\n currentChunk = line + \”\\n\”;\n } else {\n currentChunk += line + \”\\n\”;\n }\n}\nif (currentChunk) output.push(currentChunk.trim());\nreturn { output }\n”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
512,
0
],
“id”: “3b35f50c-76f0-49e1-96ea-e9bb7613fcb9”,
“name”: “Code”
},
{
“parameters”: {
“fieldToSplitOut”: “output”,
“options”: {}
},
“type”: “n8n-nodes-base.splitOut”,
“typeVersion”: 1,
“position”: [
768,
0
],
“id”: “ac6aa027-a3e0-41e7-9d0b-ebda59c9c6eb”,
“name”: “Split Out”
},
{
“parameters”: {
“options”: {}
},
“type”: “n8n-nodes-base.splitInBatches”,
“typeVersion”: 3,
“position”: [
960,
0
],
“id”: “faafb54e-f2de-4433-838c-927bb362a7c5”,
“name”: “Loop Over Items”
}
],
“connections”: {
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “Personal Assistant”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Simple Memory”: {
“ai_memory”: [
[
{
“node”: “Personal Assistant”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“Personal Assistant”: {
“main”: [
[
{
“node”: “Code”,
“type”: “main”,
“index”: 0
}
]
]
},
“Respond to the user”: {
“main”: [
[
{
“node”: “Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Receive message”: {
“main”: [
[
{
“node”: “Personal Assistant”,
“type”: “main”,
“index”: 0
}
]
]
},
“Get full post by ID”: {
“ai_tool”: [
[
{
“node”: “Personal Assistant”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“Get recent notes”: {
“ai_tool”: [
[
{
“node”: “Personal Assistant”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“Get recent posts previews”: {
“ai_tool”: [
[
{
“node”: “Personal Assistant”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“Code”: {
“main”: [
[
{
“node”: “Split Out”,
“type”: “main”,
“index”: 0
}
]
]
},
“Split Out”: {
“main”: [
[
{
“node”: “Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Loop Over Items”: {
“main”: [
[],
[
{
“node”: “Respond to the user”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “992ac2542863ba689f62908163525ecb734f9f80532de01b501f2657b08b56c0”
}
}