Skip to main content

What is n8n

n8n is a workflow automation platform that lets you connect apps, APIs, and AI models to build automated workflows. It’s commonly used to build AI agents, where a large language model is given tools and memory to carry out multi-step tasks. This page shows you how to use Xata with n8n. Since Xata is fully PostgreSQL-compatible, you can use it anywhere n8n supports PostgreSQL.

Use Xata as memory for AI agents

The most common way to use Xata with n8n is as the memory store for an AI agent, so that the agent can persist and recall chat history across runs.
When adding a memory provider to your agent, n8n shows a dedicated Xata option. This option is out of date, so don’t use it. Instead, use the Postgres Chat Memory option and point it at your Xata branch, as described below.

Prerequisites

  • A Xata account with a project and branch
  • An n8n instance (cloud or self-hosted)

Steps

  1. In your n8n AI agent, add a memory provider and choose Postgres Chat Memory (not the Xata option).
n8n memory provider list showing Postgres Chat Memory and the out-of-date Xata option
  1. In the Xata console, open the Overview tab of your branch and copy the connection string shown at the top of the page.
Xata project overview showing the PostgreSQL connection string A Xata connection string looks like this:
postgresql://xata:<password>@<host>.us-east-1.xata.tech:5432/xata?sslmode=require
In the Xata UI, you can copy each field (host, poassword, port, etc.) by simply clicking it.
  1. Create a new PostgreSQL credential in n8n and copy the values from the connection string field by field:
    n8n fieldValue from connection string
    HostThe host, e.g. <host>.us-east-1.xata.tech
    Databasexata
    Userxata
    PasswordThe password from the connection string
    Port5432
n8n PostgreSQL credential form filled in with Xata connection details
  1. Leave Ignore SSL Issues (Insecure) off and set SSL to Allow.
n8n PostgreSQL SSL settings with SSL set to Allow and port 5432
  1. Save the credential and test the connection. It should connect successfully, and your AI agent will now store its chat memory in Xata.

Next steps

  • Enable scale-to-zero. In your branch settings, enable scale-to-zero (a suggested inactivity time is 1 hour) so the branch pauses when it’s not in use. This way you only incur compute costs while the branch is active. See Scale to zero for details.
  • Move beyond the free trial. To keep using Xata after the free trial, add a credit card in the billing system. Xata charges only for the resources you use. There is no minimum fee.