This project automates the process of posting to LinkedIn using n8n, while also tracking posts in Google Sheets, generating CSV reports, uploading them to Google Drive, and sending email notifications on success or failure.
This automation reads post descriptions from a Google Sheet and goes through the following steps:
- π Reads unposted content from Google Sheets.
- π€ Uses Gemini-2.5-flash model to generate detailed LinkedIn post content based on the short description.
- π€ Posts the content to LinkedIn via LinkedIn API.
- β Updates the post status in Google Sheets as "Posted".
- π§ Sends a success or failure email notification after each attempt.
- π Generates a structured
.csvreport containing the post description, URN, and timestamp. - βοΈ Uploads that report to Google Drive as a binary file.
This is ideal for marketing teams, personal brand builders, or agencies who want to semi-automate their content distribution via LinkedIn.
- Read & filter posts from Google Sheets
- AI content generation based on short description
- LinkedIn post publishing
- Real-time post status updates
- Success & failure email alerts
- Structured
.csvreporting - Google Drive integration for report storage
- Error handling with conditional logic
- Fully modular & reusable workflow
Before running this workflow, ensure you have the following:
- Google Sheets (OAuth2 or service account)
- Google Drive access
- LinkedIn Developer Account
- With access token and proper API permissions
- Email SMTP credentials
- (Optional) OpenAI / Claude / Gemini API Key for AI content generation
π§© Step 1: Clone the Repository
git clone https://github.com/tanishra/Linkedin-Post_Automation.git
cd n8n-linkedin-automationπ§© Step 2: Import the Workflow into n8n
- Open your n8n instance
- Click Import using file
- Upload workflow/Linkedin_Post_Automation.json
π§© Step 3: Configure Credentials
- Set up these credentials in n8n:
- Google Sheets
- Google Drive
- LinkedIn API
- Email (SMTP or OAuth2)
- AI Provider (if applicable)
π§© Step 4: Customize Google Sheet
- Prepare your sheet with at least these columns: Post Description URLs Post Status
π§© Step 5: Run the Workflow You can:
- Run it manually from the editor
- Or set it on a schedule trigger to run daily
-
If a post fails (e.g. invalid token, expired credentials, network error), the workflow will:
- Send a failure email to your configured email address
- Do not update the
post_statusin Google Sheets
-
If the post is successful, the workflow will:
- Update the
post_statusin the sheet to"Posted" - Generate a
.csvreport and upload it to Google Drive
- Update the
To allow n8n to post to LinkedIn on your behalf, you need to create a LinkedIn Developer App and configure authentication.
- Go to LinkedIn Pages
- Choose a type (e.g., Small business or Community page)
- Fill in the required fields like:
- Page name
- Website
- Industry
- Logo and tagline
- Click Create Page
You must be an admin of the page to post via the API.
- Go to LinkedIn Developers Portal
- Click Create App
- Fill in:
- App name
- LinkedIn page you created
- Business email
- App logo (optional)
- Agree to terms and click Create App
- Go to your app settings
- Under "Auth", youβll find:
- Client ID
- Client Secret
- Copy both β youβll need them for n8n
Youβll use these in an OAuth2 credential in n8n.
- Add Redirect URL:
For local n8n:http://localhost:5678/rest/oauth2-credential/callback
Go to the "Products" tab and request access to:
- Sign In with LinkedIn
- Share on LinkedIn
After approval:
- Add these scopes in your credential config in n8n:
r_liteprofilew_member_social
- Go to n8n β Credentials β Create New
- Select OAuth2 API
- Fill in:
- Auth URL:
https://www.linkedin.com/oauth/v2/authorization - Access Token URL:
https://www.linkedin.com/oauth/v2/accessToken - Client ID: (from your app)
- Client Secret: (from your app)
- Scope:
r_liteprofile w_member_social - Token Type:
Bearer - Redirect URI: as provided by n8n
- Auth URL:
- Save and click "Connect" to authorize
π Once connected, you can use this credential in your LinkedIn node to post content.
Contributions are welcome! Here's how:
- Fork the repo
- Create a feature branch
- Make your changes
- Submit a PR with a clear description
