This directory contains a Zapier-like Admin Panel for building chatbots with live preview and Supabase persistence.
- From
ai-coding-tutor
:
npm install
- Set env vars in
.env
:
NEXT_PUBLIC_SUPABASE_URL=...
NEXT_PUBLIC_SUPABASE_ANON_KEY=...
npm run dev -- -p 3010
Open http://localhost:3010/admin/chatbots
Execute supabase.sql
on your database (via SQL editor):
ai-coding-tutor/supabase.sql
It creates the chatbots
table, indexes, RLS policies, and an updated_at
trigger.
Insert a row in Supabase SQL editor (replace owner_id
with your auth UID):
insert into chatbots (owner_id, name, slug, greeting, directive, starter_questions, brand_color, is_public)
values (
auth.uid(),
'Example Bot',
'example-bot',
'How can I help you today?',
'You are a helpful assistant.',
'{"What can you do?","Help me write a message","Explain this concept simply"}',
'#3B82F6',
true
);
app/admin/chatbots
– list, new, and edit builder pagesapp/c/[slug]
– public previewsrc/components/builder/*
– section forms and builder shellsrc/components/preview/ChatPreview.tsx
– live previewsrc/data/*
– Supabase data layer and typessrc/lib/supabase.ts
– Supabase clientsupabase.sql
– schema, policies, trigger
npm run test
Includes:
- slug generation and availability
- form validation (Instructions, Settings)
- preview render
- Autosave triggers after ~1.5s of idle and on blur; use Ctrl/Cmd+S to force save.
- The “Generate a greeting with AI” button uses a local stub
suggestGreeting()
; replace with your own API call if desired. - Public preview available at
/c/:slug
for bots withis_public=true
.
For local development, you can enable a server-only route that uses the Supabase Service Role to upsert/read chatbots. Add to .env.local
(never commit this key):
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
NEXT_PUBLIC_DEV_NO_AUTH=true
Seed a bot:
curl -X POST -H 'content-type: application/json' \
-d '{"slug":"demo","name":"Demo Bot","is_public":true}' \
http://localhost:4010/api/dev/ensure-chatbot