Supabase Blog

Build a Personalized AI Assistant with Postgres

thumbnail

Table of Contents

  1. Introduction
  2. Scoped Schema
  3. System Table Protection
  4. Scheduled Prompts
  5. Self-Evolving System Prompt
  6. Use Cases
    • Run Tracking
    • Personal Recipe & Meal Planning
    • Company Feedback Analysis
    • Interest-Based Article Bookmarker
  7. Implementation Guide
    • Prerequisites
    • Step 1: Database Setup
    • Step 2: Edge Functions
    • Step 3: Telegram Bot
    • Step 4: Environment Variables
    • Step 5: Test Integration
  8. Cost Considerations
  9. Make it Your Own

Introduction

Building a personalized AI assistant using Postgres, LLMs, and other tools to create a flexible system with autonomy and real-time information retrieval capabilities.

Scoped Schema

LLM owned database schema through an execute_sql tool for data operations within a specific schema.

System Table Protection

Ensuring that all other schemas are inaccessible to the LLM, maintaining data security and integrity.

Scheduled Prompts

Automated tasks for recurring actions based on user prompts, integrating database operations, web searches, and external tool interactions.

Self-Evolving System Prompt

Combining base system behaviors with personalized communication styles based on user feedback, creating a unique and evolving user experience.

Use Cases

  • Run Tracking: Tracking daily runs, sending reminders, and analyzing running patterns.
  • Personal Recipe & Meal Planning: Tracking meals, suggesting recipes, and assisting with meal planning.
  • Company Feedback Analysis: Analyzing support tickets, providing feedback summaries, and actionable insights.
  • Interest-Based Article Bookmarker: Tracking and recommending articles on specific topics of interest.

Implementation Guide

Prerequisites

Setting up Supabase account, OpenAI API key, Telegram bot token, and optional Zapier account.

Step 1: Database Setup

Running migration SQL in Supabase SQL editor to set up extensions, schema, and permissions.

Step 2: Edge Functions

Creating main AI brain function, webhook handlers, response formatter, and delivery handler in the Supabase dashboard.

Step 3: Telegram Bot

Creating a Telegram bot, setting up webhook for message handling.

Step 4: Environment Variables

Setting environment variables in the Supabase project settings for configuration.

Step 5: Test Integration

Testing the integration by trying out commands with the Telegram bot.

Cost Considerations

Analyzing the monthly costs based on usage for the components like Supabase, OpenAI, Telegram, and Zapier.

Make it Your Own

Encouragement to customize and build upon the provided framework to create unique personalized AI assistants for various use cases. Check out the GitHub repository for further details and contributions.