AI-Powered Newsletter Agent with n8n
Automation meets editorial judgment: this post walks through a production-ready n8n workflow that curates, writes, and packages an AI-focused newsletter using LLMs, content ingestion, and approval loops. Whether you want a daily digest or a weekly briefing, this architecture takes raw markdown and social content, selects the top stories, writes Axios-like segments, and outputs a ready-to-send newsletter.
Why build an AI-driven newsletter agent?
Producing consistent, high-quality newsletter content is time-consuming. An AI-driven pipeline reduces manual overhead while preserving editorial control. Benefits include:
- Faster story discovery and selection from many sources
- Consistent tone and structure for each segment
- Integrated approvals and subject-line optimization
- Traceable content provenance (identifiers, source links)
High-level architecture
The workflow in the screenshot is organized into a few clear stages. Below is a concise mapping of these stages to nodes you’ll find in the n8n flow.
1. Ingest
Inputs come from two main places: markdown files (content pipeline) and social posts (tweets/X). A form trigger starts the run with a target date and optional previous newsletter content to avoid duplicates.
- search_markdown_objects + S3 download: find content for the date and fetch objects from the “data-ingestion” bucket.
- search_tweets + extract_tweets: gather relevant social posts for the same date.
2. Filter & prepare
Only process items relevant to the newsletter: filter out non-markdown, exclude newsletters and non-target types, extract text from files, and prepare each content item with metadata (identifier, source, authors, external-source-urls).
3. Select top stories (LLM-assisted)
The workflow uses LLM chain nodes (LangChain-style connectors) to read aggregated content and select the best four stories. This step produces:
- top_selected_stories (a structured object)
- top_selected_stories_chain_of_thought (editorial reasoning)
The chain-of-thought output is shared to Slack for transparent editorial review before writing.
4. Expand and write sections
Each chosen story is iterated in a batch loop. For every story, the agent:
- resolves identifiers and downloads the source text
- aggregates any external source URLs or scraped pages
- calls an LLM to produce a newsletter segment following a strict format (The Recap: recap, Unpacked bullets, Bottom line)
Output is structured and aggregated into story sections for the final newsletter assembly.
5. Intro, subject-line, and shortlist
Separate LLM prompts generate:
- the intro section (greeting, 2 quick paragraphs, transition phrase, and a short list of topics)
- subject-line and pre-header options (with a reasoning block for editors)
- the Shortlist: short summaries of other notable stories that didn’t make the top four
6. Approvals and final packaging
Slack nodes collect reviewer approval or feedback. When approved, the workflow compiles the markdown newsletter, converts it to a file, uploads it to Slack (or CMS), and posts a finished message with the newsletter permalink.
Key nodes and their role
- formTrigger / set_input — kickoff and top-level inputs (date and previous newsletter content)
- S3 / R2 nodes — search and download source artifacts (markdown, tweets)
- extractFromFile — extract text from binary objects
- Filter — remove non-md objects and exclude newsletters
- LangChain / LLM chain nodes — story selection, writing segments, intros, subject lines
- splitInBatches / iterate — process each story and each content identifier safely
- HTTPRequest — fetch metadata and file info from internal APIs
- Slack sendAndWait — request approvals with an inline response button
- convertToFile / upload file — produce the final .md and push to Slack/CMS
Content rules & editorial guardrails
This template embeds a set of strict writing and linking instructions in the LLM prompts so outputs follow a consistent voice and legal/accuracy rules:
- Fixed structure for each segment: The Recap, Unpacked (3 bullets), Bottom line (2 sentences)
- Linking rules: only include URLs present in the provided sources and use verbatim copy of those URLs
- Blacklists for words/phrases to avoid over-hype or jargon
- Requirements for chain-of-thought and source identifiers for traceability
Best practices for production readiness
1. Cost control for LLM usage
Batch and cache LLM calls. Use smaller or fine-tuned models for routine tasks (short summaries) and reserve larger models for creative prompts like subject-line brainstorming.
2. Data provenance and compliance
Keep identifiers and source URLs attached to each segment. Store all aggregated inputs and LLM outputs for audits and dispute resolution. If handling PII or copyrighted snippets, ensure legal review and redaction rules.
3. Security and secrets
Use n8n credentials and environment-specific secrets for S3/R2, internal admin APIs, and LLM keys. Apply least privilege to API keys and rotate regularly.
4. Rate limiting & retries
Enable exponential backoff on external HTTP requests (scraping, downloading) and configure node-level retries on transient failures. Filter bad or empty results early to avoid wasted LLM calls.
5. Editorial workflow & approvals
Always surface the chain-of-thought and subject-line reasoning to Slack so editors can approve or provide feedback. When an edit is requested, a separate edit node enforces that only the requested piece (subject line, a story, etc.) changes without mutating other metadata.
Scaling and monitoring
- Instrument the flow: add logging nodes to record run times, LLM token use, and API latencies.
- Use a queuing layer (e.g., Redis) if multiple newsletter builds are requested concurrently to avoid throttling S3 or LLM APIs.
- Partition ingestion by date and source to parallelize downloads safely using splitInBatches.
Troubleshooting tips
- No content found for date — check the S3 prefix and confirm ingestion jobs wrote objects with the expected date-based prefix.
- LLM outputs inconsistent — add stricter prompt examples and use an output-parser node (structured schema) so malformed outputs are flagged and reprocessed.
- Broken links in sources — adhere to the rule: if a URL is incomplete in source, copy verbatim but surface the problem to editors for manual correction.
How to get started with this template
- Clone the n8n workflow and import it into your instance.
- Provision credentials for S3/R2, internal admin API, Slack, and your LLM provider.
- Run a dry-run for a sample date and verify each node’s output (downloaded content, LLM selections, Slack messages).
- Iterate on prompts: start conservative, then loosen constraints as you gain confidence in output quality.
Wrap-up
This n8n-based newsletter agent provides a traceable, auditable, and scalable way to produce consistent AI-focused newsletters. It combines automated content discovery with human approvals and strict LLM prompt controls to balance speed with editorial quality.
Call to action: Want the workflow JSON and starter prompts? Download the template or request a walkthrough and I’ll help you adapt it to your editorial needs.