Perplexity Research to Telegram Article with GPT-4o
This workflow automates the process of conducting research using Perplexity AI, generating a structured article with GPT-4o, and publishing it to a Telegram channel. It's designed for content creators, marketers, or researchers who want to quickly turn a topic into a well-formatted HTML article and share it with an audience.
Nodes Overview
- Manual Trigger — Starts the workflow manually (no auth)
- Error Handler — Stops execution on error with a custom message (no auth)
- Perplexity Topic Agent — AI agent that uses a custom tool to research the user's topic (OpenAI API key auth)
- Call Perplexity Researcher — Custom AI tool that sends a POST request to Perplexity API (HTTP Header Auth with API key)
- Extract JSON — Parses the Perplexity response into structured JSON (no auth)
- Improve Users Topic — GPT-4o-mini model refines the user's topic (OpenAI API key auth)
- If Topic Exists — Checks if a topic was provided; if not, sends an error message (no auth)
- Basic LLM Chain — GPT-4o-mini generates a structured article with category, title, metadata, content, and hashtags (OpenAI API key auth)
- Structured Output Parser1 — Ensures the LLM output matches a predefined JSON schema (no auth)
- Create HTML Article — GPT-4o-mini converts the structured article into a single-line HTML document (OpenAI API key auth)
- If HTML — Checks if HTML content was generated successfully (no auth)
- Telegram2 — Sends the HTML article to a Telegram chat (Telegram Bot API key auth)
- Chat Id — Extracts the Telegram chat ID from the webhook (no auth)
- Webhook — Receives incoming data (no auth)
- Prompts — Stores and manages prompt templates (no auth)
- Contents — Processes article content (no auth)
- Get Topic — Extracts the topic from incoming data (no auth)
- If Article — Checks if an article was generated (no auth)
- Perplexity — Main Perplexity research node (no auth)
- gpt-4o-mini — Various GPT-4o-mini model nodes for different tasks (OpenAI API key auth)
- Execute Workflow Trigger — Triggers another workflow (no auth)
- No Operation, do nothing — Placeholder node (no auth)
Setup Instructions
- OpenAI API Key: Create an account at OpenAI and generate an API key. Add it as a credential in n8n under 'OpenAI API'.
- Perplexity API Key: Sign up at Perplexity AI and obtain an API key. Add it as an 'HTTP Header Auth' credential in n8n with the header name 'Authorization' and value 'Bearer YOUR_API_KEY'.
- Telegram Bot: Create a bot via @BotFather on Telegram, get the bot token, and add it as a 'Telegram API' credential in n8n. Set the chat ID to your target channel or group.
- Environment Variables: Set
BASE_URLin your n8n environment to the Perplexity API endpoint (e.g.,https://api.perplexity.ai).
Use Cases and Variations
- Content Automation: Automatically generate and publish daily research articles on trending topics.
- Newsletter Generation: Adapt the workflow to send HTML articles via email instead of Telegram.
- Multi-Platform Publishing: Add nodes to post to WordPress, Medium, or social media platforms.
- Scheduled Research: Replace the manual trigger with a Schedule Trigger to run daily or weekly.
- Custom LLM Models: Swap GPT-4o-mini for other models like Claude or Gemini by changing the AI node credentials and model name.
Workflow JSON
{
"\"id\"": "\"wokWVLDQUDi0DC7I\",",
"\"meta\"": "{",
"\"instanceId\"": "\"03907a25f048377a8789a4332f28148522ba31ee907fababf704f1d88130b1b6\",",
"\"templateCredsSetupCompleted\"": "true",
"\"name\"": "\"Perplexity\"",
"\"tags\"": "[],",
"\"nodes\"": "[",
"\"type\"": "\"ai_tool\",",
"\"position\"": "[",
"\"parameters\"": "{",
"\"color\"": "3,",
"\"width\"": "420,",
"\"height\"": "340,",
"\"content\"": "\"## Optional\"",
"\"typeVersion\"": "4.2",
"\"model\"": "\"gpt-4o-mini-2024-07-18\",",
"\"options\"": "{},",
"\"responseFormat\"": "\"text\",",
"\"credentials\"": "YOUR_CREDENTIAL_HERE",
"\"openAiApi\"": "{",
"\"topP\"": "1,",
"\"timeout\"": "60000,",
"\"maxTokens\"": "YOUR_TOKEN_HERE",
"\"maxRetries\"": "2,",
"\"temperature\"": "0,",
"\"presencePenalty\"": "0,",
"\"frequencyPenalty\"": "0",
"\"schemaType\"": "\"manual\",",
"\"inputSchema\"": "\"{\\n \\\"type\\\": \\\"object\\\",\\n \\\"properties\\\": {\\n \\\"article\\\": {\\n \\\"type\\\": \\\"object\\\",\\n \\\"required\\\": [\\\"category\\\", \\\"title\\\", \\\"metadata\\\", \\\"content\\\", \\\"hashtags\\\"],\\n \\\"properties\\\": {\\n \\\"category\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Article category\\\"\\n },\\n \\\"title\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Article title\\\"\\n },\\n \\\"metadata\\\": {\\n \\\"type\\\": \\\"object\\\",\\n \\\"properties\\\": {\\n \\\"timePosted\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Time since article was posted\\\"\\n },\\n \\\"author\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Article author name\\\"\\n },\\n \\\"tag\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Article primary tag\\\"\\n }\\n },\\n \\\"required\\\": [\\\"timePosted\\\", \\\"author\\\", \\\"tag\\\"]\\n },\\n \\\"content\\\": {\\n \\\"type\\\": \\\"object\\\",\\n \\\"properties\\\": {\\n \\\"mainText\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Main article content\\\"\\n },\\n \\\"sections\\\": {\\n \\\"type\\\": \\\"array\\\",\\n \\\"items\\\": {\\n \\\"type\\\": \\\"object\\\",\\n \\\"properties\\\": {\\n \\\"title\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Section title\\\"\\n },\\n \\\"text\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Section content\\\"\\n },\\n \\\"quote\\\": {\\n \\\"type\\\": \\\"string\\\",\\n \\\"description\\\": \\\"Blockquote text\\\"\\n }\\n },\\n \\\"required\\\": [\\\"title\\\", \\\"text\\\", \\\"quote\\\"]\\n }\\n }\\n },\\n \\\"required\\\": [\\\"mainText\\\", \\\"sections\\\"]\\n },\\n \\\"hashtags\\\": {\\n \\\"type\\\": \\\"array\\\",\\n \\\"items\\\": {\\n \\\"type\\\": \\\"string\\\"\\n },\\n \\\"description\\\": \\\"Article hashtags\\\"\\n }\\n }\\n }\\n }\\n}\"",
"\"webhookId\"": "\"6a8e3ae7-02ae-4663-a27a-07df448550ab\",",
"\"path\"": "\"pblog\",",
"\"responseMode\"": "\"responseNode\"",
"\"respondWith\"": "\"text\",",
"\"responseBody\"": "\"={{ $json.text }}\"",
"\"text\"": "\"=Convert this verbatim into HTML: {{ $json.article.toJsonString() }}\\n\\n## Formatting Guidelines\\n- HTML document must be single line document without tabs or line breaks\\n- Use proper HTML tags throughout\\n- Do not use these tags: <html> <body> <style> <head>\\n- Use <h1> tag for main title\\n- Use <h2> tags for secondary titles\\n- Structure with <p> tags for paragraphs\\n- Include appropriate spacing\\n- Use <blockquote> for direct quotes\\n- Maintain consistent formatting\\n- Write in clear, professional tone\\n- Break up long paragraphs\\n- Use engaging subheadings\\n- Include transitional phrases\\n\\nThe final JSON response should contain only the title and content fields, with the content including all HTML formatting.\\n{\\n\\t\\\"title\\\": \\\"the title\\\",\\n\\t\\\"content\\\": \\\"the HTML\\\"\\n}\",",
"\"chatId\"": "\"={{ $json.telegram_chat_id }}\",",
"\"additionalFields\"": "{",
"\"parse_mode\"": "\"HTML\",",
"\"appendAttribution\"": "false",
"\"telegramApi\"": "{",
"\"promptType\"": "\"define\"",
"\"conditions\"": "[",
"\"version\"": "2,",
"\"leftValue\"": "\"\",",
"\"caseSensitive\"": "true,",
"\"typeValidation\"": "\"strict\"",
"\"combinator\"": "\"and\",",
"\"operator\"": "{",
"\"operation\"": "\"equals\"",
// ... truncated (copy to see full JSON)How to Import This Workflow
- 1Copy the workflow JSON above using the Copy Workflow JSON button.
- 2Open your n8n instance and go to Workflows.
- 3Click Import from JSON and paste the copied workflow.
Don't have an n8n instance? Start your free trial at n8nautomation.cloud
Related Templates
Automated Blog Post Creation from News with AI and Blogger
This workflow automates the entire process of creating a fully SEO-optimized blog post from a news article. It fetches a trending technology news headline from Mediastack, generates relevant images from Pexels, uses two AI agents (via OpenRouter) to produce a title, slug, meta description, and a complete WordPress-compatible HTML blog post, then posts it directly to Blogger and sends you a Telegram notification. It's perfect for content marketers, bloggers, or anyone who wants to consistently publish fresh, data-driven content without manual effort. Node Breakdown Schedule Trigger (No auth) — Runs the workflow at a set interval (configured every minute by default, but you should change it to daily or hourly). Mediastack News (API Key auth via query parameter) — Fetches the latest technology news article in English from the Mediastack API. Parameters: set to . Genarate image (API Key auth via header, ) — Searches Pexels for up to 2 images related to the news title. Parameters: = , = 2. Send a text message1 (Telegram bot token auth) — Sends a Telegram message with the generated image URLs to the chat ID stored in . AI Agent (Uses OpenRouter Chat Model — API Key auth) — This agent takes the news title and returns a JSON object with three fields: , , and (meta description). The prompt includes strict guidelines for SEO-friendly output. OpenRouter Chat Model (API Key auth) — The language model for the first AI agent, using . Parsing (No auth) — A Code node that cleans the raw AI output (removes markdown code fences) and parses the JSON into usable fields. Copywriter AI Agent (Uses OpenRouter Chat Model2 — API Key auth) — This agent writes a complete 1,000-word SEO blog post in HTML format. It uses the title, meta, and the two images from Pexels. The prompt is very detailed, specifying structure, keyword placement, and styling. OpenRouter Chat Model2 (API Key auth) — Same model as the first, but used for the second agent. Cleanup HTML (No auth) — A Set node that removes any leftover htmlurlhttps://www.googleapis.com/blogger/v3/blogs/$vars.bloggerid/postsPOSThttpQueryAuthAuthorization$vars.telegramchatid$vars.bloggeridbusinesssports`) to match your niche. Multi-language Support — Modify the Mediastack query to fetch news in other languages, and adjust the AI prompts to write in that language. Custom Image Sources — Replace the Pexels node with another image API (e.g., Unsplash) or use a local image generation model. Different CMS — Swap the Blogger HTTP Request node with WordPress or any other CMS API (just change the URL and body format). Human-in-the-Loop — Add a Slack or email approval step before publishing to review the AI-generated content. Newsletter Integration — Instead of posting to a blog, send the formatted content as an email newsletter via Gmail or SendGrid.
AI Blog Generator For WordPress Posts
AI Blog Generator For WordPress Posts This workflow automates the creation of blog post drafts by combining an n8n form, OpenAI's language model, and WordPress. It's designed for content creators, marketers, and bloggers who want to overcome writer's block and streamline their content pipeline. Instead of starting from a blank page, you submit a topic, target audience, and key points through a simple form, and the workflow generates a structured, well-written draft ready for your review and editing in WordPress. The core value of this workflow is its efficiency. It transforms a time-consuming task—writing a first draft—into a quick, structured process. By keeping the output as a 'draft' in WordPress, it ensures that nothing goes live without your final approval, maintaining editorial control. The workflow also includes thoughtful touches like automatic retries for the AI call and clear instructions for troubleshooting, making it robust and user-friendly. Workflow Nodes and Steps Here is a step-by-step breakdown of the workflow: Setup — read me first (Sticky Note) — Provides an overview, setup time, level, and links to the creator's site. How it runs (Sticky Note) — Explains the workflow's logic and data flow. If something breaks (Sticky Note) — Offers guidance on error handling and setting up an error workflow. Draft Request Form (Form Trigger) — This node hosts a web form with fields for 'Topic', 'Audience', and 'Key points (one per line)'. It starts the workflow when the form is submitted. (No auth required for the form itself). Write Draft (OpenAI) — This node uses the model to generate the blog post. It receives the form data and uses a carefully crafted prompt to produce a title and body in HTML format. (API Key auth). Split Title and Body (Code) — A JavaScript code node that parses the AI's response, extracting the title and the HTML body content into separate fields for the next step. (No auth). Create WordPress Draft (WordPress) — This node creates a new post in WordPress with the generated title and content, setting the status to 'draft' so it's not published immediately. (Application Password auth). Setup Instructions To use this workflow, you will need the following: OpenAI Account: You need an API key from OpenAI. Create an account at platform.openai.com, go to the API keys section, and create a new secret key. Add this key to the 'Write Draft' node's credentials. WordPress Site: You need a self-hosted WordPress.org site (not WordPress.com). To connect, you'll need to generate an Application Password. In your WordPress admin dashboard, go to Users > Profile and scroll down to the 'Application Passwords' section. Create a new one and use those credentials in the 'Create WordPress Draft' node. Activate the Workflow: After connecting your credentials, activate the workflow in n8n. The 'Draft Request Form' node will provide a production URL. Bookmark this URL to access your form. Use Cases and Variations Content Calendars: Integrate this with a Google Sheets node to log all generated drafts and their statuses. Multi-Platform Publishing: Add a step to convert the HTML draft to Markdown and send it to other CMSs like Ghost or Dev.to. SEO Optimization: Insert a node to analyze the generated content for keywords or readability scores before creating the WordPress post. Team Collaboration: Instead of a public form, trigger the workflow from a Slack command or email, allowing your team to submit topics without leaving their communication tools. Different Content Types: Modify the prompt in the 'Write Draft' node to generate other content formats like product descriptions, social media posts, or email newsletters.
AI-Powered Unsplash to Pinterest Workflow with RAG
Overview This workflow provides an intelligent pipeline for processing and storing data related to Unsplash images for Pinterest. It uses a Retrieval-Augmented Generation (RAG) architecture to automatically ingest content, generate embeddings, store them in a vector database (Supabase), and then process queries using an AI agent. The workflow is triggered via a webhook, making it suitable for integration with external applications or manual testing. Node-by-Node Breakdown Sticky Note — A visual note for documentation purposes. It displays the title "Automated workflow: Unsplash to Pinterest" on the canvas. No authentication required. Webhook Trigger — Listens for incoming HTTP POST requests at the path . This is the entry point for the workflow. When triggered, it passes the incoming data to the next nodes. (No auth) Text Splitter — Splits incoming text into chunks of 400 characters with a 40-character overlap. This prepares the data for embedding by breaking it into manageable pieces. (No auth) Embeddings (Cohere) — Generates vector embeddings for each text chunk using the model from Cohere. These embeddings represent the semantic meaning of the text. (API Key auth — requires a Cohere API key) Supabase Insert — Inserts the generated embeddings into a Supabase vector store named . This stores the data for later retrieval. (API Key auth — requires Supabase credentials) Supabase Query — Queries the same Supabase vector store () to retrieve relevant vectors based on similarity search. This is used by the RAG agent to find context. (API Key auth — requires Supabase credentials) Vector Tool — Wraps the Supabase vector store as a tool that the AI agent can use to retrieve context. It's labeled "Vector context" for clarity. (No auth — uses the Supabase connection from the previous nodes) Window Memory — Provides a buffer window memory for the AI agent, allowing it to maintain conversation context across multiple interactions. (No auth) Chat Model (OpenAI) — The language model that powers the AI agent. It uses OpenAI's chat model to process queries and generate responses. (API Key auth — requires an OpenAI API key) RAG Agent — The core AI agent that combines the chat model, vector tool, and memory. It processes incoming data with the prompt: "Process the following data for task 'Unsplash to Pinterest':" and includes a system message: "You are an assistant for Unsplash to Pinterest". (No auth — uses connections to other nodes) Append Sheet (Google Sheets) — Appends the AI agent's output to a Google Sheet. It writes to a sheet named "Log" in a document identified by . The column "Status" is populated with the agent's response text. (OAuth2 — requires Google Sheets API credentials) Slack Alert — Sends an error notification to the Slack channel if the RAG Agent encounters an error. The message includes the error details. (OAuth2 — requires Slack API credentials) Setup Instructions To use this workflow, you'll need accounts and API keys for the following services: Cohere: Sign up at cohere.com and generate an API key for the embeddings model. Supabase: Create a project at supabase.com and set up a vector store with the name . You'll need your Supabase URL and service role key. OpenAI: Get an API key from platform.openai.com for the chat model. Google Sheets: Create a Google Sheet with a sheet named "Log" and note the Sheet ID from the URL. Set up OAuth2 credentials in the Google Cloud Console. Slack: Create a Slack app, add it to your workspace, and obtain OAuth tokens. Create a channel named for error notifications. Configure each node's credentials in n8n by clicking on the node and selecting "Add Credential" or selecting existing ones. Use Cases and Variations This workflow is ideal for: Content Curation: Automatically process and store descriptions of Unsplash images for later retrieval and Pinterest posting. Knowledge Base: Build a searchable database of image metadata with semantic search capabilities. Automated Content Moderation: Use the AI agent to analyze image descriptions and flag inappropriate content before posting. Possible Adaptations: Replace the webhook trigger with a Schedule Trigger to run the workflow at regular intervals. Swap the Cohere embeddings with OpenAI embeddings or Hugging Face embeddings. Instead of Google Sheets, output to Airtable, Notion, or PostgreSQL. Add an HTTP Request node after the RAG Agent to post processed data directly to Pinterest's API. Use a different vector store like Pinecone or Qdrant instead of Supabase.