Data Flow Workflow¶
This workflow creates an intelligent form-to-spreadsheet system that collects user information, generates AI-powered device-specific tips, and stores everything in Google Sheets. It demonstrates a complete data flow from user input through AI processing to final storage.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Form Submission: A user fills out a web form with their name and device type (Mobile or Desktop)
- Initial Data Storage: The form data is immediately saved to a Google Sheets spreadsheet
- Device Detection: The workflow checks which device type the user selected
- AI Tip Generation: An AI agent generates personalized tips based on the user's device type
- Final Update: The AI-generated tips are added back to the same spreadsheet row, matching by the user's name
Workflow Diagram¶
graph TD
A[On form submission] --> B[Append or update row in sheet]
B --> C[Switch]
C --> D[AI Agent]
E[OpenAI Chat Model] --> D
D --> F[Append or update row in sheet1]
Trigger¶
Form Trigger: The workflow starts when someone submits the "Data Form Test" web form. The form collects: - User's name (text input) - Device type (dropdown: Mobile or Desktop)
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Form Trigger | On form submission | Captures form submissions and provides webhook endpoint |
| Google Sheets | Append or update row in sheet | Stores initial form data (Name, Device) |
| Switch | Switch | Routes data based on device type (Mobile vs Desktop) |
| AI Agent | AI Agent | Generates device-specific tips using OpenAI |
| OpenAI Chat Model | OpenAI Chat Model | Provides AI language model for tip generation |
| Google Sheets | Append or update row in sheet1 | Updates the same row with AI-generated tips |
External Services & Credentials Required¶
Google Sheets¶
- Credential:
Google Sheets account 2 - Permissions: Read and write access to spreadsheets
- Spreadsheet ID:
1kxZaVBlgdQ1Kr-CnDTAiDvbS_xHTU5BSTuCIgcf65OE
OpenAI¶
- Credential:
OpenAi account - Model: GPT-4.1-mini
- Usage: Generating device-specific tips
Environment Variables¶
No environment variables are explicitly configured in this workflow. All configuration is handled through node parameters and credentials.
Data Flow¶
Input Data¶
- Name: User's name (text)
- Device: Selected device type (Mobile or Desktop)
Processing¶
- Form data is mapped to Google Sheets columns
- Device type determines AI prompt context
- AI generates tips with constraint: "less than [X] lines"
Output Data¶
- Google Sheets Row: Contains Name, Device, and AI-generated Tips
- Matching Logic: Updates existing rows by matching the Name field
Error Handling¶
This workflow uses basic n8n error handling. No custom error handling nodes are implemented. Potential failure points: - Google Sheets API connectivity issues - OpenAI API rate limits or failures - Form submission validation errors
Known Limitations¶
- The AI prompt has a typo: "less that lines" should be "less than X lines"
- No validation for duplicate names in the spreadsheet
- Switch node handles only Mobile/Desktop - other values would not be processed
- No retry logic for API failures
Related Workflows¶
No related workflows identified in the current context.
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Google Sheets Credential:
- Create a Google Sheets OAuth2 credential
- Grant access to the target spreadsheet
- Ensure the spreadsheet has columns: Name, City, Device, Tips
-
Configure OpenAI Credential:
- Add your OpenAI API key
- Verify access to GPT-4.1-mini model
-
Set Up Spreadsheet:
- Create or access spreadsheet ID:
1kxZaVBlgdQ1Kr-CnDTAiDvbS_xHTU5BSTuCIgcf65OE - Ensure sheet name is "data" (gid=0)
- Set up columns: Name, City, Device, Tips
- Create or access spreadsheet ID:
-
Test Form:
- Activate the workflow
- Use the webhook URL from the Form Trigger node
- Submit test data to verify the complete flow
-
Optional Customizations:
- Modify the AI prompt in the AI Agent node
- Add additional form fields
- Customize the Switch conditions for other device types