K-Squared Ramblings

How to Post to Mastodon From Anything Using IFTTT

I finally managed to hook up IFTTT to Mastodon to auto-post from another site! I use IFTTT as glue for linking several services together including sharing interesting links from Pocket when I’m offline: I can add a tag in the app on my tablet, and then when it syncs that tag up to the cloud, IFTTT will pick it up and create the share post on whichever service I’ve tagged it for.*

My main source was this post by @raucao@kosmos.social. It’s a bit out of date, but it pointed me in the right direction.

1. Set up IFTTT’s Maker WebHooks

On IFTTT, go to maker_webhooks settings. Make sure it’s active.

2. Set up Mastodon to allow IFTTT as an application

Go to Preferences/Development/Your Applications on your Mastodon instance (ex: on mastodon.social it’s here). Click on New Application. Enter the following:

Name: IFTTT
Website: https://maker.ifttt.com/ (at first I thought you needed the full URL from the IFTTT config, but it seems OK without it.
Scopes: read and write should be enough. Actually just write might be fine.

Submit the app.

Now open the new app you’ve created and look up the access token.

3. Create an IFTTT app!

Go back to IFTTT and create a new app. For example, I created an app triggered by Pocket, whenever an item is tagged share-mastodon. You could also set it up to autopost every time you blog with a specific tag, or every new item in an RSS feed, or all kinds of things. Even cross-post from Facebook or “the birdsite” (Twitter).

For the “then that” section, choose a Webhooks action.

URL: https://mastodon.social/api/v1/statuses?access_token=1234567890 (paste your access token here.)
Method: POST
Content Type: application/x-www-form-urlencoded
Body: status=whatever-you-want-to-post

For example, to share a link from Pocket you might want the body to be

status={{Title}} {{Url}}

Or for posting from WordPress, you might want it to be

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

{{PostContent}}

Click on Create Action.

Add a title and click on Finish

4. Test it out!

Go and post something that should trigger the rule, then come back and click “Check Now” on the IFTTT applet. Make sure it comes through the way you want it to. Adjust it as needed.

You can follow me on Mastodon at @kelsonv@mastodon.social. If you’re not on Mastodon, but would like to check it out, start at JoinMastodon.org. It’s a quick overview of what Mastodon is, how it’s different from Twitter, how different instances work (think of them as different servers on an MMO game, or different email services), and how to pick an instance that suits you.

*The day after testing the Pocket-to-Mastodon connection with a few links, I discovered something interesting about IFTTT when it re-posted one of those links to Buffer. Apparently IFTTT doesn’t know which tags are new, only which bookmarks have been updated and what the current tags are. My new Pocket-to-Mastodon applet picked up the share-mastodon tag I’d just added, and my Pocket-to-Buffer applet picked up the old share-buffer tag that had been on there since I first shared it last month.