Supabase → Airtable Sync¶
This workflow automatically synchronizes data from a Supabase database to an Airtable base every minute, keeping coaching program data in sync across platforms. It handles coaches, youth profiles, messages, bottleneck diagnoses, and conversation records to maintain data consistency for reporting and analysis.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Schedule Trigger runs every minute to start the synchronization process
- Data Extraction pulls data from five Supabase tables simultaneously:
- Coaches information
- Youth profiles
- Messages from coaching sessions
- Bottleneck diagnoses
- Additional messages for conversation processing
- Message Processing transforms raw message data to extract content and type information
- Conversation Assembly groups messages by session and pairs human/AI interactions
- Data Upsert updates or creates records in corresponding Airtable tables using ID-based matching
The workflow processes all data streams in parallel for efficiency, with specialized handling for message data that requires transformation before storage.
Workflow Diagram¶
graph TD
A[Schedule Trigger] --> B[Coaches]
A --> C[Youth Profiles]
A --> D[Messages]
A --> E[BottleNeck Diagnoses]
A --> F[Messages1]
B --> G[Create or update coaches]
C --> H[Create or update youth profiles]
D --> I[Code in JavaScript]
E --> J[Create or update diagnoses]
F --> K[Search Conversations]
I --> L[Create or update messages]
K --> M[Create or update a record]
Trigger¶
- Type: Schedule Trigger
- Frequency: Every minute
- Execution: Runs continuously when workflow is active
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Schedule Trigger | Schedule Trigger | Initiates sync every minute |
| Supabase | Coaches | Retrieves coach data from Supabase |
| Supabase | Youth Profiles | Retrieves youth profile data |
| Supabase | Messages | Retrieves message data for processing |
| Supabase | BottleNeck Diagnoses | Retrieves bottleneck diagnosis data |
| Supabase | Messages1 | Retrieves messages for conversation assembly |
| Code | Code in JavaScript | Transforms message data structure |
| Code | Search Conversations | Groups messages into conversation pairs |
| Airtable | Create or update coaches | Syncs coach data to Airtable |
| Airtable | Create or update youth profiles | Syncs youth profiles to Airtable |
| Airtable | Create or update messages | Syncs processed messages to Airtable |
| Airtable | Create or update diagnoses | Syncs bottleneck diagnoses to Airtable |
| Airtable | Create or update a record | Syncs conversation records to Airtable |
External Services & Credentials Required¶
Supabase¶
- Credential: Supabase API credentials
- Tables accessed: coaches, youth_profiles, messages, bottleneck_diagnoses
- Permissions needed: Read access to all specified tables
Airtable¶
- Credential: Airtable Personal Access Token
- Base: "Iganga DB on Supabase" (appM1t4bTPBLfADiZ)
- Tables updated: Coaches, Youth Profiles, Messages, Bottleneck Diagnoses, Conversations
- Permissions needed: Read and write access to all tables
Environment Variables¶
No environment variables are explicitly configured in this workflow. All configuration is handled through n8n credentials and node parameters.
Data Flow¶
Input Data (from Supabase)¶
- Coaches: ID, name, gender, phone, email, role, language, region, district, contract type, availability, duty station, status, created date
- Youth Profiles: ID, name, phone, location, business type, current stage, timestamps, notes
- Messages: ID, session ID, message content (JSON), timestamps
- Bottleneck Diagnoses: ID, youth ID, stage, bottleneck name, AI reasoning, micro actions, timestamps, session ID
Output Data (to Airtable)¶
- Coaches Table: All coach fields mapped directly
- Youth Profiles Table: All profile fields mapped directly
- Messages Table: Processed message content with extracted type and text
- Bottleneck Diagnoses Table: All diagnosis fields mapped directly
- Conversations Table: Human-AI message pairs grouped by session
Data Transformations¶
- Message JSON objects are parsed to extract content and type
- Conversation messages are grouped by session ID and paired as human/AI exchanges
- All IDs are converted to strings for Airtable compatibility
Error Handling¶
The workflow uses Airtable's upsert operation which handles both creation and updates gracefully. No explicit error handling nodes are present, so failures would stop execution and require manual intervention.
Known Limitations¶
- No incremental sync - processes all records every minute
- No error recovery mechanisms
- Message processing assumes specific JSON structure
- Conversation pairing logic may miss messages if human/AI counts don't align
- No data validation before sync
Related Workflows¶
No related workflows specified in the current context.
Setup Instructions¶
-
Import Workflow
- Import the workflow JSON into your n8n instance
- Ensure all required node types are available
-
Configure Supabase Credentials
- Create a Supabase API credential in n8n
- Provide your Supabase project URL and service key
- Test connection to ensure access to required tables
-
Configure Airtable Credentials
- Create an Airtable Personal Access Token credential
- Ensure token has access to the "Iganga DB on Supabase" base
- Verify read/write permissions for all target tables
-
Verify Table Mappings
- Confirm Airtable base ID and table IDs match your setup
- Adjust field mappings if your table schemas differ
- Test with a small dataset first
-
Activate Workflow
- Enable the workflow to start automatic synchronization
- Monitor initial runs for any data mapping issues
- Adjust schedule frequency if needed for your use case
-
Test Data Flow
- Create test records in Supabase
- Verify they appear correctly in Airtable after the next sync cycle
- Check that updates are properly reflected