If you follow me on Twitter, you’ve likely noticed that my blog posts are automatically tweeted for me. There are multiple services you can use to do this, like Zapier and IFTTT. I use both services for various automations. Each has built-in actions for listening to an RSS feed and then tweeting new items as they appear. Sadly, neither service has a built-in action for Mastodon. However, we can achieve the same results with a generic webhook action on both platforms.
The webhook actions require a bit more manual work to set up, unlike the built-in tweet actions. And you’ll need to do some configuration on your Mastodon account as well. This post will assume an account on mastodon.social, but note that other instances may vary slightly.
Motivation
I’ve found that some folks prefer social media to be notified of blog posts, rather than subscribe via RSS. It’s easy enough for me to automate it, and it allows me to publish content without also having to actually login to Twitter or Mastodon to share it there if I don’t want to. I prefer to avoid Twitter more these days, so having the automation configured there is very nice. Even though I’m enjoying Mastodon, I want to implement automatically posting my RSS feed there too.
Create a Mastodon application
- Navigate to Preferences > Development and create a new application.
- Give it a name. For example, IFTTT.
- Provide the URL. For example, https://ifttt.com.
- Uncheck all scopes except for
write:statuses
. - Copy your access token at the top.
- Save.
Creating a Zap on Zapier to post to Mastodon
For Zapier:
- Create a new Zap.
- Add the “RSS by Zapier” action with “New Item in Feed” as the event.
- Add your feed URL.
- For the next action, choose “Webhooks by Zapier”.
- Set the event to “POST”.
- Set the URL to
https://mastodon.social/api/v1/statuses?access_token=YOUR_ACCESS_TOKEN
. - Payload Type should be “form”.
- For the Data section, enter “status” as the key.
- For the value, select the feed item title and link. (This is the content to be posted.)
- Save and activate!
Unfortunately, using webhooks on Zapier is a premium feature and requires a subscription that costs a minimum of $20/month. I have a free account and paying $240/year just to post a few dozen articles to Mastodon sounds ridiculous to me. Generally, I would be happy to pay for a service like this… but not that much. Luckily, using webhooks on IFTTT is free!
Creating an Applet on IFTTT to post to Mastodon
For IFTTT:
- Create a new Applet.
- Add the “New feed item” RSS action.
- Enter your feed URL.
- Next, add the “Make a web request” webhooks action.
- Set the URL to
https://mastodon.social/api/v1/statuses
. - Set the Method to “POST”.
- Set the Content Type to
application/x-www-form-URLencoded
. - Set Additional Headers to “Authorization: Bearer YOUR_ACCESS_TOKEN”
- Set the body to “status={{EntryTitle}} {{EntryUrl}}”
- Save and activate!
Alternatives
I found another free service, MastoFeed that claims to do this as well. In fact, it is a bespoke web app specifically for posting RSS content to Mastodon. However, you should not use this! MastoFeed requests full read/write permissions for everything — all scopes. However, it only needs the write:statuses
scope. MastoFeed is overzealous with the permissions it requests and there’s no information on the site about who owns or made this. I would avoid it.
For Mastodon, it would also be easy to write your own script using curl
. I might do this and then just run it manually after I run my script to publish a new post. For my set up, I’d have to first parse my feed.json
and grab the most recent item, which should be easy. However, I automatically post from multiple feeds and already had an IFTTT account setup, so I did the lazy thing first.