Skip to content

Postgres Chat Memory

Postgres Chat Memory stores the message history of a conversation in a PostgreSQL database owned by your company and retrieves it when needed. This way, components that answer questions take into account what was said before, and the history stays in your database.

Each history is identified by a Session ID: messages with the same identifier form one conversation.

When to use it

  • Your data policy requires an assistant’s conversations to be stored in a company database.
  • You want to review or analyse the conversations later with your own tools.
  • You already use PostgreSQL and prefer to keep your assistants’ history there.

Configuration

Before you start you need a PostgreSQL database that NappAI can reach and a credential of the Postgres SQL service with its connection address. See Credentials.

FieldWhat it does
Credential (required)The credential of the Postgres SQL service. Pick one with Choose an option or create one with Add new credential.

Advanced options

FieldWhat it does
Session IDThe identifier of the history. Type it or connect it, for example to the customer number. Conversations with the same Session ID share their history.

Output

Memory is the conversation history. Connect it to the External Memory input of Retrieval QA History, which reads the history before answering and saves each question and answer to it, or of Chat Memory, which reads the stored messages to use them elsewhere in the flow. If you connect it to Chat Memory, the Session ID of Chat Memory is used.

It does not connect to the Memory input of agents. To store an agent’s memory in PostgreSQL, use Postgres Memory.

Example

Seguros Arce has an assistant that answers policy questions from its general terms and conditions:

  1. Create a Postgres SQL credential with the insurer’s database.
  2. Add Postgres Chat Memory, choose that credential and connect the customer’s policy number to Session ID.
  3. Connect Memory to the External Memory input of Retrieval QA History.

Every question and answer is stored in Seguros Arce’s database, and the assistant understands follow-up questions like “and if the claim happened abroad?”.

Good practices

  • Use a different Session ID for each customer or case so histories don’t mix.