Prerequisites
Before you begin:- Node.js 18+ installed
- A Supabase account (free tier works)
- The Agility source code
- Basic familiarity with SQL and command line
Step 1: Create a Supabase Project
Sign up for Supabase
Go to supabase.com and create an account if you haven’t already.
Create a new project
- Click “New Project”
- Choose your organization
- Enter project details:
- Name: agility (or your preferred name)
- Database Password: Generate a strong password and save it securely
- Region: Choose the region closest to your users
- Click “Create new project”
Project creation takes 2-3 minutes. Supabase sets up your database, API, and authentication services.
Step 2: Configure Database Schema
Agility requires several database tables to store workflows, agent configurations, and credentials.Required Tables
Create the following tables in your Supabase project:1. user_workflows
Stores user workflow definitions.
2. agent_configs
Stores agent configuration and credentials.
3. agent_connections
Stores connections between agents in workflows.
4. agent_outputs
Stores agent execution results.
5. user_gmail_credentials
Stores encrypted Gmail OAuth credentials.
Running the Schema
Create tables
Copy and paste each table creation script above into the SQL Editor and run them one at a time.
Step 3: Configure Authentication
Agility uses Supabase Auth for user management.Enable email authentication
- Go to Authentication → Providers
- Ensure “Email” provider is enabled
- Configure email templates if desired
Configure auth settings
In Authentication → Settings:
- Site URL: Your production domain (e.g.,
https://yourdomain.com) - Redirect URLs: Add allowed redirect URLs (your domain +
/gmail-oauth-callback)
Step 4: Install Supabase CLI
The Supabase CLI is required to deploy edge functions.Installation
Login to Supabase
Link to Your Project
Find your project ref in Supabase Dashboard → Settings → General → Reference ID
Step 5: Configure Edge Function Secrets
Edge functions need access to sensitive configuration via secrets.Set Required Secrets
Verify Secrets
ENCRYPTION_KEYGOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGMAIL_OAUTH_REDIRECT_URI
Step 6: Deploy Edge Functions
Agility includes multiple edge functions that need to be deployed.Deploy All Functions
supabase/functions directory:
generate-text- Text generation using OpenAI/Anthropicgenerate-workflow- AI workflow generationgmail-oauth- Gmail OAuth flow handlerread-gmail- Read emails from Gmailsend-gmail- Send emails via Gmailread-github- Read GitHub repository eventsgithub-webhook- Handle GitHub webhookssetup-github-webhook- Configure GitHub webhookssend-discord- Send messages to Discordmanage-workflows- Workflow CRUD operationsmanage-agent-configs- Agent configuration managementmanage-connections- Connection managementmanage-api-keys- API key managementmanage-gmail-credentials- Gmail credentials managementrun-workflow- Execute workflows
Deploy a Single Function
Verify Deployment
View Function Logs
Step 7: Set Up Google Cloud Project (for Gmail)
To use Gmail agents, you need to configure Google OAuth.Create Google Cloud project
- Go to Google Cloud Console
- Click “Select a project” → “New Project”
- Enter project name: “Agility” (or your preferred name)
- Click “Create”
Enable Gmail API
- In the Google Cloud Console, go to “APIs & Services” → “Library”
- Search for “Gmail API”
- Click “Gmail API” and then “Enable”
Configure OAuth consent screen
- Go to “APIs & Services” → “OAuth consent screen”
- Choose “External” user type
- Fill in required fields:
- App name: Agility
- User support email: Your email
- Developer contact: Your email
- Click “Save and Continue”
- Add scopes:
https://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/userinfo.email
- Add test users if in testing mode
- Click “Save and Continue”
Create OAuth credentials
- Go to “APIs & Services” → “Credentials”
- Click “Create Credentials” → “OAuth 2.0 Client ID”
- Choose “Web application”
- Enter name: “Agility Web Client”
- Add “Authorized redirect URIs”:
http://localhost:3000/gmail-oauth-callback(for development)https://yourdomain.com/gmail-oauth-callback(for production)
- Click “Create”
- Save the Client ID and Client Secret
Step 8: Test the Setup
Verify your Supabase setup is working correctly.Test Database Connection
-
Run your Next.js app locally:
- Sign up for an account
- Create a simple workflow
-
Check Supabase Dashboard → Table Editor →
user_workflowsto see the data
Test Edge Functions
- Configure a Text Generator agent with an OpenAI API key
- Click “Test Agent”
- Check Supabase Dashboard → Edge Functions → Logs for any errors
Test Gmail Integration
- Add a Gmail Sender or Gmail Reader agent
- Click “Authorize Gmail”
- Complete the OAuth flow
- Check
user_gmail_credentialstable for encrypted credentials
Backup and Recovery
Database Backups
Supabase automatically backs up your database daily on paid plans. For the free tier:Migration Management
For production deployments, use migrations:Monitoring and Maintenance
Database Monitoring
- Monitor database size in Supabase Dashboard → Database → Usage
- Set up alerts for high connection counts
- Review slow query logs regularly
Edge Function Monitoring
- Check function invocation counts and errors in Dashboard → Edge Functions
- Monitor response times
- Review logs for unusual patterns
Security Audits
Troubleshooting
”Failed to fetch” Errors
Cause: CORS or network connectivity issues. Solution:- Verify Supabase URL is correct
- Check that edge functions are deployed
- Review CORS configuration in edge functions
RLS Policy Errors
Cause: Row Level Security preventing data access. Solution:- Test policies in SQL Editor:
- Verify user is authenticated
- Check policy conditions match your use case
Edge Function Timeouts
Cause: Function execution exceeds time limit (default 30s). Solution:- Optimize function code
- Use Supabase async patterns
- Increase timeout if on paid plan
Gmail OAuth Fails
Cause: OAuth configuration mismatch. Solution:- Verify redirect URI exactly matches Google Cloud Console
- Check Gmail API is enabled
- Ensure app is published or user is added as test user
- Review edge function logs for detailed error messages
Production Checklist
Before going live: ✅ All database tables created with RLS enabled✅ All edge functions deployed successfully
✅ All required secrets configured
✅ Google OAuth configured with production redirect URI
✅ Database backups enabled
✅ Authentication settings configured correctly
✅ Test user sign-up and login flow
✅ Test workflow creation and execution
✅ Test agent configurations
✅ Test Gmail OAuth flow
✅ Monitor edge function logs for errors
Next Steps
- Environment Variables - Configure all required variables
- Deployment Overview - Deploy the frontend application