June 23, 2026
How to Use n8n: A Practical Example
n8n is a workflow automation tool that connects APIs, schedules jobs, and runs custom logic without building a full backend for every integration. It shines when you need to glue together scraping, AI, databases, and HTTP endpoints — the kind of pipeline that would be tedious to maintain as a cron script.
This article walks through a real production workflow I use for lelianahoy.es: an automated news generator that pulls local stories from external sources, rewrites them with AI, and publishes drafts to the site.
What the workflow does
Every two days at 8am, the workflow:
- Fetches news listings from Levante-EMV (regional press) and the Ajuntament de L'Eliana (town hall)
- Parses and normalizes each item
- Filters out invalid or incomplete entries
- Checks a Google Sheet to skip articles already processed
- For each new item, fetches the full article page, extracts the description, and rewrites it with OpenAI
- Builds a payload and upserts it to the lelianahoy.es API as a draft
- Marks the item as processed and sends a Slack summary when the batch completes
The result: fresh local news drafts land in the admin panel without manual copy-paste from source websites.
The full workflow
Step by step
1. Schedule trigger
The workflow starts with a Schedule Trigger set to run every two days at 8am. n8n handles the cron expression; no separate server cron job is needed.
2. Parallel scraping
Two branches run in parallel:
- HTTP Request → Levante-EMV news for L'Eliana
- HTTP Request → Ajuntament de L'Eliana announcements
Each branch passes through a Code node that parses the HTML and returns a normalized list of items (title, URL, date, source).
3. Filter and deduplicate
A Filter node drops entries missing required fields. Then a Google Sheets node checks whether each item was already processed. Only new stories continue down the pipeline.
Using a spreadsheet as a lightweight state store is simple and debuggable. You can open the sheet and see exactly what ran and when.
4. Batch processing loop
A Split In Batches node processes one article at a time. Inside the loop:
| Step | Node | Purpose |
|---|---|---|
| Fetch detail | HTTP Request | Load the full article page |
| Extract text | Code | Pull the main description from HTML |
| Rewrite | AI Agent + OpenAI | Rewrite in the site's editorial style |
| Parse output | Code | Clean the model response into structured fields |
| Build payload | Set | Map fields to the API schema |
| Publish | HTTP Request | POST to the integration endpoint |
| Mark done | Google Sheets | Record the item as processed |
Processing in batches avoids hammering source sites and makes error handling per-article straightforward.
5. AI rewrite
The AI Agent node calls OpenAI to rewrite the scraped text. The prompt enforces local tone, factual accuracy, and the bilingual structure lelianahoy.es expects (Spanish and Valencian fields where applicable).
This is where RAG-style patterns are not needed: the source article is already in context. The model's job is transformation, not retrieval.
6. API upsert
The final HTTP Request posts to:
POST /api/integrations/news/upsert
Authenticated with a bearer token (EVENTS_API_TOKEN / integration token in production). The payload includes title, summary, content, category, and optional Valencian translations. Articles land as drafts so a human can review before publishing.
7. Slack notification
When the batch loop finishes, a Code node builds a short summary and a Slack node posts it to a channel: how many items were processed, which sources, and any failures.
Why n8n for this?
You could build this as a Python script on a VPS. n8n wins on a few practical points:
- Visual debugging — you see data flow between nodes
- Built-in retries and error branches — per-node error handling without custom code
- Easy credential management — API keys, OAuth, and tokens stored securely
- Fast iteration — change a prompt or parser without redeploying an app
- Scheduling included — no separate cron setup
The trade-off is operational: you need to host n8n (self-hosted or cloud) and treat workflows as production infrastructure.
Lessons learned
- Deduplication is non-negotiable. Without the Google Sheet check, reruns create duplicate drafts.
- Keep AI in the loop, not fully autonomous. Drafts + human review beats publishing raw model output.
- Parse defensively. Source HTML changes; isolate parsing in Code nodes so fixes are localized.
- Notify on completion. A Slack message confirms the job ran — essential when it only fires every two days.
Conclusion
This workflow is a practical pattern for local media, internal newsletters, or any site that aggregates and reframes external content. n8n acts as the orchestration layer: scrape, dedupe, transform with AI, publish via API, and report back.
If you are exploring automation beyond a single cron script, start with one narrow pipeline like this. Get the deduplication and API contract right first; then add AI rewriting once the plumbing is reliable.