How to Deploy Flowise to Koyeb to Create Custom AI Workflows
Tags: webdev, ai, tutorial, openai
Published: 2024-04-26 08:31:00

[Flowise](https://flowiseai.com/) is an open-source, low-code tool for building customized LLM orchestration flows and AI agents. Through an interactive UI, you can bring together the best AI-based technologies to create novel processing pipelines and create context-aware chatbots with just a few clicks.

In this guide, we will demonstrate how to deploy Flowise to Koyeb to make it easy to build and share workflows and chatbots with users anywhere in the world. We will deploy a PostgreSQL database to persist our workflows, AI agents, and credentials. Afterwards, we will deploy the Flowise Docker image, configured with authentication, providing an internet-accessible instance of the platform.

You can deploy the application from this guide with [our Flowise One-Click app](https://www.koyeb.com/deploy/flowise) or by clicking the [Deploy to Koyeb button](https://www.koyeb.com/docs/build-and-deploy/deploy-to-koyeb-button) below:

[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?name=flowise&type=docker&image=flowiseai%2Fflowise&command=flowise&args=start&instance_type=small&env%5BAPIKEY_PATH%5D=%2Froot%2F.flowise&env%5BDATABASE_HOST%5D=CHANGE_ME&env%5BDATABASE_NAME%5D=CHANGE_ME&env%5BDATABASE_PASSWORD%5D=CHANGE_ME&env%5BDATABASE_PORT%5D=5432&env%5BDATABASE_SSL%5D=true&env%5BDATABASE_TYPE%5D=postgres&env%5BDATABASE_USER%5D=CHANGE_ME&env%5BFLOWISE_PASSWORD%5D=CHANGE_ME&env%5BFLOWISE_SECRETKEY_OVERWRITE%5D=CHANGE_ME&env%5BFLOWISE_USERNAME%5D=CHANGE_ME&ports=3000%3Bhttp%3B%2F)

Be sure to modify all of the environment variables values set to `CHANGE_ME` to reflect your own data. You can consult the information in this guide if you need additional information.

## Requirements

To successfully follow and complete this guide, you need:

- A [Koyeb account](https://app.koyeb.com) to provision the PostgreSQL database and the Flowise application.
- An [OpenAI API key](https://platform.openai.com/api-keys) to test Flowise functionality.

## Steps

To complete this guide and deploy Flowise, you'll need to follow these steps:

1. [Provision a PostgreSQL database on Koyeb](#provision-a-postgre-sql-database-on-koyeb)
2. [Deploy Flowise to Koyeb](#deploy-flowise-to-koyeb)
3. [Test Flowise Chatflows](#test-flowise-chatflows)
   - [Add your OpenAI API key](#add-your-open-ai-api-key)
   - [Choose a workflow template](#choose-a-workflow-template)
   - [Customize the workflow](#customize-the-workflow)

## Provision a PostgreSQL database on Koyeb

Before we can deploy Flowise, we need to provision a PostgreSQL database that we can use to persist application data including orchestration workflows, chat history, and credentials for AI providers. We will use [Koyeb's PostgreSQL service](https://www.koyeb.com/docs/databases) which includes a free tier that we can use to get started.

To deploy a new PostgreSQL database, on the **Overview** tab of the [Koyeb control panel](https://app.koyeb.com/), click **Create Database Service**. Choose a name for the service and choose the region closest to you or your users.

Once the database is provisioned, click on the `.env` option of the **Connection Details** tab. Click the **copy icon** to save the connection details for later.

## Deploy Flowise to Koyeb

Now that we have the connection details for a PostgreSQL database, we can deploy Flowise to Koyeb.

On the **Overview** tab of the [Koyeb control panel](https://app.koyeb.com/), click **Create Web Service** to begin:

1. Select **Docker** as the deployment method.
2. Set the **Docker image** to `docker.io/flowiseai/flowise`. Optionally, append an [image tag](https://hub.docker.com/r/flowiseai/flowise/tags) if you'd like to deploy a specific version.
3. In the **Deployment** section, click the **Override** toggle associated with **Command** and enter `flowise` in the field. Click the **Override** toggle associated with **Command args** and enter `start` in the field.
4. In the **Environment variables** section, click **Bulk edit** to enter multiple environment variables at once. In the text box that appears, paste the following:

   ```
   APIKEY_PATH=/root/.flowise
   DATABASE_TYPE=postgres
   DATABASE_SSL=true
   DATABASE_HOST=
   DATABASE_PORT=5432
   DATABASE_USER=koyeb-adm
   DATABASE_PASSWORD=
   DATABASE_NAME=koyebdb
   FLOWISE_SECRETKEY_OVERWRITE=
   FLOWISE_USERNAME=
   FLOWISE_PASSWORD=
   ```

   Set the variable values to reference your own information as follows:

   - `APIKEY_PATH`: Set to the directory in the Docker image to store Flowise API information. This should be `/root/.flowise`.
   - `DATABASE_TYPE`: Set to `postgres`.
   - `DATABASE_SSL`: Set to `true`.
   - `DATABASE_HOST`: Set to the PostgreSQL host copied from the Koyeb PostgreSQL connection details.
   - `DATABASE_PORT`: Set to the port PostgreSQL is listening to. This will be 5432 by default.
   - `DATABASE_USER`: Set to the PostgreSQL username copied from the Koyeb PostgreSQL connection details. This will be `koyeb-adm` by default if you didn't change it during provisioning.
   - `DATABASE_PASSWORD`: Set to the PostgreSQL password copied from the Koyeb PostgreSQL connection details.
   - `DATABASE_NAME`: Set to the PostgreSQL database name to connect to. This will be `koyebdb` by default.
   - `FLOWISE_SECRETKEY_OVERWRITE`: Set this to a random string that will be used to encrypt the credentials stored within the PostgreSQL database. You need to provide the same key whenever redeploying to be able to decrypt the credential information.
   - `FLOWISE_USERNAME`: Set this to the username you want to use to authenticate to the Flowise instance.
   - `FLOWISE_PASSWORD`: Set this to the password you want to use to authenticate to the Flowise instance.

5. In the **Instance** section, select size **Small** or larger.
6. Choose a name for the App and Service, for example `flowise-on-koyeb`, and click **Deploy**.

Koyeb will pull the Flowise Docker image from Docker Hub and deploy it using the configuration you provided. During the deployment process, Flowise will connect to the PostgreSQL database and initialize it to create the necessary data structures.

Once the deployment is healthy, visit your Koyeb Service's subdomain (you can find this on your Service's detail page). It will have the following format:

```
https://<YOUR_APP_NAME>-<KOYEB_ORG_NAME>.koyeb.app
```

You should see a Flowise landing page, protected by an authentication challenge. Enter the username and password you chose earlier to log in.

## Test Flowise Chatflows

Now that you have a Flowise instance, you can begin to use the platform to build complex workflows and AI agents. We can test out the basic functionality using a relatively simple flow.

### Add your OpenAI API key

First, navigate to the **Credentials** page from the left-hand menu. On the Credentials page, click **Add Credential**:

![Flowise add new credential](https://www.koyeb.com/static/images/tutorials/flowise/add_new_credential.png)

In the search field, enter "OpenAI" to filter the available options. Select **OpenAI API** to continue:

![Flowise choose OpenAI API](https://www.koyeb.com/static/images/tutorials/flowise/select_openai.png)

Choose a name for the new key (for example `OPENAI_API_KEY`) and enter your key in the appropriate field. Click **Add** when you're ready:

![Flowise add key](https://www.koyeb.com/static/images/tutorials/flowise/add_key.png)

### Choose a workflow template

Next, visit the **Marketplaces** page in the left-hand menu. Find the **Translator** template and click to select it:

![Flowise find translator template](https://www.koyeb.com/static/images/tutorials/flowise/find_translator_template.png)

You will be taken to the template's overview page where you can see the different components that are used and how they fit together. Click **Use Template** to copy the template to your workflows:

![Flowise use template](https://www.koyeb.com/static/images/tutorials/flowise/use_template.png)

### Customize the workflow

On the new view of the template, select your OpenAI API key in the **Connect Credential** field of the **ChatOpenAI** component:

![Flowise connect credential](https://www.koyeb.com/static/images/tutorials/flowise/connect_credential.png)

Click the **Save icon** in the upper-right corner and choose a name for your workflow. Once your workflow is saved, you can test it out.

To test the new workflow, click the **chat icon** on the right-hand side of the workflow screen. A chat session will start:

![Flowise begin chat session](https://www.koyeb.com/static/images/tutorials/flowise/begin_chat_session.png)

The translation workflow will translate any user input to another language. By default, the workflow will translate text from English to French. Type a sentence you'd like translated to try it out:

![Flowise testing French translation](https://www.koyeb.com/static/images/tutorials/flowise/testing_french_translation.png)

Next, click **Format Prompt Values** in the **Chat Prompt Template** component. Click the **edit icon** next to the `output_language` item and change it to a new language:

![Flowise change_to_Spanish](https://www.koyeb.com/static/images/tutorials/flowise/change_to_spanish.png)

Click the **Save icon** in the upper-right corner to save the change you just made. Open the chat box again and retry your prompt:

![Flowise testing Spanish prompt](https://www.koyeb.com/static/images/tutorials/flowise/test_spanish.png)

The response should be in the new language you selected.

## Conclusion

In this guide, we demonstrated how to deploy and configure Flowise on Koyeb. We began by setting up a PostgreSQL database and copying the connection details. Afterwards, we deployed the official Flowise Docker image to Koyeb, using environment variables to customize our configuration.

We've only scratched the surface on the capabilities that Flowise offers for constructing and deploying custom AI workflows and agents. Take a look at the [Flowise documentation](https://docs.flowiseai.com/) or their [official YouTube channel](https://www.youtube.com/@FlowiseAI) to learn more about what is possible.