---
title: "Build a Personalized AI Assistant with Postgres"
description: "A personal AI assistant with long-term memory can be built on Postgres by giving the LLM an execute_sql tool scoped to a dedicated `memories` schema and role, so it creates its own tables for structured facts."
url: "https://swe.quest/articles/build-a-personalized-ai-assistant-with-postgres-15f7faa56e099e86"
canonical: "https://supabase.com/blog/natural-db"
source: "Supabase"
published: "2025-06-25"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["ai-agents","postgres","llms","vector-search","serverless"]
---

# Build a Personalized AI Assistant with Postgres

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2025-06-25, 7 min read, How-to. Original: [https://supabase.com/blog/natural-db](https://supabase.com/blog/natural-db)

## Summary

A personal AI assistant with long-term memory can be built on Postgres by giving the LLM an execute\_sql tool scoped to a dedicated \`memories\` schema and role, so it creates its own tables for structured facts. Memory has three layers: recent message history, pgvector embeddings for fuzzy recall, and LLM-created SQL tables for precise queries. pg\_cron and pg\_net run scheduled prompts through the same Edge Functions, so the assistant can act on its own. It also uses OpenAI web search, Zapier MCP for external actions, Telegram as the interface, and a versioned, user-editable personality prompt. The setup guide covers migrations, Edge Functions and environment variables, and estimates about $0.54/month at 10 messages a day on GPT-4.1-mini.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)

## Prerequisites

- PostgreSQL schemas and roles ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- LLM tool calling ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- Serverless functions ([easy posts on Serverless](https://swe.quest/tags/serverless.md?difficulty=easy))

## Keywords

Supabase, pgvector, pg\_cron, pg\_net, MCP, Zapier, Telegram, OpenAI

## Related posts

- [Building an AI-powered ChatBot using Vercel, OpenAI, and Postgres](https://swe.quest/articles/building-an-ai-powered-chatbot-using-vercel-openai-and-postgres-4fd423473384581f.md): Neon · 2023-03-09 · Medium · 13 min read · RAG & retrieval, PostgreSQL, Vector search, LLMs, Serverless
  A ChatGPT-style documentation assistant (Ask Neon) is built by storing OpenAI text-embedding-ada-002 vectors in Postgres with pgvector, retrieving context by cosine distance, and feeding it to text-davinci-003 from a Vercel Edge Function.
- [Web-based AI SQL Playground and connecting to Postgres from the browser](https://swe.quest/articles/web-based-ai-sql-playground-and-connecting-to-postgres-from-the-browser-fa7f4eccd9643a37.md): Neon · 2023-05-19 · Medium · 5 min read · PostgreSQL, LLMs, Serverless, JavaScript
  Neon's Postgres AI Playground connects to a Postgres database directly from the browser and uses OpenAI's gpt-3.5-turbo to turn natural-language prompts into SQL.
- [database.build v2: Bring-your-own-LLM](https://swe.quest/articles/database-build-v2-bring-your-own-llm-b2a3b83eee7ef5a0.md): Supabase · 2024-12-06 · Medium · 11 min read · PostgreSQL, LLMs, Browsers, WebAssembly
  database.build, Supabase's in-browser Postgres sandbox built on PGlite, now lets users bring any OpenAI-compatible LLM, with no login and no rate limits.
- [Building a Deep Research Agent with Neon and Durable Endpoints](https://swe.quest/articles/building-a-deep-research-agent-with-neon-and-durable-endpoints-ef580145e6461602.md): Neon · 2026-02-24 · Medium · 12 min read · AI agents, PostgreSQL, Vector search, Resilience, LLMs
  A recursive deep research agent built on Neon Postgres with pgvector, Inngest durable endpoints, Claude, Exa search and OpenAI embeddings.
- [Building a GPT Backed by a Heroku-Deployed API](https://swe.quest/articles/building-a-gpt-backed-by-a-heroku-deployed-api-48a6672b2eb1e607.md): Heroku Engineering · 2024-03-28 · Medium · 15 min read · AI agents, LLMs, JavaScript, PostgreSQL
  A custom OpenAI GPT can be backed by a simple Express API on Heroku that answers natural-language questions about an employee directory.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
