Build a RAG App

Create a retrieval-augmented generation app with Databases

In this tutorial, you’ll build a RAG (Retrieval-Augmented Generation) app that answers questions using your own data. This is a common pattern for building knowledge base assistants, documentation bots, and support agents.

Architecture: integrate your data into a Database, then query it with an LLM workflow.
1

Integrate your data

Scout stores your data in databases, which are groups of documents. Each document can contain metadata and text content. The text content is chunked and used for vector search. The metadata can be used to filter and sort the documents. Scout abstracts all of this complexity and provides a simple process to upload documents as outlined below:

  1. Sign up for free or sign in to Scout
  2. Once logged in, click “Databases” in the nav
  3. Click ”+ New”
  4. Name and create your database
  5. Once your database is provisioned, click it to open it
  1. Once inside the newly created database, you will be in the default Untitled table. Click the ”+” button to add columns.
  1. We’ll add two columns:
  • One named URL with a column type of URL
  • And one named Page Title with a column type of Single Line Text
  1. Once completed, our table should look as follows, with 3 columns:

There are 4 primary ways you can add documents to a database in Scout:

In this guide, we’ll build a database by scraping Scout’s docs (Scoutception?) but feel free to choose your own adventure for this section.

First, in your database, click “Sources” in the nav at the top, then click “Add Source” to start adding documents. Then, select the “Website Crawl” option.

  • Settings: Enter https://scoutos.com as the URL
  • Mapping: Map the crawl values to the colums we created in our table.
  • Frequency: For this example, we can skip the Frequency section. It’s used to schedule crawl refreshes; for example if you want to crawl your docs every week to keep the documents in your table up to date.
  • Click the “Create” button, then the “Run” button to start scraping the Scout website. You’ll see the progress and status of the process. Once it’s complete, move on to the next step to configure your workflow.
2

Configure your workflow

Workflows consist of inputs, composable blocks which represent different actions, and outputs. They can be created from scratch, cloned from an existing workflow, or started with a template. Each block is designed with its own set of configurations. In this guide, we’ll create a workflow that uses an input, a collection search, an LLM, and then output:

  • Click “Workflows” in the nav
  • Click ”+ New” to create a new workflow
  • Name your workflow and click the “Create” button. You’ll see your empty workflow canvas:
  • At the bottom of the workflow canvas click the ”+” button and drag a new Scout > Query Collection Table block onto the workflow canvas
  • Then, click the newly created query block, and modify its configurations as follows:
    • Database: Use the dropdown to select your database
    • Table: Use the dropdown to select your table
    • Query: This should be {{inputs.user_message}} in order to supply the RAG app’s input to the database query
  • Everything else can be left as default. Click the “Save” button in the upper right-hand corner. Your settings should look as follows, except for the Database ID should be your unique value as mentioned above:

At the bottom of the workflow canvas click the ”+” button and drag a new AI > LLM block onto the workflow canvas

Then, click the newly created LLM block, and modify its configuration sections as follows:

  • First is the Configuration section, where we’ll use the following settings:
    • Model: We’ll use gpt-4o for this
    • Temperature: We’ll use 0.7 to keep it more factual
    • Maximum Tokens: We’ll use 2000 as we’ll be supplying our queried documents in the request
    • Response Type: text
  • Then we’ll configure the Chat Messages section as follows:
    • First, we’ll add a System Message
      • Click ”+ Add an item”
      • Then change Chat Messages-1: Single Message
      • Set Role: system
      • And paste the following prompt into Content
        You are an expert customer solutions engineer at Scout. Your role is to respond to user inquiries in a helpful and guiding manner. You have access to Scout's technical configuration documentation for developers, which is provided below. Please use this documentation to answer user questions accurately and thoroughly. If you are not confident in your answer or if a question falls outside the scope of the provided information, kindly inform the user that you do not have that information. Maintain a professional and courteous tone in all your responses. Do not speculate or provide information not supported by the documentation.
      • The final configuration for the System Message should look as follows:
    • Then, we’ll add the User Message
      • Scroll to the bottom of the Chat Messages section and click ”+ Add an item” to add another Chat Message
      • Then change the newly created Chat Messages-2: Single Message
      • Set Role: user
      • And paste the following prompt into Content:
        <<<Scout Technical Documentation>>>
        {{YOUR_COLLECTION_BLOCK.output}}
        <<</Scout Technical Documentation>>>
        <<<User Inquiry>>>
        {{inputs.user_message}}
        <<</User Inquiry>>>
        Important: You will need to replace the YOUR_COLLECTION_BLOCK.output variable in the snippet above with your actual query block ID. You can easily copy your query block ID by hovering over it and clicking copy. For example, mine would be collection_rmdz0c.output Lastly, click the “Save” button in the upper right-hand corner. Your RAG app (workflow) is ready!
3

Run your workflow

There are a variety of ways to run workflows; Slackbots, Scout’s embeddable Copilot, SDKs, API, directly from the Console in the Scout workflow UI, and many more.

In this guide, we’ll keep it simple and test the output directly from the Console in the Scout workflow UI:

On the upper left-hand side of the workflow canvas, click the play icon to open the Console.

In the User’s Message text area, paste the following query then click “Run”:

Please build me a guide including relevant code snippets and information I'd need to install the Scout Copilot module into my website.

The output will be automatically formatted and rendered below the input, and should look something like this:

Voila! And there you have it; you built a RAG app that can answer questions using your own data!

What’s Next?