-
Notifications
You must be signed in to change notification settings - Fork 24
Setting up Tootbot (Heroku)
Instead of setting up Tootbot locally on your own computer or server, you can now run Tootbot for free in the cloud using Heroku. This guide will walk you through the whole process.
If you already have Tootbot running locally, and you want to move your bot to Heroku, use these instructions instead.
There are some differences between running Tootbot locally and running it on Heroku. Most people won't mind these limitations, but it's important to keep them in mind:
- You can't modify the Tootbot script. If you need to change how Tootbot works, you should set up Tootbot locally instead. Heroku doesn't allow you to modify scripts running in the cloud, unless you install the Heroku command line application. You can still change all of Tootbot's settings.
-
Cache works differently. The Heroku version of Toobot uses a Redis database for storing Reddit links that have been posted, instead of adding them to the
cache.csv
file.
If that all sounds good to you, continue on!
Due to Twitter's recent changes to API access, you now have to apply for a developer account if you want your bot to post to Twitter. This doesn't take much effort on your part, but you will have to wait a day or two to be accepted. This step is not necessary if you only want to post to Mastodon.
- Sign in with the Twitter account you want to use with the bot.
- Once logged in, go apply for a developer account.
- When asked "Who are you requesting access for?", click the checkbox for "I am requesting access for my own personal use".
- Twitter will ask you to explain how you will use the APIs. Type something like this:
1. I'm using Twitter's APIs to repost images from reddit.com to Twitter.
2. I am not analyzing any tweets.
3. I will be occasionally posting images to Twitter. The tool using the API will not interact with users in any way.
4. No Twitter content will be displayed.
Once you submit your application, you have to wait for approval from Twitter. You should receive an email in the next day or two. Continue on with this guide once you receive approval.
Next, you need to create a Heroku account, if you don't have one already. You only need a free account. If you already have an account, go ahead and sign in.
Once you're logged in, enter payment information on this page. This is required for the Redis addon, but you will not be charged because Tootbot uses the free development tier.
Once you've saved payment information, click the button below to deploy a Tootbot application:
You should see a 'Create new App' page that looks like this:
You can set the 'App name' to whatever you want, but it's best to give it the same name as the social media account for easy reference. Below that are the 'Config vars', which are all of Tootbot's settings. Each setting is explained on that page, so just read the descriptions above the text boxes.
Come back to this guide once you reach the Reddit and Imgur settings at the bottom.
- Log into Reddit, go to your app preferences, and click the 'Create a new application' button at the bottom.
- Select 'script' as the application type, and click the 'Create app' button.
- You should see a Reddit agent string (underneath 'personal use script') and an agent secret. Paste the agent string into the
REDDIT_AGENT
box, and paste the agent secret into theREDDIT_SECRET
box.
The Imgur API is used to obtain the direct image URLs from Imgur page/gallery/album links.
- Sign into Imgur with your account, or make one if you haven't already.
- Register an application here and choose 'OAuth 2 authorization without a callback URL' as the app type.
- Imgur will give you a Client ID and Client Secret. Paste the Client ID into the
IMGUR_ID
box, and paste the client secret into the 0IMGUR_SECRET
box.
Once you've configured all the settings and pasted in the API keys for Reddit and Imgur, click the Deploy app
button at the very bottom of the page. Once the installation process is done (all the circles have a checkmark), click the Manage app
button.
- Go to the application dashboard and click the 'Crete an app' button.
- Fill out the required text boxes and click 'Create' at the bottom.
- Click the 'Permissions' tab, and make sure the Access permission says 'Read and write'
- Click the 'Keys and tokens' tab, and click the 'Create' button underneath 'Access token & access token secret'.
Now that you have all the API keys, you need to save them in Heroku.
- Go to the Heroku dashboard and click on the Tootbot app you just made.
- Click the Settings tab, and click the
Reveal Config Vars
button. At the bottom of the variables list are two blank boxes, one forKEY
and one forVALUE
. - Paste
TWITTER_ACCESS_TOKEN
in theKEY
box, then paste the Twitter Access Token you just got in theVALUE
box. Then click theAdd
button. - Paste
TWITTER_ACCESS_TOKEN_SECRET
in theKEY
box, then paste the Twitter Access Token Secret you just got in theVALUE
box. Then click theAdd
button. - Paste
TWITTER_CONSUMER_KEY
in theKEY
box, then paste the Twitter Consumer Key you just got in theVALUE
box. Then click theAdd
button. - Paste
TWITTER_CONSUMER_SECRET
in theKEY
box, then paste the Twitter Consumer Secret you just got in theVALUE
box. Then click theAdd
button.
- Log into a Mastodon account and click on the settings gear above the compose window.
- In the settings, click 'Development', then click the 'New Application' button.
- Enter a name (it can be anything) and click the 'Submit' button at the bottom of the page. You don't need to mess with any other options on the page.
- Click the application you just created and copy the Access Token.
Now that you have the access token, you need to save it into Heroku.
- Go to the Heroku dashboard and click on the Tootbot app you just made.
- Click the Settings tab, and click the
Reveal Config Vars
button. At the bottom of the variables list are two blank boxes, one forKEY
and one forVALUE
. - Paste
MASTODON_ACCESS_TOKEN
in theKEY
box, then paste the Access Token you just got in theVALUE
box. Then click theAdd
button. - Paste
MASTODON_INSTANCE_DOMAIN
in theKEY
box, then paste the domain name of the Mastodon instance you're using (e.g. mastodon.social, no 'https' or slashes) in theVALUE
box. Then click theAdd
button. - Paste
MASTODON_SENSITIVE_MEDIA
in theKEY
box, then typefalse
in theVALUE
box. If you want all media attachments on Mastodon to be marked as sensitive, typetrue
instead. Then click theAdd
button.
Now that all your settings and API keys are configured, you can turn on Tootbot. Click on the Overview
tab, and click the Configure Dynos
link. Then click the pencil icon on the right, click the switch (so it's turned on), and click Confirm
.
Tootbot should now be running. You can see Tootbot's messages by clicking the More
button on the top right and selecting View logs
.
If you ever want to change Tootbot's settings, just go back to the Settings tab, click the Reveal Config Vars
button, and click the pencil icon next to whatever option you want to change. To see the description/usage instructions for each option, just look at the deploy page again.
You have to reboot Tootbot each time you change a setting. The easiest way to reboot Tootbot is to click the More
button on the top right of the Heroku dashboard and select Restart all dynos
.
Once you're done making a bot account with Tootbot, please add it to the list of accounts using Tootbot! Also make sure to subscribe to the Tootbot updates feed via email or with an RSS reader, so you'll be notified when a new version is available.