Opening Problem Statement
Meet Emma, a content marketer juggling multiple blogs on Ghost, who wants to maintain an active, professional LinkedIn presence without spending hours crafting posts manually. Each blog article contains rich insights, but turning that into compelling LinkedIn promotions is repetitive, time-consuming, and prone to inconsistent messaging. Emma wastes nearly 2 hours weekly manually reading blog contents, synthesizing key messages, and typing posts, delaying crucial audience engagement.
This fragmented process not only drains Emma’s time but also risks missing timely promotion opportunities, undermining content marketing impact and professional branding on LinkedIn.
What This Automation Does
This n8n workflow streamlines Emma’s content promotion by automatically transforming her Ghost blog posts into polished LinkedIn messages using advanced AI. Here’s what happens when the automation runs:
- Pulls the latest 3 blog posts directly from a Ghost blog via its API, extracting metadata and content.
- Extracts and cleans the HTML content from the blog posts, producing clear text free of tags and unnecessary spacing.
- Uses an AI Agent node powered by the ChatGPT 4o-mini model to craft targeted LinkedIn posts, including hooks, summaries, and calls-to-action, signed off professionally.
- Combines AI output with original blog meta, linking back to full articles and richer content context.
- Records all generated posts and metadata seamlessly into a Google Sheet for tracking and easy access.
- Loops automatically through multiple posts, ensuring scalable, consistent LinkedIn content generation.
In short, Emma saves hours weekly, consistently generates professional LinkedIn posts linked to her live blog articles, and gains a structured archive for future reference.
Prerequisites ⚙️
- Ghost Blog API credentials to access your blog posts.
- OpenAI API token (or appropriate langchain-compatible chat model credentials), e.g., GPT-4o-mini.
- Google Sheets API credentials for recording posts into your spreadsheet.
- n8n account set up to create and run workflows.
- Optional: Self-hosting your n8n instance for full control (see Hostinger n8n hosting).
Step-by-Step Guide
1. Configure the Manual Trigger Node
Navigate to your n8n editor, click the Manual Trigger node labeled “When clicking ‘Test workflow’”. This node lets you test and manually start the workflow without external triggers. No parameters to set here.
Expected outcome: The workflow activates on manual start.
Common mistake: Forgetting to start workflow execution manually for testing.
2. Set Up the Ghost Node to Extract Blog Posts
Click the Extract Blog Posts Ghost node. In parameters:
- Enter your Ghost API credentials under credentials.
- Set Limit to 3 to fetch the latest 3 posts.
You should see the node ready to pull blog posts. This pulls raw blog content and metadata.
Common mistake: Using invalid or expired Ghost API credentials causes retrieval failure.
3. Extract Post Metadata with Set Node
Select the Extract Post Content node, a Set-type node, which extracts and maps fields like id, title, content, excerpt, featured_image, and link from Ghost’s raw data.
Enter expressions exactly as in this workflow to assign those fields.
Expected outcome: Well-structured JSON output with relevant blog post data.
Common mistake: Incorrect field names or expressions that result in empty or missing data.
4. Batch Processing with SplitInBatches Node
Use the Loop Over Posts node configured as SplitInBatches. It processes each post individually to manage memory and asynchronous calls.
Leave defaults; batch size typically 1.
Expected outcome: Workflow handles posts one by one, preparing for further cleaning.
Common mistake: Setting batch size too high causing node timeouts or API limits.
5. Clean HTML Content using Code Node
Open the Clean HTML node (Code type). This node removes all HTML tags from the blog content and normalizes spaces:
const htmlContent = $input.first().json.content;
const cleanText = htmlContent
.replace(/<[^>]*>/g, '') // remove tags
.replace(/
+/g, ' ') // normalize spaces
.replace(/ /g, ' ') // decode nbsp
.trim();
return [{ json: { clean_content: cleanText } }];
Expected outcome: Cleaned plain text extracted from the HTML content.
Common mistake: Modifying regex incorrectly may strip needed text or keep tags.
6. Merge Clean Text Back with Metadata
The Add Clean HTML node (Merge type) merges the cleaned text back into the original post data ensuring full context for AI processing.
Expected outcome: Records now contain both original and cleaned content.
Common mistake: Setting wrong merge keys or modes breaks output data.
7. Configure the AI Agent Node for LinkedIn Text Generation
The AI Agent node uses the LangChain agent type connected to a Chat Model node:
- Under parameters, the system message instructs the AI to write LinkedIn posts following a structured format: a hook, summary of article value, call-to-action, and a professional sign-off.
- Inputs use expressions that dynamically insert the blog title, link, and cleaned content.
- Model reference points to the OpenAI Chat Model node using the GPT 4o-mini model.
Expected outcome: Engaging LinkedIn post text generated per blog post.
Common mistake: Omitting dynamic expression fields or invalid API keys leading to empty outputs.
8. Combine AI Output and Post Data
The Merge Linkedin node consolidates AI-generated LinkedIn posts with source blog metadata, preparing data for recording.
Expected outcome: Complete dataset ready for Google Sheets insertion.
Common mistake: Incorrect merge configuration leads to partial or no combined output.
9. Append All Results to Google Sheets
Open the Record the posts Google Sheets node:
- Enter your Google Sheets API credentials.
- Choose your target spreadsheet and worksheet.
- Map columns including id, title, cleaned content, original content, excerpt, featured image URL, and generated LinkedIn post.
- Operation set as Append to add new rows.
Expected outcome: New sheet rows with each post’s LinkedIn promotion and metadata.
Common mistake: Incorrect sheet ID or no access permissions causing write failure.
10. Testing and Running Workflow
Click on “Execute Workflow” starting from the manual trigger, observe each node run sequentially, watch for errors in Ghost, AI Agent, and Google Sheets nodes.
Expected outcome: Your Google Sheet fills with fresh LinkedIn post suggestions for your blog entries.
Common mistake: Not checking API limits or permissions on integrated services beforehand.
Customizations ✏️
- Adjust Number of Blog Posts: In the Extract Blog Posts Ghost node, change the Limit parameter to fetch more or fewer posts to match your promotional cadence.
- Customize LinkedIn Post Signature: Modify the systemMessage in the AI Agent node prompt to update author info or tone.
- Include Additional Metadata: Add tags or categories from Ghost posts by enhancing the Extract Post Content Set node outputs and updating Google Sheets mapping accordingly.
- Use Different AI Model: Switch the OpenAI Chat Model node’s model parameter to newer GPT versions or other providers supported by LangChain.
Troubleshooting 🔧
- Problem: “Ghost API returns empty array”
- Cause: Incorrect Ghost API credentials or wrong blog URL.
- Solution: Verify Ghost Admin API key and URL, test with Postman or similar, update node credentials.
- Problem: “AI Agent returns no output or error”
- Cause: Invalid API key, exceeded quota, or misconfigured prompts.
- Solution: Check OpenAI API key, ensure valid LangChain settings, and test prompt syntax carefully.
- Problem: “Google Sheets append fails”
- Cause: Insufficient Google Sheets API permissions or wrong document ID.
- Solution: Reauthorize Google credentials, verify document ID and worksheet name, test write permissions.
Pre-Production Checklist ✅
- Validate all API credentials for Ghost, OpenAI, and Google Sheets.
- Test Ghost API connection separately by retrieving sample blog posts.
- Run the workflow manually and confirm Google Sheets row insertion.
- Review AI Agent output for tone and format correctness.
- Backup important Google Sheets data before large inserts.
Deployment Guide
Once tested, activate your workflow by toggling it from manual to automatic trigger if desired. Monitor initial runs logged in the n8n editor for failures. Set up error notifications within n8n for critical nodes (Ghost, AI Agent, Google Sheets) to ensure smooth ongoing operation.
You can schedule this workflow in n8n or integrate with other triggers to automate LinkedIn post generation continually — perfect for content marketers like Emma.
FAQs
- Q: Can I use Twitter or Facebook instead of LinkedIn?
A: Yes, by changing the AI Agent node’s prompt and updating output handling, you can tailor posts for different social networks.
- Q: Does this use up OpenAI credits?
A: Yes, running the AI Agent consumes API calls charged per usage per your OpenAI plan.
- Q: Is my blog data safe?
A: n8n communicates securely with APIs. Ensure your environment follows best security practices.
- Q: Can this handle hundreds of posts?
A: Yes, but you may need to adjust batch sizes and API rate limits accordingly.
Conclusion
By building this tailored n8n workflow, you’ve automated the tedious task of transforming Ghost blog posts into engaging LinkedIn promotional content. You’ve saved valuable time and guaranteed professional consistency in your social media messaging.
Emma-like professionals can now focus on strategic marketing rather than content repurposing, gaining hours of weekly savings and improved audience connection.
Next steps? Consider adding email alerts for new post promotions, integrating Twitter posting, or expanding to automate multi-channel content marketing campaigns.
Keep experimenting and growing your automation skills — you’re on a powerful path!