Lately I’ve been interested in using Mastodon as a social media platform. In previous efforts I used the ActivityPub plugin to automatically push new posts to Mastodon, but unfortunately this came with a lot of limitations.

I’ve now setup a new integration which uses some additional tools (Directus and n8n) to help with this process. The below provides a quick run-through of the process and explanation of this approach.


Directus provides a quick way of creating an API around data models. They offer a free cloud version which is perfect for this small-scale integration. It can also be self-hosted in a number of ways, including using Docker which makes it very easy to setup.

Note that you don’t necessarily need Directus – you could use a database (e.g. MySQL) and replace the n8n API calls with database queries instead.

n8n (nodemation) is a powerful automation tool similar to Zapier or Logic Apps. You can build workflows to help you achieve complicated processes using simple building blocks. This also has a Cloud version (paid) or a self-hosted version.

Using the above means that I have far more control over what is going out to Mastodon, and can easily be expand to cover additional platforms e.g. Telegram, Slack or Teams.

  • messages can be customised to your liking
  • messages can be deleted if a post is updated, and you can resubmit
  • you use your own Mastodon account so your profile can be managed fully

The Process

  1. In Directus create a Collection called ‘rss_feed_items’ with a field called ‘guid’. This is used to track posts which have already been sent to Mastodon to prevent duplicates
  2. In n8n, use a Schedule trigger to run every 5 minutes or so
  3. Use the RSS block to fetch the RSS feed for your WordPress blog
  4. Use the HTTP block to get a list of existing guids from the Directus API
  5. Use the Merge block to keep only new blog posts
  6. Use a Code block to prepare the message for Mastodon i.e. get the title, link and convert the categories to hashtags
  7. Use the Mastodon block to post the message to Mastodon. This is a third-party block at the moment.
  8. Use the HTTP block to call the Directus API and create a record for the guid of the blog post

Using this method, if a blog post is updated, I can just edit my post on Mastodon. It could actually be made more sophisticated by keeping the Mastodon status ID and Mastodon post content in Directus with the GUID, and then if the new content is different to the old n8n can delete the old post and create a new post for you.

Note that on the first run, it will send all the posts that appear on your current RSS feed to Mastodon.


Would love your thoughts, please comment.x