Formatting for LinkedIn posts, e.g. bold, line break etc

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?

Emojis seem to be more easy.

  • n8n version: 1.71.2
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): ?
  • Running n8n via (Docker, npm, n8n cloud, desktop app): running via Yunohost based selfhosting
  • Operating system: Debian 12 (I guess)

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

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…

1 Like

Thanks @Fernanda_Silva I have to digest this a bit, especially since I had problems earlier as LinkedIn did not recognize the line break \n.

Have a great end of the year!

1 Like

@Fernanda_Silva

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
    },
  },
];