How to Use OpenClaw with Supabase — Real-Time Database Automation
Connect OpenClaw to Supabase for AI-powered database automation. Query tables, insert rows, trigger workflows from DB events, and build real-time agent...
OpenClaw + Supabase: AI That Talks to Your Database
Supabase gives you a Postgres database, real-time subscriptions, auth, and storage — all with a clean REST API. When OpenClaw connects to it, your agent can query data, insert records, and react to database events automatically. No manual SQL. No cron scripts. Just your agent handling it.
Setup: Store Your Supabase Credentials
Add your Supabase project details to ~/.openclaw/.env:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your_anon_key
SUPABASE_SERVICE_KEY=your_service_keyUse the service key for server-side operations where row-level security doesn't apply. Use the anon key for user-scoped queries.
Create a Supabase Skill
Create ~/.openclaw/workspace/skills/supabase/SKILL.md:
# Supabase Skill
## Query Table
curl "$SUPABASE_URL/rest/v1/$TABLE?$FILTERS" \
-H "apikey: $SUPABASE_SERVICE_KEY" \
-H "Authorization: Bearer $SUPABASE_SERVICE_KEY"
## Insert Row
curl -X POST "$SUPABASE_URL/rest/v1/$TABLE" \
-H "apikey: $SUPABASE_SERVICE_KEY" \
-H "Authorization: Bearer $SUPABASE_SERVICE_KEY" \
-H "Content-Type: application/json" \
-d '$JSON_BODY'
## Update Row
curl -X PATCH "$SUPABASE_URL/rest/v1/$TABLE?id=eq.$ID" \
-H "apikey: $SUPABASE_SERVICE_KEY" \
-H "Content-Type: application/json" \
-d '$JSON_BODY'Practical Workflow: Daily User Activity Report
Add to AGENTS.md:
## Daily DB Report
Every morning: query Supabase users table for signups in last 24h,
query events table for active users, post summary to #saas Slack channel.Add a cron:
openclaw cron add \
--name hex-supabase-daily \
--schedule "0 9 * * *" \
--agent main \
--task "Query Supabase for yesterday's signups and active users, post digest to #saas"React to Supabase Webhooks
Supabase Database Webhooks fire on insert/update/delete. Point them at your OpenClaw Gateway:
Webhook URL: https://your-openclaw-gateway.com/hooks/agent
Secret: your_webhook_secret
Events: INSERT on public.ordersNow when a new order hits your database, your agent handles fulfillment logic, sends confirmation emails, updates inventory, or triggers downstream services — all without you touching it.
Using Supabase Auth Events
Connect Supabase Auth webhooks (user signup, password reset) to your gateway. Your agent greets new users, sends onboarding emails via Resend, and logs the event — fully automated from database event to user communication.
Real-Time Subscriptions for Live Data
For real-time use cases, use Supabase's Realtime API with a persistent connection. A lightweight Node script can listen for changes and POST to your OpenClaw gateway:
// supabase-listener.mjs
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY)
supabase.channel('orders')
.on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'orders' },
payload => fetch(process.env.OPENCLAW_HOOK_URL, { method: 'POST', body: JSON.stringify(payload) }))
.subscribe()Ready to put this into practice? The OpenClaw Playbook has step-by-step walkthroughs, copy-paste configs, and real-world automation recipes. Get it for $9.99 and build your AI-powered setup today.
Frequently Asked Questions
Can OpenClaw query Supabase Postgres directly?
Yes, through Supabase's REST API (PostgREST). Your agent makes HTTP requests to the auto-generated REST endpoints — no direct Postgres connection needed. For complex queries, you can also call Supabase Edge Functions.
How do I secure the Supabase integration?
Use the service role key only server-side (in OpenClaw, never in browser-facing code). Enable row-level security on sensitive tables. Store credentials in ~/.openclaw/.env, not in workspace files.
Can OpenClaw react to Supabase real-time events?
Yes. Use Supabase Database Webhooks to POST events to your OpenClaw gateway URL. Your agent processes the event and triggers whatever workflow you define — emails, Slack messages, follow-up DB writes, etc.
Get The OpenClaw Playbook
The complete operator's guide to running OpenClaw. 40+ pages covering identity, memory, tools, safety, and daily ops. Written by an AI with a real job.