So you’re streaming on Twitch, and you want a chatbot for your channel? Great! Many content creators start out with a hosted option like Nightbot, but they often realize the custom benefits of self-hosted bots like Ankhbot or Deepbot. Here’s the challenge, though; if, like many people, you host your chatbot on your own PC, you have to remember to start the bot again any time you restart your computer. If you want the bot to be running 24/7 (for example, if it has Discord integrations), you can’t afford to turn your PC off when you’re not streaming. However, there’s an alternative that solves this problem: cloud computing.
If you can host your chatbot on a virtual machine, you don’t have to worry about adding yet another piece of software to manage on your stream PC. Then again, if you don’t have a VM laying around somewhere in the cloud, who wants to add that cost to their streaming expenses? This is where Amazon Web Services (AWS) comes into play. They provide a free tier of a VM product that we can use to host any bots we want to run 24/7. I’ll walk you step-by-step through the entire process to get your chatbot up and running smoothly on a virtual machine!
Reading Time: 15 minutes, Setup Time: 30 minutes, Total Time: 2-3 hours (See AWS signup note below)
Choosing A Chatbot
For the purposes of this guide, we’ll be using the Streamlabs Chatbot, formerly known as Ankhbot. I strongly recommend this great bot for any streamer; it has all the tools you’ll need to run your channel smoothly. However, this same process should work with any self-hosted bot, though a few minor steps may be different depending on your bot’s requirements. If you’re already running your own bot locally, read on! I’ll also include instructions for how to transfer your bot to a VM without losing your existing data.
Sign Up For AWS
The first thing you’ll need to do is make sure you have an AWS account. Visit aws.amazon.com to sign up if you don’t have one yet. Most people will choose “Personal” as their account type, unless they’re signing up on behalf of a business. You’ll be asked to enter a credit card to verify your identity, though it won’t be charged within free tier usage. Just running the chatbot would not exceed any the free tier limits, and I have not been charged in months of running two of my own bots. Some aspects of the free tier do expire after 12 months, though; while I believe you should be able to run the bot for free indefinitely, don’t quote me on that. I’ll certainly report back here if I find out differently, since I’ve been running my bots for several months already and will pass the 12-month mark in mid-2018.
You’ll also need your phone handy so AWS can call you to enter a PIN for additional verification of your signup. Finally, you will likely choose the Free support tier, as opposed to a paid support system.
Note: Newly created AWS accounts can take up to 24 hours to be fully available. If you do not have an account yet, sign up now and then check back later in the day to complete the rest of the steps in this guide. In my case, it took 1-2 hours to have my account approved.
Create A Virtual Machine
Once you’ve signed in to your AWS account, it’s time to create your virtual machine. In the “Build a Solution” section of your home (Console) page, you should see a link to “Launch a virtual machine”. This will give you the choice of either an EC2 or Lightsail Instance, of which you’ll want to select EC2. After naming your instance, pick Windows Server 2016 Base as your operating system.
Stick with the default options and click through to create a key pair. You will download a (.pem) file that contains the private key for accessing your virtual machine. Store that key in a safe place, as it’s necessary for the later steps. With all options selected, it’s time to tell AWS to create your instance. After a few minutes, click “Proceed to EC2 Console” to access the virtual machine.
Set Up Security Protocols
In order to use this VM, you need to be able to connect remotely to setup and manage your chatbot. Before you connect, though, you’ll need to set up a security protocol to protect who can access it. This may be done by limiting it to your IP or other filters, but for the purposes of this guide, I’m going to show you how to open up your security protocol to be able to access it from any computer/IP that has the secret access key you downloaded earlier.
From your EC2 Management Console, click “Security Groups”, and then “Create Security Group” (or edit the default one that was . Give your group a name and description, and then enter the following rules for both inbound and outbound:
Please note that this will allow any traffic to communicate with your VM, though remote access will still provide the aforementioned private key. If you are interested in setting up more restrictive rules, refer to the AWS Documentation for further help.
Once you’ve created your security group, click “Instances” to get back to your VM instance. Check the instance you want to change, and then click Actions->Networking->Change Security Groups. Make sure to select your modified security group and assign it to this instance. Now that you have security rules in place, it’s time to finally connect to your VM!
Connect To A Virtual Machine
In order to access a VM, you will need remote desktop software. Feel free to use your favorite, but Microsoft’s Remote Desktop product will work just fine. For this guide, we’ll use Microsoft Remote Desktop for MacOS. Click “Connect” from the Instances page of your EC2 Management Console to download the files necessary for a remote connection. The Remote Desktop Protocol (.rdp) file will tell your software how to find the VM, now we just need the password. This is where the (.pem) file you downloaded earlier will come into play.
Click “Get Password” and upload the private key file to decrypt the VM’s password. Open your Remote Desktop software and, using File->Import, import the (.rdp) protocol to set up your connection. Right-click on the new connection in the list and select “edit”. Copy the password you decrypted into the “password” field of the connection, and, optionally, give that connection a name to make it easy to identify. Close the connection details to save, and then double-click on it to connect to your VM. This will launch a remote connection, giving you control over the VM you’ve set up!
Setting Up Your Chatbot
Once you’re connected, download the installer for the bot. While Internet Explorer is serviceable, on AWS VMs the default security settings are annoying and overly restrictive. So visit www.google.com/chrome to download and install Google Chrome, or do the same with your favorite browser. IE will tell you insecure content is being blocked from various Google sites repeatedly while you do this; each time, just click “Add” twice and close the dialog to bypass the security warnings. Once you download and install Chrome, use it for all future downloads to make things easier.
Visit the Streamlabs site to download the installer and run it. Once installed, start the application and you will be taken through the setup wizard for your bot! If you already have an existing bot to transfer, skip the wizard and read below.
Backing Up Bot Settings
Most bots include a backup/restore system that protects you from losing your data. In the case of the Streamlabs Chatbot, you can refer to page 16 of their documentation for help with setting up a backup through Google Drive, Dropbox, or your favorite cloud platform. Once that’s set up, you’ll be able to ensure that your bot data is safe in case you ever need to transfer the bot to a new computer.
In fact, let’s say you’re already running a bot on your stream PC, and you want to set it up on the VM without losing any of your precious data. These cloud backups can be used to transfer the bot to the VM. After backing up the existing data, you can install the same cloud platform (ie Google Drive) onto the VM. Then, set up your new bot’s cloud settings to point to the folder the backed up data is stored in locally, and click “Import Backup” to target the latest backup file for your bot. This will allow you to keep running the same bot you had before without having to go through the full setup steps again!
Managing Your Bot Remotely
The most annoying part of hosting your bot on a VM is making configuration changes like adding new commands. Fortunately, many bots allow for an “Editor” role that gives users (such as your moderators) access to manage the bot from your Twitch chat. You can easily give yourself the same capabilities by adding your own Twitch account as an editor!
Is running your chatbot through a virtual machine the silver bullet solution to all your bot hosting needs? Not necessarily. While it provides a lot of convenience to give your bot 24/7 uptime, it has a few drawbacks. In particular, features that are meant to integrate directly into your stream will be difficult, if not impossible to use. This includes things like song requests and sound effects that are handled by the bot. There are a few options for working around this, however:
- Host these features through a separate bot: You can either install a second instance of the same bot on your local machine that you only use for these features (allowing the remote bot to handle the rest), or you can use a different bot (such as Nightbot) that implements one or more of these features.
- In an ideal world, Streamlabs would leverage integrations between the chatbot and their other features to allow your remote chatbot to play music & sound effects via a browser source, the same as their other widgets. In fact, I’ve submitted this suggestion to Streamlabs, so feel free to track its progress for updates.
Hopefully I’ve provided a thorough step-by-step guide for setting up your very on VM-hosted chatbot. If you have questions or run into any issues, feel free to reach out to me on Twitter or check out the Streamlabs Chatbot Discord. I’m happy to do whatever I can to help you realize your bot hosting dreams. Best of luck, streams!