Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkedIn Browser Automation

A TypeScript and Playwright-based browser automation project for generating AI-powered LinkedIn content, creating matching visuals, storing generated content locally, and scheduling posts through a browser workflow.

This project is designed for personal content automation, and building a reusable LinkedIn content workflow.


Features

  • AI-powered LinkedIn post generation
  • AI image generation using a style reference
  • Local storage for generated posts and images
  • Weekly post scheduling support
  • Multi-account ChatGPT profile support(Support 5 different account at the same time)
  • Persistent browser profiles for saved login sessions
  • Resume support after failed runs
  • LinkedIn scheduling support
  • Email alerts on automation failure
  • Dry-run mode for safe testing

Tech Stack

  • TypeScript
  • Node.js
  • Playwright
  • ChatGPT browser automation
  • LinkedIn browser automation
  • Local JSON storage
  • Gmail SMTP email alerts

Requirements

Before running this project, make sure the following are installed:

  • Node.js
  • npm
  • Git
  • Playwright browsers

Check Node.js and npm:

node -v
npm -v

Installation

Clone the repository:


Open the project folder:

```bash
cd linkedin-browser-automation

Install dependencies:

npm install

Install Playwright browsers:

npx playwright install

Required Files

The project requires a few local files before running.


1. .env

Create a .env file in the root folder:

.env

Example:

EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_gmail_app_password
EMAIL_TO=receiver_email@gmail.com

These values are used for email failure alerts.

For Gmail, use a Gmail App Password instead of your normal Gmail password.


2. .env.example

Create a .env.example file in the root folder:

.env.example

Example:

EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_gmail_app_password
EMAIL_TO=receiver_email@gmail.com

This file is safe to keep in the repository because it does not contain real credentials.


3. .gitignore

Create a .gitignore file in the root folder:

.gitignore

Recommended content:

node_modules
.env

profiles/
storage/
dist/
build/

*.log
npm-debug.log*
.DS_Store

4. Style Reference Image

Create an assets folder:

assets/

Add your style reference image:

assets/style.jfif

This image is used as the visual style reference for generated LinkedIn images.


Project Structure

linkedin-browser-automation/
│
├── assets/
│   └── style.jfif
│
├── src/
│   ├── browser/
│   ├── chatgpt/
│   ├── config/
│   ├── image-generator/
│   ├── linkedin/
│   ├── notifications/
│   ├── post-generator/
│   ├── prompts/
│   ├── scheduler/
│   ├── services/
│   ├── setup/
│   ├── storage/
│   ├── types/
│   └── main.ts
│
├── .env.example
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md

Local Runtime Folders

The following folders are created locally during usage:

profiles/
storage/

profiles/

Stores local browser sessions for ChatGPT and LinkedIn.

Example:

profiles/chatgpt-1
profiles/chatgpt-2
profiles/linkedin

storage/

Stores generated posts and images.

Example:

storage/posts/posts.json
storage/images/

These folders should not be committed to GitHub.


Configuration

Main configuration is available in:

src/config/constants.ts

Example:

export const POSTS_PER_WEEK =
  7;

export const ACCOUNT_LIMITS =
  [
    5,
    2
  ];

export const ACCOUNT_LOGIN_READY =
  [
    true,
    true,
    false,
    false,
    false
  ];

export const LINKEDIN_PROFILE =
  "./profiles/linkedin";

export const LINKEDIN_AUTO_SCHEDULE =
  true;

export const LINKEDIN_DRY_RUN =
  false;

Configuration Options

POSTS_PER_WEEK

Number of posts to generate for one week.

export const POSTS_PER_WEEK =
  7;

ACCOUNT_LIMITS

Defines how many posts each ChatGPT account should generate.

export const ACCOUNT_LIMITS =
  [
    5,
    2
  ];

Example:

Account 1 = 5 posts
Account 2 = 2 posts
Total = 7 posts

ACCOUNT_LOGIN_READY

Defines which ChatGPT accounts are ready to use.

export const ACCOUNT_LOGIN_READY =
  [
    true,
    true,
    false,
    false,
    false
  ];

Only accounts marked as true are used.


LINKEDIN_AUTO_SCHEDULE

Enables or disables LinkedIn scheduling.

export const LINKEDIN_AUTO_SCHEDULE =
  true;

Set to false if you only want to generate content without scheduling.


LINKEDIN_DRY_RUN

Runs LinkedIn scheduling in test mode.

export const LINKEDIN_DRY_RUN =
  true;

Use true for testing.

Use false for real scheduling.


Available Scripts

The project uses these npm scripts:

{
  "scripts": {
    "dev": "ts-node src/main.ts",
    "login-accounts": "ts-node src/setup/login-accounts.ts",
    "login-linkedin": "ts-node src/setup/login-linkedin.ts",
    "reset-linkedin-status": "ts-node src/setup/reset-linkedin-status.ts"
  }
}

Login Setup

Before running the main automation, login sessions need to be created.

ChatGPT Login

npm run login-accounts

This opens browser profiles for ChatGPT accounts.

Log in manually when required.


LinkedIn Login

npm run login-linkedin

This opens the LinkedIn browser profile.

Log in manually when required.


Running the Project

After setup is complete, run:

npm run dev

This starts the main automation workflow.

Generated data will be saved locally inside:

storage/

Reset LinkedIn Status

To reset local LinkedIn scheduling status, run:

npm run reset-linkedin-status

This is useful during testing when generated posts already exist but scheduling status needs to be cleared.


Output

Generated posts are stored in:

storage/posts/posts.json

Generated images are stored in:

storage/images/

Example post object:

{
  "topic": "AI Productivity",
  "content": "AI is changing how developers build software...\n\n#ArtificialIntelligence #SoftwareEngineering #Programming",
  "status": "linkedin-scheduled",
  "imagePath": "storage/images/post-1.png",
  "scheduledAt": 1783560600000,
  "scheduledDate": "Wednesday, July 8, 2026 at 7:30 PM",
  "linkedinStatus": "scheduled",
  "linkedinError": ""
}

Prompt Customization

Post prompt configuration is located in:

src/prompts/post.prompt.ts

Use this file to customize:

Post topic
Writing style
CTA
Hashtags
Output format

Image prompt configuration is usually created in:

src/services/weekly-generation.service.ts

Search for:

const imagePrompt =

Use this section to customize image generation requirements.


Email Alerts

The project can send email alerts when automation fails.

Required .env values:

EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_gmail_app_password
EMAIL_TO=receiver_email@gmail.com

For Gmail, enable 2-Step Verification and create an App Password.


Testing Recommendation

For safe testing, enable dry-run mode:

export const LINKEDIN_DRY_RUN =
  true;

Then run:

npm run dev

After testing, disable dry run:

export const LINKEDIN_DRY_RUN =
  false;

Then run again:

npm run dev

Troubleshooting

Browser asks for login again

Run login setup again:

npm run login-accounts
npm run login-linkedin

Email alerts are not working

Check:

.env file exists
EMAIL_USER is correct
EMAIL_PASS is a Gmail App Password
EMAIL_TO is correct

Posts are generated but not scheduled

Check these values in src/config/constants.ts:

export const LINKEDIN_AUTO_SCHEDULE =
  true;

export const LINKEDIN_DRY_RUN =
  false;

Playwright browser error

Install Playwright browsers again:

npx playwright install

Dependencies error

Delete node_modules and reinstall:

npm install

Security

Do not commit private or generated files:

.env
profiles/
storage/
node_modules/

These files may contain credentials, browser sessions, generated content, or large dependencies.


License

MIT License

About

A Node.js and TypeScript automation project using Playwright for AI-powered LinkedIn content generation, image creation, and post scheduling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages