Automating LinkedIn posts for my blog - Part 2


Tags: programming, python, linkedin, api, automation

In this post, I explain how I improved my LinkedIn automation script by adding bold/italic formatting and randomized call-to-actions.


View the code here.

Plain text LinkedIn posts looked a bit flat, and could easily be missed in the midst of a doomscrolling session. So I added translation maps for bold, italic, and boldโ€‘italic alphabets using Unicode pseudofonts. I know all you LinkedIn users used a LinkedIn Text Formatter at least once in your lifetime! I basically embedded one in my script. It makes the LinkedIn feed more eyeโ€‘catching and easier to skim.

Before, it would always show the same boring "New blog post is out!" call-to-action without any emojis or formatting or anything. Now that call to action is bold, has an emoji, and is randomized. I also emboldened the "Title:" text and emboldened and randomized the "๐Ÿ‘‰ Read it here:" text to either be "๐Ÿ‘‰ Read it here:" or "๐Ÿ‘‰ Check it out!"

Previously, the posts weren't very clear about whether they were posted by a human or not. I wanted to keep my main post clean, but still be transparent that the LinkedIn posts weren't being posted by a human, so I decided to put a comment under the post. That didn't go so well. So there's now just a note in the post that says:

๐™‰๐™ค๐™ฉ๐™š: ๐˜›๐˜ฉ๐˜ช๐˜ด ๐˜ฑ๐˜ฐ๐˜ด๐˜ต ๐˜ช๐˜ด ๐˜จ๐˜ฆ๐˜ฏ๐˜ฆ๐˜ณ๐˜ข๐˜ต๐˜ฆ๐˜ฅ ๐˜ฃ๐˜บ ๐˜ข ๐˜—๐˜บ๐˜ต๐˜ฉ๐˜ฐ๐˜ฏ ๐˜ด๐˜ค๐˜ณ๐˜ช๐˜ฑ๐˜ต. ๐˜ ๐˜ฐ๐˜ถ ๐˜ค๐˜ข๐˜ฏ ๐˜ง๐˜ช๐˜ฏ๐˜ฅ ๐˜ช๐˜ต ๐˜ฉ๐˜ฆ๐˜ณ๐˜ฆ: https://github.com/tiash-and-cats/tiash-and-cats.github.io/blob/master/.github/scripts/linkedin_share.py. ๐˜๐˜ต ๐˜ด๐˜ช๐˜ฎ๐˜ฑ๐˜ญ๐˜บ ๐˜ค๐˜ฉ๐˜ฆ๐˜ค๐˜ฌ๐˜ด ๐˜ต๐˜ฉ๐˜ฆ ๐˜ญ๐˜ข๐˜ต๐˜ฆ๐˜ด๐˜ต ๐˜ฃ๐˜ญ๐˜ฐ๐˜จ ๐˜ฑ๐˜ฐ๐˜ด๐˜ต ๐˜ข๐˜ฏ๐˜ฅ ๐˜ฑ๐˜ฐ๐˜ด๐˜ต๐˜ด ๐˜ข ๐˜ฏ๐˜ฐ๐˜ต๐˜ช๐˜ง๐˜ช๐˜ค๐˜ข๐˜ต๐˜ช๐˜ฐ๐˜ฏ ๐˜ช๐˜ฏ ๐˜ต๐˜ฉ๐˜ฆ ๐˜ง๐˜ฐ๐˜ณ๐˜ฎ ๐˜ฐ๐˜ง ๐˜ข ๐˜“๐˜ช๐˜ฏ๐˜ฌ๐˜ฆ๐˜ฅ๐˜๐˜ฏ ๐˜ฑ๐˜ฐ๐˜ด๐˜ต. ๐˜›๐˜ฉ๐˜ช๐˜ด ๐˜ฑ๐˜ณ๐˜ฐ๐˜ค๐˜ฆ๐˜ด๐˜ด ๐˜ฅ๐˜ฐ๐˜ฆ๐˜ด ๐˜ฏ๐˜ฐ๐˜ต ๐˜ถ๐˜ด๐˜ฆ ๐˜ˆ๐˜.

That way, anyone curious can see how it works, without cluttering the announcement itself.

How it works

  1. The script gets the latest blog post.
  2. It prepares a LinkedIn post text and the comment text.
  3. It posts the blog update to LinkedIn via the ugcPosts API.

That's it!

What did I learn?

I learnt that LinkedIn's API has multiple endpoints (ugcPosts vs socialActions), and knowing which one to use is key. Formatting with Unicode alphabets is surprisingly fun! And though comments didn't work out, there was still a light at the end of the tunnel.

Now my blog posts show up on LinkedIn with styled text and randomized CTAs.