Social Media Automation: Schedule Posts to Twitter and LinkedIn with n8n and ChatGPT
As a social media manager, your time is precious. Between crafting posts, engaging with followers, and analyzing performance, manually scheduling content can be a drain. Enter n8n and ChatGPT a powerful duo that automates scheduling posts to platforms like Twitter and LinkedIn while generating engaging, tailored captions. This guide is designed for social media managers looking to streamline their workflow, save time, and boost content quality with automation.
Why Automate Social Media Posting?
Automation isn’t just about convenience it’s about working smarter. Here’s why n8n and ChatGPT are game-changers for social media managers:
- Consistency: Schedule posts across multiple platforms without manual effort.
- Engaging Content: Use ChatGPT to create captivating captions that resonate with your audience.
- Time Savings: Focus on strategy and engagement instead of repetitive tasks.
- Scalability: Manage multiple accounts or campaigns effortlessly.
This beginner-friendly guide will show you how to set up an n8n workflow to schedule posts and generate captions using ChatGPT.
What You’ll Need
- n8n Account: Sign up for free at n8n.io or install locally (cloud is easier for beginners).
- OpenAI API Key: Get one from openai.com for ChatGPT access.
- Twitter and/or LinkedIn Accounts: Ensure you have API access or credentials for these platforms.
- Google Sheets (Optional): For organizing post schedules.
Step-by-Step Guide: Automating Social Media Posts
Let’s create a workflow that:
- Pulls post details from a Google Sheet.
- Uses ChatGPT to generate a caption.
- Schedules the post to Twitter and LinkedIn.
Step 1: Set Up n8n
- Create an n8 araya: Log in to n8n.io and click “New Workflow.” Name it, e.g., “Social Media Scheduler.”
- Familiarize Yourself: n8n’s drag-and-drop interface is intuitive, with nodes for each task.
Step 2: Trigger Posts from Google Sheets
Use a Google Sheet to store post details like content, date, and platform.
- Add a Schedule Trigger Node:
- Click “+” and select “Schedule Trigger.”
- Set it to check every hour (or your preferred interval).
- Add a Google Sheets Node:
- Select “Google Sheets” and connect your account via OAuth.
- Choose a spreadsheet with columns like Post Content, Platform (Twitter/LinkedIn), and Post Time.
- Filter for posts where Post Time matches the current time using {{new Date().toISOString()}}.
- Test the node to ensure it pulls the right data.
Step 3: Generate Captions with ChatGPT
Enhance your posts with AI-generated captions.
- Add an HTTP Request Node:
- Set the URL to https://api.openai.com/v1/chat/completions.
- Method: POST.
- Headers: Add Authorization: Bearer YOUR_OPENAI_API_KEY.
- Configure the Request Body:
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a social media expert. Create a concise, engaging caption for a {{node['Google Sheets'].json['Platform']}} post about: {{node['Google Sheets'].json['Post Content']}}. Include relevant hashtags."
}
],
"max_tokens": 100
}
- Test to confirm ChatGPT generates a caption.
Step 4: Post to Twitter
- Add a Twitter Node:
- Select “Twitter” and choose “Create Tweet.”
- Connect your Twitter account via OAuth.
- Configure the Tweet:
- Set “Tweet Text” to:
{{node['Google Sheets'].json['Post Content']}} {{node['HTTP Request'].json['choices'][0]['message']['content']}}
- Add media or links if needed.
- Test the node to post a tweet.
Step 5: Post to LinkedIn
- Add a LinkedIn Node:
- Select “LinkedIn” and choose “Create Post.”
- Connect your LinkedIn account.
- Configure the Post:
- Set “Content” to the same as above.
- Adjust visibility (e.g., public or connections).
- Test the node.
Step 6: Log Activity
Track your posts in a Google Sheet.
- Add another Google Sheets Node:
- Select “Append” and choose your log sheet.
- Map fields like:
- Post Content: {{node['Google Sheets'].json['Post Content']}}
- Caption: {{node['HTTP Request'].json['choices'][0]['message']['content']}}
- Platform: {{node['Google Sheets'].json['Platform']}}
- Timestamp: {{new Date().toISOString()}}
- Test to ensure logging works.
Step 7: Activate the Workflow
- Click “Activate” to run the workflow.
- Test with a sample Google Sheet entry to verify the process.
Example Workflow JSON
Import this into n8n for a quick start:
{
"nodes": [
{
"parameters": {
"triggerTimes": {
"mode": "everyHour"
}
},
"name": "Schedule",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1,
"position": [240, 300]
},
{
"parameters": {
"operation": "read",
"sheetId": "YOUR_SHEET_ID",
"range": "Sheet1",
"filters": {
"conditions": [
{
"key": "Post Time",
"value": "{{new Date().toISOString()}}"
}
]
},
"authentication": "oAuth2"
},
"name": "Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 1,
"position": [460, 300],
"credentials": {
"googleSheetsOAuth2": "Your Google Sheets Credentials"
}
},
{
"parameters": {
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"sendHeaders": true,
"headers": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_OPENAI_API_KEY"
}
]
},
"sendBody": true,
"body": {
"parameters": [
{
"name": "model",
"value": "gpt-3.5-turbo"
},
{
"name": "messages",
"value": [
{
"role": "system",
"content": "You are a social media expert. Create a concise, engaging caption for a {{node['Google Sheets'].json['Platform']}} post about: {{node['Google Sheets'].json['Post Content']}}. Include relevant hashtags."
}
]
},
{
"name": "max Tokens",
"value": 100
}
]
}
},
"name": "ChatGPT",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [680, 300]
},
{
"parameters": {
"operation": "create",
"text": "{{node['Google Sheets'].json['Post Content']}} {{node['ChatGPT'].json['choices'][0]['message']['content']}}",
"authentication": "oAuth1"
},
"name": "Twitter",
"type": "n8n-nodes-base.twitter",
"typeVersion": 1,
"position": [900, 200],
"credentials": {
"twitterOAuth1": "Your Twitter Credentials"
}
},
{
"parameters": {
"operation": "create",
"content": "{{node['Google Sheets'].json['Post Content']}} {{node['ChatGPT'].json['choices'][0]['message']['content']}}",
"visibility": "public",
"authentication": "oAuth2"
},
"name": "LinkedIn",
"type": "n8n-nodes-base.linkedin",
"typeVersion": 1,
"position": [900, 400],
"credentials": {
"linkedinOAuth2": "Your LinkedIn Credentials"
}
},
{
"parameters": {
"operation": "append",
"sheetId": "YOUR_LOG_SHEET_ID",
"range": "Sheet1",
"values": {
"Post Content": "{{node['Google Sheets'].json['Post Content']}}",
"Caption": "{{node['ChatGPT'].json['choices'][0]['message']['content']}}",
"Platform": "{{node['Google Sheets'].json['Platform']}}",
"Timestamp": "{{new Date().toISOString()}}"
},
"authentication": "oAuth2"
},
"name": "Log to Sheets",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 1,
"position": [1100, 300],
"credentials": {
"googleSheetsOAuth2": "Your Google Sheets Credentials"
}
}
],
"connections": {
"Schedule": {
"main": [
[
{
"node": "Google Sheets",
"type": "main",
"index": 0
}
]
]
},
"Google Sheets": {
"main": [
[
{
"node": "ChatGPT",
"type": "main",
"index": 0
}
]
]
},
"ChatGPT": {
"main": [
[
{
"node": "Twitter",
"type": "main",
"index": 0
},
{
"node": "LinkedIn",
"type": "main",
"index": 0
},
{
"node": "Log to Sheets",
"type": "main",
"index": 0
}
]
]
}
}
}
How to Use:
- Copy the JSON.
- Import it via n8n’s “Import Workflow” option.
- Replace YOUR_OPENAI_API_KEY, YOUR_SHEET_ID, YOUR_LOG_SHEET_ID, and credentials with your own.
Tips for Social Media Managers
- Batch Content Creation: Use ChatGPT to generate multiple captions at once for efficiency.
- Brand Voice: Customize ChatGPT’s system prompt to match your client’s tone (e.g., professional, witty, or casual).
- Analytics Integration: Add nodes to pull engagement metrics into Google Sheets for reporting.
- Cost Management: Monitor OpenAI API usage to avoid unexpected costs.
- Explore n8n Integrations: Connect to tools like Canva for automated graphics or Buffer for additional platforms.
Why This Matters
This automation frees you to focus on strategy, community engagement, and analytics. With n8n and ChatGPT, you can manage multiple accounts, maintain a consistent posting schedule, and deliver high-quality content without the grind.
Ready to try it? Head to n8n.io to start automating, and explore OpenAI’s documentation for advanced ChatGPT tips. Share your automation wins in the n8n community!