<commit_before>---
layout: guide
---

# 🚀 Deploying our bot

Now that our bot is ready, we're ready to deploy it to Heroku.

## Heroku

We're using Heroku because it's fast, easy and free to deploy and manage your bot from there.

### Prerequisites

- If you don't already have a Heroku account, you can create one for free [here](https://signup.heroku.com).

- Install the Heroku CLI by following [these instructions](https://devcenter.heroku.com/articles/heroku-cli).

- Type `heroku login` in your terminal to login to heroku

### Git

Let's init a git repo in our bot directory:

```bash
git init

git add .

git commit -m "First commit"
```

Then let's create a Heroku App:

```bash
heroku create

# Creating app... done, ⬢ glacial-inlet-29943
# https://glacial-inlet-29943.herokuapp.com/ | https://git.heroku.com/glacial-inlet-29943.git
```

Alright, now let's actually deploy our app:

```bash
git push heroku master
```

And you're done! You should see something like:

```bash
remote:        https://glacial-inlet-29943.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/glacial-inlet-29943.git
 * [new branch]      master -> master
```

For more information about how to setup Heroku, [read this](https://devcenter.heroku.com/articles/git).

## Configuring our app

Your bot is now live at the URL that Heroku just gave you in the last command run. If you open that URL you'll notice that you are facing a login page. The default password is `password`. You can change this password by setting the `BOTPRESS_PASSWORD` env variable:

```bash
heroku config:set BOTPRESS_PASSWORD=<PASSWORD>
```

### Using Postgres as the database  [[Why make SQL the database by default if it creates and extra step and doesn't work with Heroku which is likely the default host?]]

By default Botpress uses SQLite as a database for persistence. This doesn't work well on Heroku because it has ephemeral storage, which means data will get lost every day or so. The best is to switch the database to Postgres:

```bash
# Get a free Postgres database
heroku addons:create heroku-postgresql

# Tell Botpress to use Postgres
heroku config:set DATABASE=postgres
```

And we're done!

## Website deployment

You can embed the bot on your website with the following snippet. Just make sure to replace `<<HOST>>` by your Heroku URL, e.g. `https://glacial-inlet-45783.herokuapp.com`

```html
<script src="<<HOST>>/api/botpress-platform-webchat/inject.js"></script>
<script>window.botpressWebChat.init({ host: '<<HOST>>' })</script><commit_msg>Update trivia_deploying.md<commit_after>---
layout: guide
---

# 🚀 Deploying our bot

Now that our bot is ready, we're ready to deploy it to Heroku.

## Heroku

We're using Heroku because it's fast, easy and free to deploy and manage your bot from there.

### Prerequisites

- If you don't already have a Heroku account, you can create one for free [here](https://signup.heroku.com).

- Install the Heroku CLI by following [these instructions](https://devcenter.heroku.com/articles/heroku-cli).

- Type `heroku login` in your terminal to login to heroku

### Git

Let's init a git repo in our bot directory:

```bash
git init

git add .

git commit -m "First commit"
```

Then let's create a Heroku App:

```bash
heroku create

# Creating app... done, ⬢ glacial-inlet-29943
# https://glacial-inlet-29943.herokuapp.com/ | https://git.heroku.com/glacial-inlet-29943.git
```

Alright, now let's actually deploy our app:

```bash
git push heroku master
```

And you're done! You should see something like:

```bash
remote:        https://glacial-inlet-29943.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/glacial-inlet-29943.git
 * [new branch]      master -> master
```

For more information about how to setup Heroku, [read this](https://devcenter.heroku.com/articles/git).

## Configuring our app

Your bot is now live at the URL that Heroku just gave you in the last command run. If you open that URL you'll notice that you are facing a login page. The default password is `password`. You can change this password by setting the `BOTPRESS_PASSWORD` env variable:

```bash
heroku config:set BOTPRESS_PASSWORD=<PASSWORD>
```

### Using Postgres as the database

By default Botpress uses SQLite as a database for persistence. This doesn't work well on Heroku because it has ephemeral storage, which means data will get lost every day or so. The best is to switch the database to Postgres:

```bash
# Get a free Postgres database
heroku addons:create heroku-postgresql

# Tell Botpress to use Postgres
heroku config:set DATABASE=postgres
```

And we're done!

## Website deployment

You can embed the bot on your website with the following snippet. Just make sure to replace `<<HOST>>` by your Heroku URL, e.g. `https://glacial-inlet-45783.herokuapp.com`

```html
<script src="<<HOST>>/api/botpress-platform-webchat/inject.js"></script>
<script>window.botpressWebChat.init({ host: '<<HOST>>' })</script>
{'fraction_non_alphanumeric': 0.10757605885862001, 'fraction_numerical': 0.011930801352157487, 'mean_word_length': 4.143149284253579, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4925766', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1526, 'n_words': 640}