n8n blog automation workflow
# n8n Blog Automation Workflow
**Automatically generate, save, and log blog posts from Telegram messages using AI (Perplexity/OpenAI), Google Drive, Google Docs, and Google Sheets—all orchestrated by [n8n](https://n8n.io).**
---
## Workflow Overview
- **Trigger**: Receive a blog topic via Telegram bot message.
- **Search** (optional): Fetch background info using DuckDuckGo.
- **Write**: Generate a blog post using Perplexity AI (or OpenAI).
- **Save**: Store the blog as a `.txt` file in Google Drive and as a Google Doc.
- **Log**: Record the blog title, timestamp, and Drive link in Google Sheets.
- **Confirm**: Send a success message back to Telegram.
---
## Prerequisites
- **n8n** (local installation via Docker/Podman recommended)
- **Telegram bot** ([BotFather](https://t.me/BotFather))
- **Perplexity AI API key** ([perplexity.ai](https://www.perplexity.ai/account/api/keys)) or **OpenAI API key**
- **Google Cloud Project** with Drive & Sheets APIs enabled (OAuth credentials)
- **Google Sheet template** and **Drive folder** for output
---
## Quick Start
### 1. Run n8n
podman volume create n8n_data
podman run -it --rm
--name n8n
-e NODE_EXTRA_CA_CERTS=/home/node/ca.crt
-p 5678:5678
-v /path/to/your/ca.crt:/home/node/ca.crt
-v n8n_data:/home/node/.n8n
docker.io/n8nio/n8n
Access the n8n UI at `http://localhost:5678`.
---
### 2. Import the Workflow
- Download the workflow JSON:
- **Sample workflow:** [Create-Blog-Telegram-Trigger.json](https://github.com/mandeep111/n8n-telegram-trigger-for-blog/blob/main/Create-Blog-Telegram-Trigger.json)
- Import into n8n: **Add Workflow** → **Import from file**
---
### 3. Configure Nodes
- **Telegram Trigger**: Enter your bot token.
- **Perplexity/OpenAI Node**: Add your API key as a credential.
- **Google Drive & Sheets**: Authenticate with OAuth, set target folder/sheet.
- **Telegram Send**: Set chat ID and bot token for confirmation.
---
### 4. Test the Workflow
- **Activate** the workflow in n8n.
- **Send a message** (e.g., “Python DevOps tools”) to your Telegram bot.
- **Watch** as the blog is generated, saved, logged, and confirmation sent.
**Outputs:**
- **Google Drive**: `your-topic.txt` (blog content)
- **Google Docs**: New doc with blog text
- **Google Sheets**: New row with title, timestamp, and Drive link
- **Telegram**: “Your blog on [topic] is ready and saved to Google Drive!”
---
## Customizing & Extending
- **Change AI Provider**: Swap Perplexity for OpenAI (or another provider).
- **Add Nodes**: Insert Slack/Email notifications, schedule triggers, or add a webhook.
- **Adjust Output**: Save as PDF, HTML, or plain text; modify logging columns.
---
## Troubleshooting
- **Logs**: Check n8n’s execution logs for API/auth errors.
- **Certificates**: If TLS errors occur, ensure your CA cert is mounted correctly or use a trusted registry image.
- **Google Auth**: Double-check OAuth scopes and project settings if authentication fails.
- **AI Limits**: Adjust token limits and retries if content is truncated or rate-limited.
---
## Resources
- **n8n Integrations**: [n8n.io/integrations](https://n8n.io/integrations)
- **Sample Workflow JSON**: [GitHub](https://github.com/mandeep111/n8n-telegram-trigger-for-blog/blob/main/Create-Blog-Telegram-Trigger.json)
- **n8n Docs**: [docs.n8n.io](https://docs.n8n.io)
- **Perplexity AI**: [perplexity.ai](https://www.perplexity.ai)
---
✨ **Start small. Build fast. Automate big.**
*One node at a time.*