Automated posting to LinkedIn is possible, but what about formatting the post?
I want:
titles of a section to be bold
separation lines between sections
line breaks between paragraphs
etc.
Can this be automated?
My understanding is that the LinkedIn Post editor can deal with unicode which allows for more formatting, but I have not found a way on how to do that in n8n.
Is there a work-around with JavaScript or OpenAI or similar?
First of all, im guessing you already read the documentation of LinkedinAPI.
Bold Text: LinkedInβs API doesnβt support rich text formatting like bold or italics. However, you can simulate bold text using Unicode characters. For instance, the section titles in the example use bold Unicode characters.
Line Breaks: Use \n to insert line breaks between paragraphs or sections.
Section Separators: Incorporate a series of hyphens (--------------------) to create visual separation between sections.
Something like this:
{
"author": "urn:li:person:{personId}",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "π§πΆππΉπ² πΌπ³ π¦π²π°ππΆπΌπ» π’π»π²\n\nContent of the first section.\n\n--------------------\n\nπ§πΆππΉπ² πΌπ³ π¦π²π°ππΆπΌπ» π§ππΌ\n\nContent of the second section."
},
"shareMediaCategory": "NONE"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
Then you choose if you want to sue Linkedin n8n node or a HTTP Request node with linkedin credentials etcβ¦
I used the Code Node to generate a formatted content for the LinkedIn node with the help of ChatGPT. It works well, still I have to find a solution for making the (section) titles bold.
Any feedback is appreciated
const items = $input.all();
let postContent = 'π XYZ NEWS π\n\n';
// Helper function for decorative emphasis around text
function emphasizeText(text) {
return `πΉ ${text.toUpperCase()} πΉ`; // Convert text to uppercase for emphasis
}
// Loop through each item to append the formatted content
items.forEach(item => {
// Emphasize headline
const emphasizedHeadline = emphasizeText(item.json.Headline);
postContent += `${emphasizedHeadline}\n`;
postContent += `${item.json.Summary}\n\n`; // Adding extra line break for clear separation
postContent += `π ${item.json.Link}\n`;
postContent += 'ββββββ\n\n'; // Adding extra line break for clear separation
});
// Add hashtags at the end of the post
postContent += '#API #networkapi #camara #opengateway';
// Return the result with the content formatted with standard newlines
return [
{
json: {
content: postContent
},
},
];