Supercharge your Substack: Build a personalized AI assistant in a few clicks ๐๐ค
Turn your latest posts and notes into new ideas with an AI sidekick powered by n8n and ChatGPT
Iโve always loved writing ๐, but lately I was drowning in ideas and struggling to organize my newsletter content. I was reading about n8nโs1 AI capabilities and realized I could automate some of my workflow. n8n even has a Telegram2 AI bot template3 where a LangChain agent talks to GPT-4. Inspired by that, I decided to build a Telegram bot assistant that pulls in my Substack newsletter posts and helps me brainstorm new ideas.
In the beginning, I was just a busy writer turned no-code tinkerer. I set up a Telegram bot (via BotFather4) to send messages to my phone, and got to work wiring up an n8n workflow. It felt amazing to empower myself with code โ I mean no-code! โ to solve my own problem. Peek at this. ๐
Now I have a helper that listens on Telegram, reads my recent Substack notes and posts, summarizes them, and even helps me come up with newsletter ideas. Itโs like having a ๐ค editor-in-chief who knows all my content.
๐ Like where this is going? Subscribe today and join a growing community of creators experimenting with AI workflows. Youโll get step-by-step guides, real examples, and fresh ideas delivered straight to your inbox.
๐๐ ๏ธ What the AI assistant can do
Hereโs a quick overview of what my Telegram AI assistant can do.
Chat on Telegram. It listens for any message I send on Telegram and responds in a friendly chat. Behind the scenes it uses OpenAIโs GPT-4.1 model5 to generate its replies. Because GPT-4.1 is optimized for instruction-following and has a huge context window, it can handle pretty complex prompts.
Fetch Substack Content. It can pull in my latest Substack notes or posts6. In practice, this means I can ask the bot things like โWhat were my last 3 notes about?โ or โShow me a summary of the last post.โ and it will fetch that content for reference.
Summarize and Brainstorm. The agent can summarize a full post when asked for, or brainstorm new content. I prompt it with something like โSummarize my last newsletterโ or โBrainstorm 5 ideas based on these notesโ, and GPT-4.1 generates helpful suggestions. Thanks to the modelโs 1-million-token context window, it can โreadโ entire articles or notes I give it. Itโs also trained to follow instructions, so it knows to output a structured summary or list of ideas.
Remember Chat History. It keeps track of our conversation context using a simple buffer memory. In n8n I attached a Simple Memory to the agent, which โstores the entire conversation historyโ. This means the bot can recall what we talked about earlier in the chat, so brainstorming is more coherent (it knows what we discussed last week, for example).
By combining GPT-4.1 with these tools, my assistant can chat with me, look up my own content from Substack, and help turn my notes into new ideas. Itโs a handy creative partner that keeps me on track with my newsletter.
๐ก Iโve shown you what my AI assistant can do - but what about yours? Imagine building your own version: what features would you add, or what problems would you solve first? Share your thoughts in the comments, Iโd love to exchange ideas with you.
๐๏ธ๐ How the workflow works
The n8n workflow is a chain of connected nodes, each doing one step.
Hereโs a friendly walk-through of each part.
๐ฌ๐ฒ Telegram Trigger node
The Telegram Trigger node is where it all starts.
I connected this node to my Telegram Botโs credentials. Whenever I send a message to the bot, this trigger fires and passes the chat message text to the next node.
Essentially, it says โNew input from Telegram: here is the userโs messageโ, so the workflow knows to react.
๐ฒ Pretty cool, right? If you know someone whoโs struggling with content overload or could use a little AI boost in their daily workflow, share this post with them. It might be exactly the inspiration they need to start building their own assistant.
๐ง ๐ค AI Agent node
Next is the AI Agent node. I set it up as a conversation agent with a custom system prompt that tells it to focus on content brainstorming. Here is the system prompt I have provided.
You are a helpful personal assistant focused on content creation.
Your role is to help brainstorm new ideas for upcoming newsletters by reviewing and drawing inspiration from recently published content.
You can use the following tools:
* `Get recent notes`: Fetch the userโs latest notes (default: last 15).
* `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.
* `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.
Always use these tools when helpful to provide context, summaries, and inspiration.
Today is {{ $now }}.
In n8nโs world, an AI Agent is โan autonomous system that receives data, makes decisions, and acts within its environmentโ. By attaching my own tools to it, I give it power to look up information and craft answers.
OpenAI Chat (GPT-4.1). This chat model node calls OpenAIโs chat completion (using GPT-4.1). It is the โbrainโ of the agent.
Whenever the agent decides it needs to generate text (like an answer or idea list), it uses this node.
Memory Buffer. I added a Simple Memory node. This stores our chat history so the agent can refer back to earlier messages.
In practice, this means if I say โfollowing up on the idea about AI in educationโ, the agent still remembers what we talked about before.
Inside the agent node, I hook up a few Substack Tools. Crucially, I created custom sub-nodes that call the Substack API. These tools let the agent fetch my content.



For example, one tool calls โGet All Postsโ to grab the titles or previews of my most recent articles. Another tool calls โGet Post by IDโ to fetch an entire postโs content. So if I ask โWhatโs in post #123?โ, the agent uses the Substack tool to retrieve that post text and then passes it to the GPT model to summarize or analyze.
Because all these are connected, the agent intelligently decides when to use which tool. For example, if I type โShow me my latest postโ, the agent might call the โGet All Postsโ tool and โGet Post by IDโ under the hood and then display the results. It can even call multiple tools in one answer if needed.
โ๏ธ๐งพ Code Node
After the AI agent generates a response, it might be several hundred words long. I added a Code node next in line to handle splitting.
This node runs a bit of JavaScript that takes the agentโs output text and breaks it into an array of chunks, each under 1000 characters.
const inputText = $input.first().json.output || "";
const lines = inputText.split("\n");
let output = [];
let currentChunk = "";
for (const line of lines) {
if ((currentChunk + line + "\n").length > 1000) {
if (currentChunk) output.push(currentChunk.trim());
currentChunk = line + "\n";
} else {
currentChunk += line + "\n";
}
}
if (currentChunk) output.push(currentChunk.trim());
return { output }
This is necessary because Telegram messages have a character limit and we want to avoid cutting anything off. Think of this node as a smart text buffer: it makes sure each piece is short enough to send.
๐ค The workflow I built connects quite a few moving parts. If something isnโt clear or youโd like me to break down a specific step in more detail, drop a comment below. I check them all and Iโm happy to help troubleshoot or brainstorm improvements together.
๐๐ค Split Out Node
Next, a Split Out node takes that array of text chunks and splits them into separate โitemsโ in n8nโs workflow.
Essentially, if the code node created an array like ["Hello world...", "How are you?", ""], the Split Out node will produce three output items from it (ignoring any empty tail). This sets us up to send each chunk as a separate message.
๐๐ฆ Loop Over Items node
Now I use a Loop Over Items node to handle each chunk one by one. This node goes through each split message in order.
On each loop iteration, it takes the next text chunk and passes it to the Telegram reply node. In n8n terms, this ensures the messages are sent sequentially so nothing gets lost. Itโs basically a loop that says โfor each piece of text, do the next stepโ.
๐ฌ๐ฌ Telegram Reply node
Finally, a Telegram Reply node sends the text chunk back into the Telegram chat. Each loop iteration triggers this node once, so the user (me) sees multiple messages in sequence that together make up the full answer. I configured it to reply in the same chat ID.
Optionally, thereโs a setting to mask or escape any HTML/Markdown (n8nโs docs even mention using a special node to mask HTML syntax for stability ). In practice, this means I get all the parts of the answer delivered one after the other as tidy messages on Telegram.
This covers the main nodes; the flow is: (1) Telegram Trigger โ (2) AI Agent (with tools) โ (3) Code split โ (4) Split Out โ (5) Loop โ (6) Telegram Reply.
Each nodeโs output feeds into the next, so a Telegram message goes in, data flows through the agent tools, and replies come back chunk by chunk.
๐๐ Getting API keys
Before running this workflow, you need API keys/credentials for each service.
OpenAI API key
Go to OpenAI Platform and sign up or log in. In the dashboard, click your account icon and select API keys. Then click Create new secret key to generate a key. Copy that key (you wonโt be able to see it again) and add it as credentials in n8n. This lets the AI Agent node call GPT-4.1 via OpenAIโs API.
Substack credentials
I used unofficial Substack API along with Substack community node for this. To make it work, I had to obtain Substack credentials/API key. This part is a bit tricky, but you can learn how to do it the following post.
Telegram Bot API token
Open the Telegram app and start a chat with @BotFather. Send /newbot
and follow the prompts to name your bot and set its username. BotFather will reply with a message that includes your new botโs API token. (It looks like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
). Copy this token into n8nโs Telegram credentials. Now your workflow can connect to that bot and send/reply to messages.
Each of these steps only takes a few minutes. Once the keys are stored in n8n, my workflow nodes could authenticate to OpenAI, Substack, and Telegram seamlessly.
๐ This guide took a lot of tinkering (and coffee โ) to put together, but I truly believe it can save creators hours of work. If it sparked new ideas for you, please hit Share so others can discover it too - letโs spread the word and help more people build smarter with AI.
โจ๐ Recap
Putting this all together, I ended up with a smart, Telegram-based assistant for my newsletter work. It responds to my messages, knows my recent Substack content, and helps me generate or refine ideas. The AI agent, armed with GPT-4.1 and a memory buffer, can chat naturally and reference past notes. And by chunking outputs for Telegram, nothing gets cut off.
This assistant saves me a ton of time. Instead of manually digging through my Substack or brainstorming alone, I just text the bot: โAny ideas for this weekโs topic?โ or โSummarize my last postโ. Itโs like having a personal AI editor in my pocket. Best of all, since n8n is so flexible, I can keep customizing and extending this workflow. For example, I could add a tool that scrapes RSS feeds, or connect it to Google Sheets to log ideas โ n8n makes it easy to plug in new steps.
I hope this walk-through shows how even no-code/low-code developers can build something awesome. If you have your own newsletter or content pipeline, try adapting this setup. Swap in your Substack (or Medium, or blog RSS), or use a different messaging app โ the pieces will be similar. The key idea is: chain the tools you need in n8n, give an agent a good prompt, and let GPT-4.1 do the heavy lifting.
Happy automating โจ โ and may your content ideas flow freely with a little AI help!
๐ฆโก Want to skip the setup and dive right in?
Grab my exported workflow JSON below - just copy-paste it into your own n8n instance and youโre ready to roll!
โจ If you enjoyed this walk-through and want more practical tutorials, behind-the-scenes experiments, and honest lessons from my own journey, hit Subscribe now. Donโt miss the next post - your future AI assistant might be just one click away.