Automating the LinkedIn posts using Generative AI(LLM). Part-2(Post Automation Implementation)

Gathnex
5 min readNov 10, 2023

--

Photo by Alexander Shatov on Unsplash

In the previous article (Part 1), we discussed how to create a LinkedIn access token. In this blog, we will now explore the implementation of automating LinkedIn posts.

Features of this tool

  • Automated content creation: Generate compelling LinkedIn posts based on your intent and provided links.
  • Intelligent posting: Determine the optimal time to post your content for maximum engagement.
  • Content crafting: Automatically craft the best title and description for LinkedIn by accessing the link you provided.
  • Image capturing: Automatically find and include relevant images to accompany your posts.
  • Time-saving efficiency: Streamline your LinkedIn posting process and save valuable time.

Architecture

The LinkedIn automation posting system using Gen AI utilizes a two-pronged approach to handle different types of requests.

Normal Query Flow

For standard queries, the Intent Identification System directs the input to the GPT in the upside. GPT excels at generating text, translating languages, and writing various creative content. It analyses the query and produces a comprehensive and informative response tailored to the user’s request.

Create Content and Post LinkedIn Post with a Link Flow

When a user intends to create content and post it on LinkedIn along with a link, the Intent Identification System takes a different route. It bypasses GPT and directly enters the Intelligent posting System. This path is specifically designed to efficiently process requests involving content creation and LinkedIn posting.

Intelligent posting System module extracts relevant information from the provided link and organizes it into a structured format. This structured data then feeds into the Content Creator module, which crafts a high-quality LinkedIn post based on the extracted information. the Image Capturer module retrieves an appropriate image from the internet to accompany the post.

The above-extracted contents and information have been well formatted and organised. Finally, the formatted post is sent to the LinkedIn API for publishing on the user’s LinkedIn profile.

This streamlined flow ensures that content creation and LinkedIn posting requests are handled efficiently and effectively, saving time and effort for users.

Code implementation

Install our Linkedin_Automation_with_Generative_AI github repo.

!pip install -q git+https://github.com/gathnexadmin/Linkedin_Automation_with_Generative_AI.git

Import the llm_automation and Linkedin_post modules, which contain all pre-written functions and automation to connect to LinkedIn. Set up the OpenAI API and your LinkedIn access token.

To know more about how to create LinkedIn access token checkout previous blog : https://medium.com/@gathnex/automating-the-linkedin-posts-using-generative-ai-llm-part-1-how-to-create-linkedin-api-e5f77fa46e5f

from psi import llm_automation, Linkedin_post

OPENAI_API_KEY = "Your openai key"
access_token = "your linkedin access token"

PSI function

def Gathnex_AI(prompt):
llm = llm_automation.llm_auto(prompt, OPENAI_API_KEY)
if llm.intent_indentifier() == "#Post":
url = llm.prompt_link_capturer()
res = Linkedin_post.LinkedinAutomate(access_token, url, OPENAI_API_KEY).main_func()
return llm.posted_or_not(res)
else:
return llm.normal_gpt()

Time to test our automation system.

Test 1.

Gathnex_AI("explain quantum computing")
#Output
Sure! 🤓 Quantum computing is a fascinating field that aims to use the principles of quantum mechanics to perform computations more efficiently than classical computers. 🚀

In classical computing, data is stored as binary digits called "bits" that can be either 0 or 1. But in quantum computing, information is stored as "qubits," which can exist in a superposition of both 0 and 1 states simultaneously. This allows quantum computers to perform parallel computations on multiple possible solutions at once.

Moreover, quantum computers leverage the concept of "entanglement" which allows qubits to be linked together in a way that the measurement of one qubit instantly determines the state of another, regardless of the distance between them.

These unique properties of qubits and entanglement enable quantum computers to perform certain tasks much faster than classical computers. For example, quantum computers have the potential to solve complex optimization problems, simulate quantum systems, and break certain cryptographic algorithms.

However, it's important to note that quantum computing is still in its early stages and faces significant challenges, such as maintaining the delicate quantum states, minimizing errors, and scaling up the number of qubits. 🧪

Did that help? Let me know if you have more questions! 😊

Test 2.

Gathnex_AI("create content about my new medium blog post https://medium.com/@gathnex/new-generative-ai-course-by-deeplearning-ai-daf34e24e9c8 and post it on my linked")
#Output
Great news! 🎉 Your LinkedIn post has been successfully posted! 🚀 Congrats on sharing your thoughts, ideas, or updates with your network.
🙌 Keep up the fantastic work! 👏 If you need any assistance with anything else, feel free to ask. 😊

Linkedin :

Here, we can see the post is successfully posted on LinkedIn when we explain the prompt clearly.

UI Playground

Now you can easily use this LinkedIn automation tool with a UI by simply entering the OpenAI and LinkedIn access tokens.

Huggingface Space UI Link : https://huggingface.co/spaces/gathnex/Linkedin_Automation

We highly recommend cloning the Hugging Face repository and utilizing this tool.

Conclusion

In this article, we explored how to set up the LinkedIn automation system. If PSI is enhanced with chat history and an intent identification system with multiple specialties, it will yield even better results. Furthermore, we extend an open invitation to individuals who wish to contribute to this community, as their input and contributions are highly valued.

To get more update in AI follow us on LinkedIn : https://www.linkedin.com/company/gathnex/

A special thanks to Gokul Raja R, who made a significant contribution to this project

--

--

Gathnex

🤖 Exploring Generative AI & LLM. Join the Gathnex community for cutting-edge discussions and updates! LinkedIn : https://www.linkedin.com/company/gathnex/ 🌟