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
[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.