We all know LinkedIn. And we all know that, sometimes, it’s very difficult to come up with engaging and quality content to share with the community.
But … what if we try to use crewAI to help us in these situations?
Well, just to let you know, I’ve already tried it, and, even if I don’t use it for my content creation (sorry, I’m not an agent … yet 😅), it’s a great experiment that works reasonably well. In this article, I’ll show you the process I followed.
If you prefer to go directly into the code, there’s a GitHub repo available!!
Understanding the Crew
I know you’re probably eager to jump straight into the code section and start putting this system into practice … but remember: patience is key.
So, before we jump into the hands-on part, let’s take a moment to understand how this system works. Start by checking out the diagram above—it gives you a detailed view of the project architecture.
After taking a close look, one thing becomes obvious: we need 3 agents.
We need one agent (LinkedIn Scraper Agent) in charge of scraping my LinkedIn profile. Why? Because I want the generated post to follow my writing style. The agent will interact with LinkedIn using a custom tool I’ve created, that wraps Selenium (more on this later).
We also need another agent (Web Researcher Agent), for fetching relevant information about a given topic. This agent is able to use the SerperDevTool and the ScrapeWebsiteTool, both available as native CrewAI tools.
Finally, the last agent (LinkedIn Influencer Agent), will gather all the information provided by the previous agents and will generate a LinkedIn post. Ideally, it should be a LinkedIn post about the topic I chose, that closely mimics my writing style.
Now that you know my general approach, let’s get into the code! 👇
Selenium Tool: Scraping my LinkedIn profile
This is probably the trickiest part of the application, since you need to know a little bit about what is Selenium and how it works. What my custom tool does is to log into my LinkedIn account (using my email and password, stored in a .env
file) and parse relevant posts from my feed.
When this Tool is called by the LLM, the response will contain a list of my latest posts (I limited the number to two for this project, but you can change that), that the influencer agent will use to get my writing style.
First Agent: LinkedIn Scraper Ninja 🥷
As I said before, the first agent will be using the Selenium tool to scrape some of my LinkedIn posts. The implementation is pretty straightforward:
Second Agent: Web Researcher 🧑🔬
This is even easier to implement than the previous one, since we don’t need any custom tool. We are going to ask the agent to search for some key differences between Llama 2 and Llama 3 - put any topic that you want.
Third Agent: Your Doppelgänger
This agent has to deal with the information gathered by the two previous agents and write a high quality and engaging LinkedIn post about the differences between Llama 2 and Llama 3. Additionally, the LinkedIn post must follow my writing style (I don’t want the typical ChatGPT robotic style 😂). As you can see, I’ve chosen a Mistral model for this agent.
Defining the Tasks
I’ve defined the following tasks. Not much comment about them, since they are pretty self-explanatory …
Building the Crew
Ok, we’re almost done! Let’s define the crew now.
And … let’s kick it off!!!
crew.kickoff()
Want to see the results? Check the full video here!
See you next Wednesday!! 👋
. I love mistral than chatgpt for such tasks too but I'm learning more on MAS currently , finding your post insightful , thanks for the writeup