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
- The script gets the latest blog post.
- It prepares a LinkedIn post text and the comment text.
- It posts the blog update to LinkedIn via the
ugcPostsAPI.
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.