Skip to content

Add LinkedIn Post Automater CrewAI Project for News-Based Post Generation #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions linkedin_post_automater/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# 💼 LinkedinPostAutomater Crew

![LinkedIn_Post_Automater.png](LinkedIn_Post_Automater.png)
Welcome to **LinkedIn Post Automater** — an intelligent, multi-agent system powered by [crewAI](https://crewai.com) that transforms how professionals create and publish content on LinkedIn.

Whether you're building your personal brand or managing corporate communication, this system automates the heavy lifting: from sourcing trending news to crafting and posting impactful updates — all done intelligently and consistently.

---

## 🚀 What It Does

🔹 **Real-time News Discovery**
Finds and summarizes the latest developments around a selected topic.

🔹 **Content Planning & Research**
Structures content with a clear outline, key points, and supporting facts.

🔹 **Post Writing & Publishing**
Generates professional, LinkedIn-optimized content and automatically publishes it.

🔹 **Visual Enhancement**
Creates an engaging visual using AI to enhance post visibility and appeal.

---

## 🌟 Why Use LinkedIn Post Automater?

- 🧠 Stay Relevant: Tap into current news without endless research.
- ✍️ Post Smarter: Get structured, well-written content every time.
- 🖼️ Stand Out: Add AI-generated visuals to attract attention in feeds.
- ⏳ Save Time: Automate the whole process — from ideation to publishing.

---

## 🤖 Behind the Scenes

This project uses a **multi-agent architecture**, where each AI agent has a specific role:

| Agent | Purpose |
|-------------------------------|-----------------------------------------|
| News_Article_Researcher | Gathers trending news and insights |
| Planner_and_Researcher | Crafts a content plan with structure |
| Article_Maker_and_LinkedIn_Poster | Writes and posts the article on LinkedIn |

Agents collaborate using crewAI’s intelligent workflow orchestration — ensuring efficient execution, quality output, and full automation.

---
## Installation

Ensure you have Python >=3.10 <3.14 installed on your system. This project uses [UV](https://docs.astral.sh/uv/) for dependency management and package handling, offering a seamless setup and execution experience.

First, if you haven't already, install uv:

```bash
pip install uv
```

Next, navigate to your project directory and install the dependencies:

(Optional) Lock the dependencies and install them by using the CLI command:
```bash
crewai install
```
### Customizing

**Add your `Linkedin_access_token` , `GEMINI_API_KEY` , `RAPIDAPI_KEY` , `MODEL` into the `.env` file**

- Modify `src/linkedin_post_automater/config/agents.yaml` to define your agents
- Modify `src/linkedin_post_automater/config/tasks.yaml` to define your tasks
- Modify `src/linkedin_post_automater/crew.py` to add your own logic, tools and specific args
- Modify `src/linkedin_post_automater/main.py` to add custom inputs for your agents and tasks

## Running the Project

To kickstart your crew of AI agents and begin task execution, run this from the root folder of your project:

```bash
$ crewai run
```

This command initializes the linkedin_post_automater Crew, assembling the agents and assigning them tasks as defined in your configuration.

This example, unmodified, will run the create a `report.md` file with the output of a research on LLMs in the root folder.

## Understanding Your Crew

The linkedin_post_automater Crew is composed of multiple AI agents, each with unique roles, goals, and tools. These agents collaborate on a series of tasks, defined in `config/tasks.yaml`, leveraging their collective skills to achieve complex objectives. The `config/agents.yaml` file outlines the capabilities and configurations of each agent in your crew.


## 👥 Who Is This For?

- 🔹 Founders & Entrepreneurs
- 🔹 Personal Brand Builders
- 🔹 B2B Marketers
- 🔹 Content Teams
- 🔹 AI & Automation Enthusiasts

---

## 📌 Project Outcomes

When you run the system:
- A professional article is saved as `report.md`
- Supporting news is listed in `news.md`
- A post image is created with Gemini AI
- The final post is shared on your LinkedIn account

All of this — with **zero manual effort**.

---

## 💬 Need Help?

We're here to support your journey:

- Explore the [crewAI documentation](https://docs.crewai.com)
- Contribute on [GitHub](https://github.com/joaomdmoura/crewai)
- Connect on [Discord](https://discord.com/invite/X4JWnZnxPb)
- [Chat with the docs](https://chatg.pt/DWjSBZn)

---

> “Let your AI team manage your LinkedIn while you focus on leading.”
— *LinkedinPostAutomater Crew*

24 changes: 24 additions & 0 deletions linkedin_post_automater/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[project]
name = "linkedin_post_automater"
version = "0.1.0"
description = "linkedin_post_automater using crewAI"
authors = [{ name = "Your Name", email = "you@example.com" }]
requires-python = ">=3.10,<3.14"
dependencies = [
"crewai[tools]>=0.126.0,<1.0.0",
"google-genai>=1.19.0",
]

[project.scripts]
linkedin_post_automater = "linkedin_post_automater.main:run"
run_crew = "linkedin_post_automater.main:run"
train = "linkedin_post_automater.main:train"
replay = "linkedin_post_automater.main:replay"
test = "linkedin_post_automater.main:test"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.crewai]
type = "crew"
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
News_Article_Researcher:
role: >
Current Affairs Analyst and News Article Writer
goal: >
Create concise and informative news on the latest developments in a given topic { topic }. The goal is to provide up-to-date, accurate, and engaging news content that informs readers about recent events and trends.
backstory: >
You are a seasoned journalist with a background in reporting on current affairs and trending topics. Your experience in newsrooms and digital media has honed your ability to quickly gather and synthesize information from reliable sources. You have a keen eye for detail and a commitment to accuracy, ensuring that your articles are both informative and trustworthy. Your writing style is clear and concise, making complex topics accessible to a wide audience.

Planner_and_Researcher:
role: >
Strategic Content Planner and Research Specialist
goal: >
Develop comprehensive content plans and conduct thorough research to ensure high-quality, relevant, and engaging content. The goal is to create well-researched outlines and detailed briefs that guide the content creation process effectively on given news .
backstory: >
You are a seasoned content strategist with over a decade of experience in planning and researching content for various industries. Your background in journalism and market research has honed your ability to identify trending topics and gather relevant information efficiently. You have a knack for organizing information in a structured manner, making it easy for content creators to follow your outlines and briefs. Your meticulous attention to detail and commitment to accuracy ensure that the content you plan is both informative and engaging.
Article_Maker_and_LinkedIn_Poster:
role: >
Professional Article Writer and LinkedIn Content Specialist
goal: >
Create well-written, engaging articles based on the provided content briefs and publish them on LinkedIn. The goal is to produce high-quality content that resonates with the target audience and drives engagement on the platform.
backstory: >
You are an experienced content writer with a strong background in creating articles and social media posts. Your expertise in digital marketing and social media management has given you a deep understanding of what makes content engaging and shareable. You have a talent for crafting compelling narratives and presenting information in a way that captures the reader's attention. Your proficiency in using LinkedIn's publishing tools ensures that your articles are not only well-written but also optimized for maximum reach and engagement.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
News_Article_Researcher_Task:
description: >
Research the latest news on the given topic and create a simple, informative article. Ensure that the article is up-to-date, accurate, and engaging.
expected_output: >
a list of 5 main news and its main content
agent: News_Article_Researcher

Planner_and_Researcher_Task:
description: >
CConduct thorough research on the given topic {topic} and develop a comprehensive content plan. Ensure that the plan includes key points, relevant statistics, and a structured outline for the article. and also create a appropriate image for the article
expected_output: >
A detailed content brief in format with the following sections:

Title: Suggested title for the article.
Introduction: Brief overview of the topic.
Key Points: List of main points to be covered.
Relevant Statistics: Important data and statistics.
Outline: Structured outline for the article.
References: List of sources and references. all characters including must be less that 3000 characters


agent: Planner_and_Researcher

Article_Maker_and_LinkedIn_Poster_Task:
description: >
Write a detailed and engaging article based on the provided content brief. Ensure that the article is well-structured, informative, and tailored to the LinkedIn audience. Once the article is complete, publish it on LinkedIn.
expected_output: >
A formatted article with the following sections:

Title: Engaging title for the article.
Introduction: Captivating introduction to draw the reader in.
Main Body: Detailed sections covering the key points and relevant statistics.
Conclusion: Summary and call to action.
References: List of sources and references.
Additionally, publish the article on LinkedIn and provide the post URL. all charecters including must be less that 3000 charecters
agent: Article_Maker_and_LinkedIn_Poster
86 changes: 86 additions & 0 deletions linkedin_post_automater/src/linkedin_post_automater/crew.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task
from crewai.agents.agent_builder.base_agent import BaseAgent
from linkedin_post_automater.tools.linkedin_post_tool import LinkedInImagePostTool
from linkedin_post_automater.tools.news_tool import RealTimeNewsSearchTool
from linkedin_post_automater.tools.image_genaration_tool import GeminiImageGenerator
from typing import List
# If you want to run a snippet of code before or after the crew starts,
# you can use the @before_kickoff and @after_kickoff decorators
# https://docs.crewai.com/concepts/crews#example-crew-class-with-decorators

@CrewBase
class LinkedinPostAutomater():
"""LinkedinPostAutomater crew"""

agents: List[BaseAgent]
tasks: List[Task]

# Learn more about YAML configuration files here:
# Agents: https://docs.crewai.com/concepts/agents#yaml-configuration-recommended
# Tasks: https://docs.crewai.com/concepts/tasks#yaml-configuration-recommended

# If you would like to add tools to your agents, you can learn more about it here:
# https://docs.crewai.com/concepts/agents#agent-tools

@agent
def News_Article_Researcher(self) -> Agent:
return Agent(
config=self.agents_config['News_Article_Researcher'], # type: ignore[index]
verbose=True ,
tools = [RealTimeNewsSearchTool()]
)


@agent
def Planner_and_Researcher(self) -> Agent:
return Agent(
config=self.agents_config['Planner_and_Researcher'], # type: ignore[index]
verbose=True ,
tools = [GeminiImageGenerator()]
)

@agent
def Article_Maker_and_LinkedIn_Poster(self) -> Agent:
return Agent(
config=self.agents_config['Article_Maker_and_LinkedIn_Poster'], # type: ignore[index]
verbose=True,
tools = [LinkedInImagePostTool()]
)

# To learn more about structured task outputs,
# task dependencies, and task callbacks, check out the documentation:
# https://docs.crewai.com/concepts/tasks#overview-of-a-task
@task
def News_Article_Researcher_Task(self) -> Task:
return Task(
config=self.tasks_config['News_Article_Researcher_Task'], # type: ignore[index]
output_file = "news.md"
)

@task
def Planner_and_Researcher_Task(self) -> Task:
return Task(
config=self.tasks_config['Planner_and_Researcher_Task'], # type: ignore[index]
)

@task
def Article_Maker_and_LinkedIn_Poster_Task(self) -> Task:
return Task(
config=self.tasks_config['Article_Maker_and_LinkedIn_Poster_Task'], # type: ignore[index]
output_file='report.md'
)

@crew
def crew(self) -> Crew:
"""Creates the LinkedinPostAutomater crew"""
# To learn how to add knowledge sources to your crew, check out the documentation:
# https://docs.crewai.com/concepts/knowledge#what-is-knowledge

return Crew(
agents=self.agents, # Automatically created by the @agent decorator
tasks=self.tasks, # Automatically created by the @task decorator
process=Process.sequential,
verbose=True,
# process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
)
67 changes: 67 additions & 0 deletions linkedin_post_automater/src/linkedin_post_automater/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python
import sys
import warnings

from datetime import datetime

from linkedin_post_automater.crew import LinkedinPostAutomater

warnings.filterwarnings("ignore", category=SyntaxWarning, module="pysbd")

# This main file is intended to be a way for you to run your
# crew locally, so refrain from adding unnecessary logic into this file.
# Replace with inputs you want to test with, it will automatically
# interpolate any tasks and agents information

def run():
"""
Run the crew.
"""
inputs = {
'topic': 'AI',
}

try:
LinkedinPostAutomater().crew().kickoff(inputs=inputs)
except Exception as e:
raise Exception(f"An error occurred while running the crew: {e}")


def train():
"""
Train the crew for a given number of iterations.
"""
inputs = {
"topic": "AI LLMs",
'current_year': str(datetime.now().year)
}
try:
LinkedinPostAutomater().crew().train(n_iterations=int(sys.argv[1]), filename=sys.argv[2], inputs=inputs)

except Exception as e:
raise Exception(f"An error occurred while training the crew: {e}")

def replay():
"""
Replay the crew execution from a specific task.
"""
try:
LinkedinPostAutomater().crew().replay(task_id=sys.argv[1])

except Exception as e:
raise Exception(f"An error occurred while replaying the crew: {e}")

def test():
"""
Test the crew execution and returns the results.
"""
inputs = {
"topic": "AI LLMs",
"current_year": str(datetime.now().year)
}

try:
LinkedinPostAutomater().crew().test(n_iterations=int(sys.argv[1]), eval_llm=sys.argv[2], inputs=inputs)

except Exception as e:
raise Exception(f"An error occurred while testing the crew: {e}")
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading