1. Opening Problem Statement
Meet Sarah, a content marketer who spends hours each week researching and writing detailed articles based on trending topics her team gathers. She often struggles to keep up with the sheer volume of content needed while maintaining quality and structure. Manually compiling research, formatting articles, and ensuring SEO-friendly content is time-consuming and error-prone, leading to missed deadlines and lost opportunities.
Sarah needs a streamlined solution that can take her raw research topics, gather reliable information, and rapidly output polished, ready-to-publish HTML articles — all without requiring her to code or spend countless hours editing content.
2. What This Automation Does
This Perplexity AI-powered n8n workflow automates the entire content creation process from topic input to fully formatted HTML article output. When triggered, it:
- Accepts a research topic via a webhook or chat input.
- Leverages the Perplexity AI tool node to query the latest, relevant data on the given topic.
- Structures the AI’s response into a detailed article including title, sections, quotes, and hashtags.
- Converts the structured article data into a clean, single-line HTML document formatted with proper headings, paragraphs, and blockquotes.
- Delivers the HTML content as a response ready to be embedded or published on blogs, newsletters, or websites.
This workflow reduces content creation time from hours to minutes, eliminates formatting errors, and ensures consistent, professional output without manual intervention.
3. Prerequisites ⚙️
- n8n account configured and ready to build workflows.
- Perplexity AI tool node configured with an OpenAI GPT API key (to enable the “ai_tool” node).
- Webhook URL or other trigger mechanism to input topic data.
- Basic knowledge of JSON formatting to understand the article schema.
4. Step-by-Step Guide
Step 1: Create the Trigger Webhook Node
Navigate to “Nodes” → “Webhook” → “Create New Webhook”. Configure it to receive HTTP POST requests. Set the path, for example, “pblog”. This webhook will accept incoming topic requests.
After saving, copy the generated webhook URL for use in later testing.
Expected outcome: Your webhook is ready to receive topic data submissions.
Common mistake: Forgetting to set the request method to POST or not saving the webhook node.
Step 2: Add the Perplexity AI Tool Node
Drag the “AI Tool” node onto the canvas. Select the model “gpt-4o-mini-2024-07-18”. In the parameters section, input your OpenAI API credentials in the credentials tab under “OpenAI API”.
Configure the JSON body query to send topic data structured as follows:
{
"model": "llama-3.1-sonar-small-128k-online",
"messages": [
{"role": "system", "content": "Your system prompt here."},
{"role": "user", "content": "{{ $json.text }}"}
],
"max_tokens": 4000,
"temperature": 0.2
}This node will perform the research query and return raw article content in JSON format.
Common mistake: Not providing valid API credentials, resulting in authentication errors.
Step 3: Extract and Structure Article Data
Use a Function or Set node to parse the AI response JSON, ensuring the article object contains mandatory fields: category, title, metadata, content, and hashtags. Your structure should match the workflow’s input schema.
Step 4: Convert Article JSON to HTML
This workflow uses the AI tool node again to convert the structured JSON article to clean HTML. Configure the node to use a prompt like:
=Convert this verbatim into HTML: {{ $json.article.toJsonString() }}
## Formatting Guidelines
- HTML document must be single line document without tabs or line breaks
- Use proper HTML tags throughout
- Use for main title, for sections,
for paragraphs,
for quotes
- Maintain professional tone and consistent formatting
Expected outcome: You receive a single-line HTML string with all article parts properly formatted.
Step 5: Return the HTML Response
Use the ‘Respond to Webhook’ node to output the final HTML article. Configure it to respond with the single-line HTML string from the previous node’s output.
5. Customizations ✏️
- Change AI Model: In the AI Tool node, update the “model” parameter to another version like “gpt-4o” for different text styles.
- Modify Article Schema: Adjust the JSON article structure in the parsing node to include extra metadata fields such as “readingTime” or “authorBio”.
- Trigger Variations: Replace the Webhook trigger with a Telegram node to get topics from chat inputs.
- Output Formats: Extend beyond HTML by adding nodes to also output Markdown or PDF formats.
6. Troubleshooting 🔧
Problem: “Authentication failed for OpenAI API”
Cause: Incorrect or missing API key in credentials.
Solution: Go to the AI Tool node → Credentials → update your OpenAI API key. Test with a simple prompt to confirm connection.
Problem: “Webhook does not receive data”
Cause: Incorrect webhook URL or wrong HTTP method.
Solution: Verify webhook URL is copied correctly and ensure it is set to accept POST requests.
7. Pre-Production Checklist ✅
- Verify OpenAI API credentials in the AI Tool node.
- Test webhook by sending sample JSON topic data via POST.
- Confirm AI response matches expected article schema fields.
- Preview HTML output for formatting correctness.
- Back up workflow before production deployment.
8. Deployment Guide
Activate your workflow by toggling it on in n8n. Share the webhook URL with content requesters or integrate into your CMS to automate article creation.
Monitor executions via n8n’s executions dashboard to troubleshoot or optimize performance.
9. FAQs
Can I use other AI models instead of the one configured?
Yes, you can change the model parameter inside the AI Tool node to other supported models like GPT-4o or GPT-3.5 turbo, depending on your access and needs.
Does this consume OpenAI API credits?
Yes, each AI request uses your OpenAI API credits, so monitor usage to avoid unexpected costs.
Is the output safe to publish directly?
The output is generated text and should be reviewed for accuracy and tone before publishing.
10. Conclusion
By following this tutorial, you have built an advanced content automation workflow in n8n using the Perplexity AI tool node to convert research topics into fully formatted HTML articles quickly and efficiently.
This automation saves hours weekly in manual content crafting and formatting, freeing marketers like Sarah to focus on strategy instead of busywork.
Next steps: integrate a webhook to capture topic requests from social media, add more AI enhancements for SEO optimization, or expand output formats to include PDF newsletters.