Quickly Make a Mastodon bot with IFTTT
If you recently joined mastodon or another fediverse instace of something and thought to yourself, “If only x was here from Twitter” or “If only this feed was in mastodon”, well do I have a solution for you. The easiest way to turn a tweet (or a variety of things) from anyone into a toot from a bot is with IFTTT (Pronounced, If This, Then That)
Let’s say my usecase is I want my tweets from my twitter account to foward to a Mastodon account I setup for a bot.
Requirements:
- IFTTT account
- Mastodon account that bot will tweet out of
- Account for other network. Twitter, discord, youtube, etc
IFTTT is free for less than 5 Applets. But if you want to make a bot army with IFTTT, their plans are here.
1.) Create mastodon account that the bot will toot from
NOTE: Please ensure that the creation of a bot is not a violation of your instances' rules. Some find bots annoying no matter how endearing.
Once your account is Created, head to Preferences -> Development and click on New application
Give your application a name and the default credentials should be fine. However, If you want to toot from your own account, you might want to lock down and uncheck everything except for write:statuses only. Clicking submit should create the application and return you back to the application list. Upon reclicking the application name, you should now see the generated api keys.
Copy that access token to notepad.
2.) Create IFTT webhook
After creating an account. From within IFTTT Create screen, Click Add.
Follow the prompts to add twitter
After clicking on twitter you should be given a set of options.
After clicking on one(I chose my own account for this test), you will be asked to link your twitter account.
After linking, it should bring you back to the Create dashboard with If This replaced with twitter, now to add Then That.
Search for “webhook” and after clicking it, it only provides one option, make a web request.
Enter the following information while replacing MASTODON.DOMAIN and TOKENHERE with yours domain and key.
URL
https://MASTODON.DOMAIN/api/v1/statuses?access_token=TOKENHERE&status={{Text}}
Method:
POST
Content Type:
application/x-www-form-urlencoded
Additional Headers:
Authorization:access_token
Body
empty
IFTTT is pretty handy when you click on Add ingredient it simply allows you to enter the available fields, this is much more helpful if you were to pull an RSS feeds instead rather than a twitter feed, but leaving &status={{Text}}
will copy the text of the tweet over to a toot exactly.
Which means this tweet.
Will look like this toot.
If you’re happy with that, we’re done, click save. However, if you want to add any text, or link back to the original tweet on twitter, add some more elements to that URL like so
https://MASTODON.DOMAIN/api/v1/statuses?access_token=TOKENHERE&status={{Text}}%0A%0A<<<Link to original tweet: >>>{{LinkToTweet}}
Which will turn this tweet.
Into this toot. This is very helpful to determine if a tweet has been deleted, because the toot will remain.
This does run into issues with photos, where this.
Becomes this.
Tiny drawback, but it is still the absolutely simplest way to convert them tweets into toots. Once you click save, it should return you to the dashboard for the applet showing it’s now connected. Click on View activity to see a timeline of the last tweets that were forwarded. Another option without using IFTTT is using Feed2toot, but I’ll write up a guide for that one in a later post.
I hope that was simple. I used this method to create @SecurityAdvisories@0twitter.com where it pulls from a large Feedly group. If this was helpful for you, let me know at my main at @L0G1S@infosec.exchange
Have a good one,