Twitter bot @getwhatdone that tweets platitudes to get things done. Heavily inspired by cool-robot-pals/getreadyfor.
Every hour job.js
is run. This loads the HTML template into headless Chrome using Puppeteer, inserts a random noun from noun-json, takes a screenshot and tweets it using node-twitter.
- Create
.env
with the Twitter bot credentials:TWITTER_CONSUMER_KEY=XXX TWITTER_CONSUMER_SECRET=XXX TWITTER_ACCESS_TOKEN_KEY=XXX TWITTER_ACCESS_TOKEN_SECRET=XXX
- Install dependencies:
npm install
- Run the job:
npm run job
There is also a placeholder webapp app.js
to occupy the Heroku web process. To run this:
npm start
Then visit http://localhost:3000/.
- Create app:
heroku create getwhatdone --region eu --buildpack heroku/nodejs heroku buildpacks:add jontewks/puppeteer
- Configure app for Twitter:
heroku config:set TWITTER_CONSUMER_KEY=XXX \ TWITTER_CONSUMER_SECRET=XXX \ TWITTER_ACCESS_TOKEN_KEY=XXX \ TWITTER_ACCESS_TOKEN_SECRET=XXX
- Deploy app:
git push heroku master
- Schedule job:
Add job to run
heroku addons:create scheduler:standard heroku addons:open scheduler
npm run job
every hour
To list all previous tweets:
npm run list
Example output:
Id | Created At | Text
--------------------+--------------------------+---------------------------------
1210271071955570688 | 2019-12-26T18:48:03.000Z | Get earthworm done https://t.co/wg1Eg9FCAP
1210263078572580865 | 2019-12-26T18:16:18.000Z | Get gather done https://t.co/2UCVPP0RAV
1210262953158758400 | 2019-12-26T18:15:48.000Z | Get brother done https://t.co/k9unIt5Hk6
The Id
can then be used to obtain the tweet URL.