How to Build a Chat App with Agent Cloud and PostgreSQL

Learn How to Build a RAG Chatbot Using Agent Cloud and PostgreSQL


Enterprises are turning to RAG (Retrieval-Augmented Generation) because it fundamentally changes how AI can be used for better decision-making.

RAG combines the power of information retrieval with AI generation, allowing businesses to:

  1. Leverage vast amounts of data: RAG unlocks the value of internal and external data sources, providing a more comprehensive picture for informed choices.
  2. Enhance accuracy and confidence: By grounding AI generation in reliable information, RAG reduces the risk of bias or errors in decision-making.
  3. Streamline the process: RAG automates parts of the information-gathering and analysis process, leading to faster and more efficient decision-making cycles.

RAG is a framework designed to improve language models by pulling in relevant, up-to-date data directly related to a user’s query and RAG chat apps allow you to chat with your data. 

In this blog, we will learn to build a RAG chatbot in minutes using AgentCloud

AgentCloud is an open-source platform enabling companies to build and deploy private LLM chat apps, empowering teams to securely interact with their data. 

  • AgentCloud uses Airbyte to build data pipelines, which allow us to split, chunk, and embed data from over 300 data sources, including Postgres. 
  • AgentCloud uses Qdrant as the vector store to efficiently store and manage large sets of vector embeddings. For a given user query the RAG application fetches relevant documents from vector store by analyzing how similar their vector representation is compared to the query vector.

So, let’s get started building a RAG chat application using Agent Cloud to talk privately and securely with your Postgres data.

Setting up Agent Cloud via Docker

To run AgentCloud locally, ensure Docker is installed. Follow these steps to get AgentCloud up and running.

  1. Clone the repo:

 git clone

  1. Navigate to the agentcloud directory: 

cd agentcloud

  1. Run this command: 

chmod +x && ./

Running the install command will download necessary Docker images and launch the containers.

Once the install script is executed successfully we can view the containers running in the docker app:

To access Agent Cloud in the browser, we can hit the below URL:


Next, we need to sign to the platform


Post sign-up, and log in to the App, to get to this landing screen.

Congrats, setup is complete now. Next, we will move towards building our RAG application.

Adding New Model

Agent Cloud allows us to use models like FastEmbed and OpenAI in app. 

To add a new model let’s go to the Models screen and click the Add Model option.

In the configuration screen, select a Model—such as the fast-bge-small-en for embedding text. Then, save your settings to finish the model setup.

Post successfully adding the model we will be able to view the model in the Models list.

Creating New Datasource

The data source for our app will be a Postgres table which contains information about Indian dishes. 

Here is the snapshot of the table data.

Our table features 181 Indian dishes representing various Indian states.

Here is a description of the table columns.

  1. name : Name of the dish
  2. ingredients : Main ingredients used
  3. diet : Type of diet - either vegetarian or non-vegetarian
  4. prep_time : Preparation time
  5. cook_time : Cooking time
  6. flavor_profile : Flavor profile includes whether the dish is spicy, sweet, bitter, etc
  7. course : Course of meal - starter, main course, dessert, etc
  8. state : State where the dish is famous or is originated
  9. region : Region where the state belongs
  10. meta_info: This column contains the dish information in an unstructured format. The column data will be embedded for vector search.

To integrate table data into our app, add the data source by navigating to the Data Source page, clicking the New Connection button, and selecting a source from the modal.

Let's choose Postgres as our data source and then configure the connection.

Here's what's needed to set up the Postgres data source.

  • Schedule type
  • Host name
  • Port
  • Password
  • Postgres username
  • Postgres password
  • Database name

Let's disabled the SSL modes as we're running Postgres on our local machine.

Next, we need to select the replication method; I have selected Xmin. 

Xmin replication is the new cursor-less replication method for Postgres. 

Cursorless syncs enable syncing new or updated rows without explicitly choosing a cursor field. The Xmin system column is used to track inserts and updates to your source data. 

Now, we need to click on the Test and Save button, which will first test the DB connection and, if successful, save the data connector.

We'll select the table and all its columns.

The column meta_info is selected for embedding, which means the vector search will be performed on the contents of this column.

Then we press the Continue button to create the Data Source.

It will take some time to embed the data, and post that you will be able to see this data in a new collection in the Qdrant collection dashboard. 

After setting up the data source, Agent Cloud uses Airbyte in the background to create a data pipeline between Postgres and Qdrant.

Once the sync is complete, the new collection will appear in the Qdrant DB.

Example of how the data is stored inside a Qdrant point.

Next, we will be setting up a tool for using our data source.

Setting up Tools

Tools are essential for enabling the AI agent to interact effectively with its environment, process information, and take appropriate actions to achieve its goals. 

The tools used by an AI agent can include functions, APIs, data sources, and other resources that help the agent perform specific tasks autonomously and efficiently. 

The tool we will be setting up will be responsible for querying the data source and fetching relevant documents. Agent Cloud creates a tool for us when we add a new data source by default.

The screenshot below shows that the Postgres Food data tool has been automatically created by the platform.

I have updated the tool configuration to change the description. 

This description is very important as it will be used by the Agent to decide which tool to use for a given task.

Click on the Save button to update the tool.

Creating Agent

An Agent is an intelligent system that can efficiently accomplish complex tasks. 

To create an Agent, let’s go to the Agents screen and click on the New Agent button.

In the Agent configuration, we need to provide certain information one of the information is the LLM Model. Agents use LLMs to enhance their capabilities and improve communication. 

We are using gpt-4-0125-preview OpenAI model for our agent.

Here are the remaining details needed for configuration:

  • Agent Name
  • Agent role
  • Agent Goal
  • Agent Backstory
  • Agent Tools

Now click on the Save button to complete the Agent configuration.

Creating Task

Tasks are specific assignments assigned to an agent for completion. 

To create a new task let’s click the `Add Task` button in the Task screen.

When configuring the task, provide the following information:

  • Task name
  • Task description
  • Task tools
  • Task Agent

Post that we can click on the Save button to save the configuration.

Creating App

So till now, we have created a data source for the App, a tool to retrieve to information from the data source, an LLM Agent that will be working on complex tasks using the tool, and a Task that will be assigned to the Agent based on the user’s instruction. 

Now we will be creating a conversational App that will allow us to chat with our data. 

To create the App, let’s go to the App screen and click on the New App button.

In the configuration page, let’s enter the app name and select the app type, which will be a conversation chat app in our case. 

Select the Task and Agent that we created. In the process, we will select sequential, and finally, in the Chat manager model, we will select the OpenAI GPT 4 model. 

Now we can click on the Save button to complete the app setup.

After completing the app setup, the newly created app will appear in the dashboard.

Now let's see the app in action by clicking the Play button.

A conversion window is opened for us where we can chat with our data.

Here is the app's response to our question.

Yay, we did it 😎


In this blog, we learned to build a RAG chat app with Agent Cloud and Postgres.

We covered creating a data source, embedding it, and storing it in Qdrant DB.

Additionally, we learned how to build tools for Agents and create an app where users can interact with their private data.

Explore other blog posts

see all