⚠️ This lesson is retired and might contain outdated information.

Host a Simple Twitter Bot Using Heroku

Hannah Davis
InstructorHannah Davis
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated a year ago

In this lesson, we’ll learn how to host a simple bot with Heroku. We'll learn how to create a new Heroku application and how to deploy our code to Heroku using git. We’ll learn how to change our project from a web app to a worker app and how to create a Procfile. We'll also see how to see output from our Heroku app with the command heroku logs.

[00:00] To host your bot on Heroku, first log into Heroku. Then say new app, enter a name for your app, and then press Create App. Then go to settings, reveal config bars, and this is where we'll put our environment variables.

[00:19] We'll put our consumer key, obviously these are made up for now, our consumer secret, our access token, and our access token secret. Back in our code let's say Heroku login, enter your email and password. For new Git repository we'll say git init, and then Heroku git remote -a and our application name.

[00:52] If we do git status we can see our files, so we're going to make a git ignore, and open that git ignore to put our node module in it, and then we'll add all of it, git commit -m initial commit. Then it's git push Heroku master.

[01:12] By default, Heroku thinks the app is a Web app, so to make this a worker app, we need to make a file called procfile. In procfile we say worker:then our start command, which is nodeindex.js. Then we need to push that up to Heroku as well.

[01:44] Once we do that, if we go to resources, we can see we have two options, Web and worker. First, we want to turn off the Web, and confirm. We want to turn on the worker, and confirm. Once everything is up and we can see that our build succeeded, we can say Heroku logs, we can see that our bot is working.

[02:07] I've got a little bot here that tweets the date every minute, using the set interval function, but the Heroku pipeline would also work for a bot that was listening to a Twitter stream and replying to tweets.

~ an hour ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today