Ephemerabot is a Twitter bot cousin of the Ephemera project. Ephemerabot checks for and tweets out new scraps of ephemera daily. Any new ephemera also causes the Ephemera website to rebuild using Netlify build hooks.
This repo might be useful to you if:
- You're interested in making a Twitter bot
- Your ideal Twitter bot reads and writes images
- You'd like to transform images via Node
- You're interested in using the Airtable API
- You're interested in automatically deploying Netlify sites
Here's how to get this project working locally.
- Node.js (v18 and above) and npm
- An Airtable base and API key (instructions here)
- A Twitter developer account and API key
And if you'd like to make Ephemerabot automatically deploy you'll need to either:
- Prepare a Netlify site with a build hook URL
- Comment-out the
fetch(rebuild_url, { method: 'POST' })
line in server.js
- Clone this repo
git clone https://github.com/dnywh/ephemerabot.git
- Install the NPM packages
cd ephemerabot
npm install
- Create a file called .env and enter values for the variables shown in .env.example
TWITTER_API_KEY=
TWITTER_API_SECRET_KEY=
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_SECRET=
AIRTABLE_API_KEY=
AIRTABLE_BASE_ID=
REBUILD_URL=
Here's how to get Ephemerabot going, assuming you have followed the above instructions and have:
- API keys for both Twitter and Airtable
- An Airtable base set up similarly to mine (instructions here)
npm start
Consider using one of the two core functions currently commented-out for debugging. Otherwise Ephemerabot will just wait for its scheduled time to post.
Ephemerabot loves to chat. Keep an eye on the terminal to see how things are progressing.
Ephemerabot looks at the tweeted value of each record to see if it has been tweeted yet. Once tweeted, records have this value to true
. The aforementioned instructions include an example base with a tweeted column. Try setting one or two records' tweeted value to false
to have them recognised and tweeted by the tweetLatestEphemera()
function.
To use the tweetLatestEphemera()
function in debug mode:
- Make sure your connected Airtable base has at least one record with its tweeted value set to
false
- Uncomment
tweetLatestEphemera()
in the debugging section (at the bottom) of server.js - If you just want to debug locally (and not kick off a real tweet): Comment-out
kickOffTweet(record, false)
within the maintweetLatestEphemera() function
- Run
npm start
- Keep an eye on your console for the results
Running Node on your computer is the only way Ephemerabot lives, unless you deploy this app to a server. You'll need to sign up to a service such as Heroku to do so. Daniel Shiffman has a few videos on this that are beginner-friendly.
Once you have set up a Heroku account and installed the Heroku CLI:
- Enter your API keys as Config Vars inside your Heroku dashboard's Settings page
- Push your project to Heroku:
git push heroku main
To use your own images you'll need to use a service like Cloudinary and change the imageDirectory
value in server.js.