logo

Deploying botpress on AWS

In this tutorial, we'll set up an instance of Botpress on a domain using proper encryption standards. You'll be able to access the Botpress Admin Panel from anywhere, and allow chatbot users to talk with your Chatbots. I've purchased the domain learnbotpress.com on Google Domains (you can use any Domain Name Provider), and we'll be hosting Botpress on AWS.

10 Nov, 2021

Updated 16 Nov, 2021

Share

Deploying botpress on AWS

I did a video a couple of weeks ago. This video was about deploying botpress on an HTTPS server using DigitalOcean and google domain name. I do want to create a blog post to accompany this video. Instead of using the same cloud provider, I will use another one. In this blog post, I will use AWS as my cloud provider to route all my connections from the domain name that I brought on the Google registry domain. (Same pattern as in the video). You can find the video below if you prefer.

Deploying botpress with digital oceans

AWS

AWS doesn't have a global nameserver for redirecting traffic from a domain name to a server. To make sure all the traffic that goes to learnbotpress.com I need to use route53 to create a DNS nameserver. In the console of AWS, I will go in the route53 service and click create new Hosted zones. This new hosted zone will be used for my learnbotpress.com domain name. In the route53 service, I will create new hosted zones.

After the creation of the route53 service, You will have 4 DNS nameservers. You will need to use those servers on your google domain registry (or another domain registry)

Redirect traffic to your domain name

On the google domain name registry website, you want to redirect the traffic.

  1. Go to the DNS menu
  2. Click Custom Name Servers
  3. Manage Name servers

It's time to add the nameserver you got from the route53 service into the custom name servers.

You need to tell Google Domains to use those name servers. I don't have the image for this one sorry :(. But I do remember you need to do it. From the google domain name website, it says that it can take up to 30 minutes to update the DNS registry. To check if your DNS propagation has been successful you can use some website. I used the website called whatsmydns.

Security group in AWS

Once the DNS propagation is done. You need to modify the security group for your EC2. The security group is like UFW for the server. I will let the ACL (access control list) be open to everyone (ACL is for the VPC).

In the security group, you need to open the inbound traffic (HTTPS, HTTP, and SSH) before running the docker-compose.

To open the Inbound traffic for the security group, you can go on your EC2 instance.

  • In the tab security
  • Click on the security group associated with your ec2 instance.
  • In the security group section, you can click on the inbound traffic tab and edit your inbound traffic.
  • Make sure to add IPV6 and IPV4 in the inbound traffic for your EC2 instance.

You don’t need to modify the ACL inbound and outbound traffic. Unless you have done specific modifications to your ACL. By default, it should allow all the traffic.

Start EC2 instance

In the AWS console, you can search for the EC2 (Elastics Cloud Computing) service. This service is used to start a server on AWS.

  1. Search for the EC2 Service
  2. Click on "instance" on the left panel
  3. Launch the instance

  1. In the search bar, search for ubuntu 20.04
  2. Click on the instance

Botpress needs 4 GB of ram and 64 GB of free space to run correctly. Find a size that matches those criteria.

Select a Security group or create a new one if you don't have any. We are gonna do some modifications to this security group in a couple of minutes. After this, you will need to select a private key. This private key will be use as the key for the ssh connection.

Update route53 with the IP address of your EC2

Your domain name is known by the DNS, it knows where to find it. But your domain needs a server behind it. The EC2 installation is done. The IP address of the EC2 will be used in route53 service.

If you go in the route53 service in AWS.

  1. Select Hosted Zone
  2. The domain name you want to route your server

Inside the route53 create a new record.

  1. For the first record, the record name should be empty
  2. The record type should be A
  3. Value is the IP address of your EC2

And the second record to add is www.


  1. For the second record, the record name will be www
  2. Record Type is A
  3. Value is the IP address of your EC2

At the end, you should have something like this.

  • Two A records that match the IP address of the EC2 instance
  • Four NS record that is linked in the domain name provider
  • One SAO

Start Botpress

The first thing to do is to go in your EC2 instance. I will use SSH for this. You should have a private key that is assigned to your EC2 server.

$ ssh -i "Botpress-daehli.pem" [email protected]

You can find that information if you go on your instance, and click on the connect button.

Inside your server you can start by updating the apt-get registry

1$ sudo apt-get update

After you need to install docker

1$ sudo apt-get install \
2 ca-certificates \
3 curl \
4 gnupg \
5 lsb-release
6$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
7$ echo \
8 "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
9 $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
10$ sudo apt-get update
11
12$ sudo apt-get install docker-ce docker-ce-cli containerd.io

And the last piece of the puzzle is the docker-compose

1$ sudo apt install docker-compose

After the installation of docker. Clone the botpress project on your server.

1$ git clone https://github.com/botpress/botpress.git
2$ cd botpress/example/docker-compose
3$ sed -i ‘s/$PLACE_HOLDER_DOMAIN_NAME/learnbotpress.com’ docker-compose-community-nginx-https.yml
4$ sed -i ‘s/$PLACE_HOLDER_DOMAIN_NAME/learnbotpress.com’ nginx/user_conf.d

Start the botpress project

1$ docker-compose -f docker-compose-community-nginx-https.yaml up -d

In the docker-compose file, the Nginx service will create an encrypted key. This key is used to enable HTTPS connection between the user browser and your server. It can take a moment to create this key for the let's encrypt. Once the let’s encrypt is done you can navigate to your website (in this case www.learnbotpress.com learnbotpress.com).

Conclusion

I hope it was a helpful blog post. You have learned How to spin up a server and use a domain name. You can start deploying your bot on different channels. Most of the external channels (Messenger, Slack) need to have a valid domain name with an HTTPS connection.

Happy chatbot coding

Daehli Nadeau-Otis

Daehli is Botpress' developer advocate. For the past 4 years, he's been working as a full-stack developer for various companies. Daehli has a passion for trying new technologies and pushing the limits. During his free time, he enjoys Bicycle Polo (yes, it's a thing), trail running, and lots of bike camping.

Related Articles

7 Dec, 2021

The People of Botpress: Jean-Bernard Perron, Chief Financial Officer

The People of Botpress is a series where we highlight our people and the great work they do by talking about life at Botpress. In this first edition of The People of Botpress, we are interviewing our Chief Financial Officer, Jean-Bernard Perron

7 Dec, 2021

What’s Happening at Botpress: November 2021 Recap

Find out all about our November 2021 events, product updates, tips, tools, tricks and tutorials — All in one place.

23 Nov, 2021

The People of Botpress: François-Xavier Darveau, Head of Engineering

The People of Botpress is a series where we highlight our people and the great work they do by talking about life at Botpress. In this first edition of The People of Botpress, we are interviewing our Head of Engineering, François-Xavier Darveau!

Newsletter

Get The Latest Updates.
Subscribe Now