Using IFTTT to post to Mastodon

On moving from Twitter to Mastodon as my main microblogging platform I was keen to set up a couple of integrations via IFTTT (If This Then That) – one to automatically post my public Flickr photos (with the description as the image description aka alt text) and another to post when I blog.

Unfortunately the former isn’t possible (yet?) as apparently posting an image to Mastodon is a two-stage process and IFTTT automation can only handle a single step. However I’ve managed to set up a simple post with the title, description and a link to the image page on Flickr, and a similar new blog post notification from this WordPress site.

Full disclosure: very little in this post is original! I highly recommend Matthias Ott’s post on Syndicating Posts from Your Personal Website to Twitter and Mastodon [Syndicating to Mastodon section] which got me most of the way there, and the post he referenced by Kelson Vibber (How to Post to Mastodon From Anything Using IFTTT) covered the rest.

Rather than replicate their work in detail, first I’ll very briefly outline the steps as covered by them, then say a bit more about formatting the post itself.

Linking IFTTT to Mastodon

  1. Set up IFTTT Webhooks and look up the full URL of your Webhook via Webhooks Settings.
  2. Use your Webhook URL to add this application to your Mastodon account via https://[your instance URL]/settings/applications/ – only tick 'write:statuses', it doesn’t need access to anything else.
  3. Copy the access token this generates.
  4. Set up a trigger for your IFTTT applet as usual and when choosing the ‘then that’, select Webhooks.
  5. Use the following settings:
    • URL = https://[your instance URL]/api/v1/statuses?access_token=[your access token]
    • Method = POST
    • Content type = application/x-www-form-urlencoded
  6. Body – this is where it gets interesting!

Formatting your post

First click ‘Add ingredient’ to see what fields are available to you. Whichever you add, it seems best to surround any of them with <<< >>> which escapes any special characters to ensure they display correctly.

At a minimum, start the body with status=<<< {{your ingredient of choice}} >>>. You can do more e.g. use a content wrapper/warning using 'spoiler_text=', just remember to put an ampersand (&) between each part of the post. Kelson’s post gives some nice examples.

For Flickr I ended up with the below – the yucky-looking variables were easily inserted via ‘add ingredient’.

spoiler_text=Flickr crosspost - <<<{{Flickr.anyNewPublicPhoto.Title}}>>>&status=<<<{{Flickr.anyNewPublicPhoto.Description}}>>>  <<<{{Flickr.anyNewPublicPhoto.FlickrUrlShort}}>>>

For WordPress I used the following (with the WordPress integration rather than RSS):

status=New blog post: <<< {{PostTitle}}>>> <<< {{PostUrl}}>>>

Testing

I’m a free IFTTT user and found the ‘check now’ button to try and run the applet straight away didn’t seem to do much. In the end I published a new blog post/uploaded a photo and had to Just Be Patient! First time round the widget didn’t fire at all; I suspect because I went in and edited the settings after doing something that would trigger it, but before it had fired. Second time round all went very well :) You can enable notifications when applets run in IFTTT so you know when to check your Mastodon posts.

Final thoughts

Matthias discusses the etiquette of cross-posting at all, and Kelson mentions the importance of only doing this with triggers that you control. Otherwise you’re essentially creating a bot account and need to use an appropriate instance, consider the ethics of doing so, etc.

I’m not sure how useful it is to post a link to Flickr rather than the image itself; longer-term I ought to check out Pixelfed but I have a huge archive of photos on Flickr now.

I’m also wondering if there’s cleverer and more sophisticated uses of this integration. There’s a syntax to post a draft for manual editing/publishing which could be a nice way to set up a workflow for more selective sharing. In fact I just found that adding a blog post to Feedly’s ‘save for later’ list is a possible trigger which is very interesting, but IFTTT integration requires Feedly Pro at $8 a month. Now where have I heard that price point recently?!

Published by

Edith Speller

Library nerd. Lives in and loves SE London.

Leave a comment