π¬ Create LinkedIn posts from articles with OpenAI, Pexels and Google Sheets
β‘ 11 views Β· π¬ Content Creation & Video
π‘ Pro Tip β If youβre pulling LinkedIn data through HTTP requests or dealing with API restrictions, thereβs a community node called ScraperNode that handles this natively. It has dedicated scrapers for profiles, companies, jobs, and people search β you just pass a URL and get structured data back.
Description
Quick overview
This workflow runs on a daily schedule, reads a βTO DOβ topic from Google Sheets, uses Tavily and OpenAI to generate a LinkedIn post, finds and selects a matching image from Pexels, uploads the image to LinkedIn, publishes the post, and writes the generated content back to Google Sheets.
How it works
- Runs on a schedule and fetches the first Google Sheets row where the Status column is set to βTO DOβ.
- Searches the web for the rowβs Topic using the Tavily Search API and collects content from the top three results.
- Uses OpenAI (GPT-4) to synthesize the three article excerpts into a single LinkedIn post and outputs JSON containing the post text, an image search query, and image alt text.
- Uses OpenAI to refine the post into a 2β5 keyword visual search query and then searches Pexels for 10 landscape images.
- Uses OpenAI (GPT-4o) to review the 10 Pexels image URLs and select the best match, then extracts the chosen image URL.
- Downloads the selected image, uploads it to LinkedIn via the LinkedIn REST image upload endpoint, and publishes the LinkedIn post with the uploaded image.
- Updates the matching row in Google Sheets with the generated content output.
Setup
- Connect Google Sheets OAuth credentials and ensure your spreadsheet has at least Topic and Status columns, with rows marked βTO DOβ to be picked up.
- Add an OpenAI API credential (GPT-4 and GPT-4o access) for post generation and image selection.
- Add API keys for Tavily Search and Pexels and replace the hard-coded Authorization headers in the HTTP Request nodes.
- Create a LinkedIn app/access token with permission to upload images and post, then set your person URN (YOUR_PERSON_ID), access token (YOUR_ACCESS_TOKEN), and desired visibility.
- (Optional) Connect Google Drive OAuth credentials and set the target folder ID if you want to save the downloaded image to Google Drive.
π Nodes Used
Google Sheets, HTTP Request, Google Drive, LinkedIn, Schedule Trigger, AI Agent
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File