Botpress is a fantastic and powerful chatbot platform with heaps of basic as well as advanced functionality. However, to a beginner (and those with little programming experience) it can be quite daunting to get started. In this tutorial we’ll cover what I think are some important terms and a step-by-step guide to getting your first chatbot up and running.
Disclaimer: This guide is for LINUX users. Specifically Ubuntu 20.04.1 LTS. If there is enough interest, or if people request it, I’ll write a guide for Windows as well.
To be honest, Botpress is fairly easy to get the hang of once you have some knowledge about how it works and its architecture. I wanted to write this guide because I feel the official Botpress documentation is not easy to digest if you are: a) Not a programmer and, b) Aren’t already familiar with the layout and architecture of Linux-type systems. One of the main reasons I love Botpress is the fact that, if you choose, you have complete control of all the data as everything can be hosted on premises – and it’s all open-source!
In this guide we’ll cover the following:
- Botpress quick install (under 1 minute)
- Some core concepts
- SQLite vs. PostgreSQL
- Preparing your environment
- Dependencies – none, wait what?!
Local Botpress server up and running in under a minute? Yes, please!
For those who:
- Are completely new to Botpress and just want to see what it’s about
- Are Impatient
- Don’t need a lot of performance
- Just want to test the latest version with no fuss
- Visit https://botpress.com/download
- Click the box with Linux
- Open up your Download folder in ‘Files’
- Right click botpress-v12_14_2-linux-x64.zip
It will look like the following:
- Click ‘Extract Here’
- Double click to enter the folder (botpress-v12_14_2-linux-x64)
- Right click an empty section in the botpress-v12_14_2-linux-x64 folder
- Click ‘Open in Terminal’
- Type the following command
Do the following commands:
That's it! Yes, the Botpress server is now running at http://localhost:3000
With that out the way, let’s delve into the more detailed version.
Botpress Flow editor, Cyklon Helper Bot Start Node
It is recommended that you have 64GB available disk space and at least 4GB of RAM, see. A Botpress chatbot receives data from a channel (e.g. Web, Slack, Facebook Messenger), processes it and then executes flows based on rules. Below is the processed visualised courtesy of Botpress:
If you want or need more detailed information about the whole process, visit the Botpress Docs directly. Botpress uses a database to store information. By default SQLite is used, however it is recommended (by Cyklon IT Solutions, me, and Botpress themselves) to instead use a PostgreSQL database. There are a few reasons to use PostgreSQL instead of SQLite, namely:
SQLite vs. PostgreSQL
- Better performance
- Handy as Botpress uses JSON a lot!
Preparing your environment
Dependencies - none, wait what?!
Okay, so that’s a bit of a lie – but not really. If you used the earlier ‘quick start’ guide to get a Botpress server up and running there are no dependencies, however, by default Ubuntu does not come with PostgreSQL pre-installed.
I was originally going to include a GUI guide in this section but decided against it. It is honestly so much easier to do these next steps in the Terminal – so it’s an idea to get accustomed to using the command line.
PostgreSQL can be easily installed using the command:
sudo apt update && sudo apt install postgresql
Note: You can also install the optional package, “postgresql-contrib” but it’s not necessary. I haven’t found any benefit to installing it because all we’ll be doing is creating a PostgreSQL user and database.
Now we need to create a PostgreSQL user and database. Use the following command to switch to the PostgreSQL ‘postgres’ user account.
sudo su postgres -
To enter PostgreSQL we then type the following:
The Terminal prompt should now look like this:
Great! In order to create our Botpress user, we use the syntax:
CREATE USER botpressuser WITH PASSWORD ‘yourpasswordhere’;
It’s important to note the username does not have quotations, but the password does. Personally, I prefer only including alphanumeric characters (letters and numbers) in the password so you don’t have to worry about escaping any characters. Also, make sure you put the semicolon at the end of the command. Note down these details because we need them later. To exit PostgreSQL type:
to return to our normal Terminal prompt.
Almost there! To create the database, we use:
CREATE DATABASE botpressdb;
We’ve created a PostgreSQL user and database, but Botpress doesn’t know about it. Let’s tell Botpress where it can find this information – and to use it! In order to do this we need to create an environment file in the extracted directory of Botpress (the same folder where the “bp” executable file is). Type the following:
This creates a file called “.env” and opens it in the ‘nano’ text editor. Type the following:
On the next line, put:
and finally on the next line:
Close the file by pressing ‘CTRL + X’ and press ‘Y’ to accept the changes. That’s it! When you run
Botpress will be using PostgreSQL. You can double check this by navigating to ‘Production Checklist’ in Botpress. Green check marks will appear next to ‘Use a Postgres database’ and ‘Use the database BPFS storage’, similar to the image below:
Botpress ‘Production Checklist’
If you followed the above steps yours will look different to this, but don’t fret because my installation is just configured differently!
Thanks for reading and I hope this helped you!
The featured image is from Botpress