Building a Stateful Chatbot Question-Answer System | 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 Building a Stateful Chatbot Question-Answer System

- 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
- Getting started
- Creating the Chatbot

Documentation Index

## Introduction

Creating a stateful chatbot is very straight forward and by way of example we will use the chomsky datasets that are already loaded and available in AllegroGraph.cloud. You can easily create a chatbot with your own data with only a few additional steps that are covered in our documentation.

(If you are using an installed AllegroGraph server, create repos as described here naming the repos `chomsky` and `chomsky-vec` rather than `chomsky47` and `chomsky47-vec`.)

The Chomsky Chatbot is built on AllegroGraph’s ChatStream functionality with the key feature being the chatState Magic Predicate which delivers 'Retrieval Augmented Generation with Feedback', or 'RAG with Feedback'. The term 'Feedback' in this case refers to storing short-term memories of the recent dialog in the long-term memory of a vector database.

The following assumes you have created an AllegroGraph.cloud account and are logged in.

You will also need your OpenAI API key that may be obtained from openai.com. (Keys shown in examples in the AllegroGraph documentation are not valid.) If you are doing this on a local machine you can use Ollama which does not require a key, but we use OpenAI in this example.

## Getting started

Open WebView and then open the `chomsky` repository. Choose Query from the Repository menu on the left, then select ChatStream Bot from the New Query drop down menu in the upper right.

You will be prompted with the option to first add your OpenAPI key or review documentation about this step. Select Navigate to the page.

In the Name field start typing openaiApiKey and select it. For the Value add your OpenAI API key. For the Scope you can just go with the default User but there are options to share your Chatbot with other AllegroGraph users.

Click on Save Query Options.

You are now set up to create a chatbot.

## Creating the Chatbot

Navigate back to the `chomsky` repository by clicking on `root` (the `root` catalog in the upper left and choosing the `chomsky` repo. Get to the Query page (if necessary) by clicking Query from the Repository menu on the left, then select ChatStream - Bot from the New Query drop down menu in the upper right.

You will see a dialog with links to create a chatbot and documentation.

Select this page to create the Chomsky ChatStream bot.

On this page, click on Select a vector database and choose chomsky-vdb from the choices. That vector database is already created in AllegroGraph.cloud. To learn more about creating a vector database from your own Knowledge Graph-RDF Data, the Embedding Knowledge Graph Specification document.

Click on the Create button.

There are many advanced options in the Advanced Settings. We do not go into these options in this example.

Click on the Create button at the bottom (out of the image) to create the Chatbot and get to the chatbot page.

From this dialog you can start chatting with Chomsky, make edits, and delete the Chatbot.

You can create additional Chatbots by selecting the Add new Chatbot button.

Click on the Chat button. You now have a Chatbot that is ready to answer questions based on the data contained in the Knowledge Graph which directs the Large Language Model (LLM). This is an example of Graph Retrieval Augmented Generation or Graph RAG.

Start typing your questions to the Chomsky Bot in the question field at the bottom.

We asked Who is Noam Chomsky? and this is the response:

You can explore the logic used in answering the questions. Click on the Show Bot Logic button. AllegroGraph provides extensive details for tuning the responses in order to ensure accurate answers and understand variability for reduced hallucinations. (The logic is cut off in the image.)

Because we have implemented chatState Magic Predicate in AllegroGraph, the conversation is stored in AllegroGraph and the Chatbot can draw upon this dialog history to maintain continuity.

Ask the Chatbot what you have discussed and based on the history it will provide a valid response that is in context with your dialog over time.