Natural Language Queries and Chatbot Support | AllegroGraph 9.0.1
Author: Franz Incorporated

Copyright (c) 2005 - 2026 Franz, Incorporated
Last updated 27 May 2026 at 10:34

# AllegroGraph 9.0.1 Natural Language Queries and Chatbot Support

- Documentation Index
  - Release Notes
  - Quick Start
  - SSL/TLS Quick Start
  - Introduction
  - Setup and Configuration
    - Download
    - Server Installation
    - Server Configuration and Control
    - WebView
    - Database Upgrading
    - Managing Users
  - Server Management
    - Performance Tuning
    - Deleting Duplicate Triples
    - Purging Deleted Triples
    - Auditing
    - Managing Users
    - Replication
    - Point-in-Time Recovery
    - Transaction Log Archiving
    - Security Overview
    - Security Implementation
  - Tools
    - agtool
    - Data Loading
    - Data Export
    - Backup and Restore
    - Querying
    - RDFS++
    - Materializer
    - Event Scheduler
    - SHACL
  - Details
    - Triple Indices
    - Freetext Indices
    - Encoded IDs
    - Connection Pooling
    - N-dimensional Geospatial Overview
    - 2-D Geospatial
    - Temporal
    - Social Network
    - JavaScript
    - Datatypes
    - Data Conversion (Rapper)
    - Stored Procedures
    - Triple Attributes
    - Lineparse Format
  - Querying
    - SPARQL documentation summary
    - SPARQL Reference
    - SPIN
    - SPARQL Magic Properties
    - Prolog
  - 3rd-party tools
    - Solr text Indices
    - MongoDB integration
    - TopBraid Composer Plugin
    - Cloudera
  - Client APIs
    - Gruff
    - GraphTalker
    - REST/HTTP interface
    - HTTP reference
    - Javadocs (Sesame and Jena)
    - Python API
    - Lisp Reference
    - JavaScript
  - Tutorials
    - N-dimensional Geospatial
    - SPARQL Tutorial
    - Java Sesame
    - Java Jena
    - Python Sesame
    - Lisp
    - Prolog
    - More...
  - Other
    - Conferences and Seminars
    - Source Code on Github
    - Amazon EC2
    - Copyrights
  - Franz, Inc.

- Introduction
- Starting the Chatbot
- Repos created by chatbots
- Specifying API keys in your AllegroGraph configuration file

Documentation Index

## Introduction

Queries in RDF databases are typically written in SPARQL or Prolog, but natural language queries (that is, questions in plain English) are also supported when dealing with AI tools and features. Here we point to some examples in other documents that support natural language queries.

- ChatStream - Natural Language Querying
- LLM chatState Magic Predicate Details
- RAG (Retrieval Augmented Generation) example

A Chatbot is "a software application or web interface that is designed to mimic human conversation through text or voice interactions" Wikipedia. AllegroGraph supports various Chatbot applications. Examples include the Chomsky Chatbot and the Chomsky Chatbot with memory. With memory means that information from the user appearing in the chat is added to the database and can itself be queried.

We also have a Chatbot tool in WebView and we describe that tool in this document. When you use a Chatbot, you have to decide whether you want information from the user to be stored in some fashion. This may be desirable, particularly if the users interactions may affect later questions and responses. Or you may not want your knowledge base crowded with information about random users.

We base our discussion on the Chomsky example. There are two such examples, a plain Chatbot and a Chatbot with memory, both linked to above. In this document, we work with those examples using the WebView tool to manipulate them.

You can try this in AllegroGraph.cloud. All AllegroGraph.cloud servers have the chomsky and chomsky-vec repositories created and available. Other examples in this documentation using the Chomsky data name the repositories `chomsky47` and `chomsky47-vec` but they contain the same data. Since the images are made in a local (not cloud) AllegroGraph, we use the chomsky47 names.

You can run this example in AllegroGraph.cloud as described in Building a Stateful Chatbot or in your own version of AllegroGraph 8.2.0 or later. Just get and load the Chomsky data and create the associated vector database, as described here for the Chomsky Chatbot and here for the Chomsky Chatbot with memory.

Note that interaction using natural language queries and Chatbots often requires support keys for interaction with models. You must obtain your own keys and supply them when needed in your running AllegroGraph.cloud instance. The keys shown below in text and in illustrations are not valid OpenAI API or serpAPI keys. They are used to illustrate where your valid key will go.

To get an OpenAI API key go to the OpenAI website and sign up. To get a serpAPI key, go to https://serpapi.com/.

The actual openaiApiKey starts with `sk-` followed by a lot of numbers and letters. The serpApiKey is just a lot of numbers and letters. In the query option prefixes just below, the keys are preceded with `franz:` and the whole thing is wrapped in angle brackets. Similarly for the query options just below that.

As a query option prefix, write (the keys are not valid, replace with your valid key(s)):

    PREFIX franzOption_openaiApiKey: <franz:sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno>

    PREFIX franzOption_serpApiKey: <franz:11111111111120b7c4d3d04a9837e3362edb2733318effec25c447445dfbf594>

If you have downloaded the Chomsky data and are using your own running AllegroGraph see below for information on how you can put the keys in the configuration file.

## Starting the Chatbot

You can start a Chatbot, once you have opened the correct repo (chomsky47 in our case). You must set things up by specifying a valid key and optionally providing more information.

Click on Manage Chatbots from the Repository Control menu displayed by Repository control in the Repository menu to the left:

That takes you to a page for Chatbots, with none listed (as none have been created).

Click on the Add New Chatbot button on the right. That displays a page with some areas needing required information and many other optional fields.

You can specify an id (one is suggested for you), and name the vector database (chomsky47-vec in our case), and enter your OpenAI API key. There are many more choices under Advanced Settings.

Click on the CREATE button and you go to a Chatbot query page.

Questions are entered at the bottom of the page. We have asked some questions already. Note we entered `My name is David` and subsequently the Chatbot answered correctly when asked `What is my name?` as the conversation history is remembered.

You can create a new Chatbot with Repository | Repository Control | Manage chatbots You can create a new Chatbot window by choosing ChatStream - Bot from the New Query menu on the Query page:

That action will ask you to choose from existing Chatbots (if you have only one, that is the one you get).

## Repos created by chatbots

A couple of repos are created by the Chatbot process, as shown in this image:

You see a ChatStateLog and a my-chat-bot-history-vdb-w-Laq vector database (the names you see may be different).

At any time, you can delete a Chatbot page (that does not delete the chatbot which can be brought up again on a new Chatbot page). You can also click the Clear History button which clears the chat history. (The history is also kept in the auxilliary repo `chatStateLog` which is a permanent record of all transcripts from all chatbots. To really delete all history, you need to clear the (relevant portion of the) chatStateLog repo. Clear History allows the client to start a fresh new conversation, without any long-term memory of this client's conversations before.)

## Specifying API keys in your AllegroGraph configuration file

You can use this syntax in the AllegroGraph config file (usually agraph.cfg) which causes the option to be applied to all queries (see the Server Configuration and Control document for information on the config file):

    QueryOption openaiApiKey=sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno

    QueryOption serpApiKey=11111111111120b7c4d3d04a9837e3362edb2733318effec25c447445dfbf594

You can also put the value in the file data/settings/default-query-options file:

    (("franzOption_openaiApiKey" "sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno"))

    (("franzOption_serpApiKey" "11111111111120b7c4d3d04a9837e3362edb2733318effec25c447445dfbf594sk"))

Remember your key is valuable (its use may cost money and others with the key can use it at your cost) so protect it.