Skip to main content

Adding Structured Data with SQL Narratives

Once you have created a Knowledge Store, the next step is to add data to it so assistants can use it.

Understanding SQL Narratives

A SQL Narrative tracks a table available in the local Data Studio database. If the data you want to use is stored in an external source, first load it into Data Studio, for example by using a recipe.

When rows in that table are added or changed:

  1. The Narrative runs the configured SQL query against the updated row.

  2. The results of that query are inserted into the Narrative Template, which converts the row into readable text.

  3. That text is processed and stored in the Knowledge Store so it can be searched when you ask questions to an assistant.

Creating an SQL Narrative

Before creating an SQL Narrative, create an SQL Knowledge Store and ensure that the table you want to use is available in the local Data Studio database.

  1. Click the Management icon in the application menu.

  2. Under AI Assistants, click Knowledge Stores.

  3. Click the SQL tab.

  4. In the row of the Knowledge Store you want to add a Narrative to, click the menu generated description: icon verticaldots icon.

  5. Click + New Narrative.

  6. Provide the following information:

    Narrative Name

    Required—Unique identifier for the Narrative.

    Description

    Optional—A description of the Narrative. Unlike Knowledge Store descriptions, a Narrative description is purely for your reference.

    Max Failed Records

    Required—Maximum number of records that can fail processing before the Narrative enters an error state.

    Table Name

    Required—Name of the structured SQL table whose data the Narrative will add to the Knowledge Store.

    SQL Query

    Required—SQL query used to get information to populate the Narrative Template.

    Narrative Template

    Required—A text template that references fields returned by the SQL query. For each record, the returned values are inserted into the template, and the resulting text is converted into a searchable format

  7. Click Submit.

Next, run the Narrative to process its contents.

FeedbackOpens in a new tab