Tools for Thought (TfT) Twitter Bot
Supports Roam and Obsidian!
Setting up
Twitter Credentials
Apply for a twitter developer account which will let you the credentials you need to create a bot. Should get automatically approved since you are an individual developer. Once approved, getting credentials should be intuitive.
Obsidian Credentials
- You will need to sync your obsidian vault to Google Drive
- Copy the id of your vault folder and store that somewhere, you will fill
that in for
NOTES_FOLDER_IDwhen setting up the server.
- Copy the id of your vault folder and store that somewhere, you will fill
that in for
- Obtain the credentials JSON file by following the following instructions
- https://developers.google.com/workspace/guides/create-credentials
- You will need to authorize Drive API
- Make sure that the OAuth consent screen settings is set to production, otherwise the app will terminate the credentials in 7 days and the token will be unable to be refreshed.
- Then you will need to manually run the
generate_initial_tokenfunction - Run:
./generate_token.py- Copy the contents of the file and set it to
GDRIVE_TOKENin.env(this is also used when deploying the server)
Roam credentials
If you signed up using Google OAuth, make sure to reset your password so that you can set a manual password.
Deploying
Heroku
Simply click the button and fill in the credentials you got from the previous step. You should immediately see a sample tweet show up on your timeline.
Locally / Custom Server
Developed on Python 3.8+
Install geckodriver (required for selenium)
- Linux: https://askubuntu.com/a/871077
- MacOS:
brew install geckodriver
Then run the following commands
$ python -m venv tft_bot
$ ./tft_bot/bin/activate
(tft_bot) $ pip install -r requirements.txt
(tft_bot) $ pip install -e .
(tft_bot) $ cp .env.sample .env # now update these values manuallyYou should just be able to run the cron script in a background process.
(tft_bot) $ nohup ./cron.py &Running Tests
Running the simple tests.
(tft_bot) $ pip install -r requirements-dev.txt
(tft_bot) $ pytestRunning the integration tests. WARNING: these actually tweet out using the provided credentials and require configuring your local environment according to the instructions above.
(tft_bot) $ INTEGRATION=1 pytest -s -k integrationRoadmap
The future roadmap for different features.
-
Draft README on setting up bot for other people
- Acquiring Twitter API credentials
- Deploying bot to Heroku
-
Roam
- Pull blocks from roam database using a single backlink/tag
- Switch from
roam-apito self-contained dependency
-
Obsidian
- Add Obsidian support and optional env var switch
-
Bot
- Split long tweets into threads (max size = 9)
- For some reason Heroku does not seem to like "cron" mode of APScheduler only interval seems to work.
- Refactor the bot into python package
- Migrate to Heroku Scheduler to use one-off runners instead of continuously running dyno. There are only 550 dyno hours for the free tier in a month which is ~22 days.
-
Advertise the project
- Slack
