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.
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)
On the google domain name registry website, you want to redirect the traffic.
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.
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.
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.
In the AWS console, you can search for the EC2 (Elastics Cloud Computing) service. This service is used to start a server on AWS.
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.
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.
Inside the route53 create a new record.
And the second record to add is www.
At the end, you should have something like this.
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
$ sudo apt-get update
After you need to install docker
$ sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg$ echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null$ sudo apt-get update$ sudo apt-get install docker-ce docker-ce-cli containerd.io
And the last piece of the puzzle is the docker-compose
$ sudo apt install docker-compose
After the installation of docker. Clone the botpress project on your server.
$ git clone https://github.com/botpress/botpress.git$ cd botpress/example/docker-compose$ sed -i ‘s/$PLACE_HOLDER_DOMAIN_NAME/learnbotpress.com’ docker-compose-community-nginx-https.yml$ sed -i ‘s/$PLACE_HOLDER_DOMAIN_NAME/learnbotpress.com’ nginx/user_conf.d
Start the botpress project
$ 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).
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