Skip to content

Data Flow

A form-to-spreadsheet workflow that collects user information, generates AI-powered device-specific tips, and stores everything in Google Sheets for tracking and analysis.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

How It Works

  1. Form Submission: A user fills out a web form with their name and device type (Mobile or Desktop)
  2. Initial Data Storage: The form data is immediately saved to a Google Sheets spreadsheet
  3. Device Detection: The workflow checks which device type the user selected
  4. AI Tip Generation: An AI agent generates personalized tips based on the user's device type
  5. Final Update: The 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 -->|Mobile| D[AI Agent]
    C -->|Desktop| D[AI Agent]
    D --> E[Append or update row in sheet1]
    F[OpenAI Chat Model] -.->|Language Model| D

Trigger

Form Trigger: A web form with two fields: - Text input: "Enter your name?" - Dropdown: "Device" (options: Mobile, Desktop)

The form is titled "Data Form Test" and generates a webhook URL for submissions.

Nodes Used

Node Type Node Name Purpose
Form Trigger On form submission Captures user input via web form
Google Sheets Append or update row in sheet Stores initial form data
Switch Switch Routes flow based on device type
AI Agent AI Agent Generates device-specific tips
OpenAI Chat Model OpenAI Chat Model Provides AI language model
Google Sheets Append or update row in sheet1 Updates row with AI-generated tips

External Services & Credentials Required

Google Sheets

  • Credential: Google Sheets OAuth2 API
  • Purpose: Read/write access to spreadsheet data
  • Document: "Flows" spreadsheet (ID: 1kxZaVBlgdQ1Kr-CnDTAiDvbS_xHTU5BSTuCIgcf65OE)

OpenAI

  • Credential: OpenAI API
  • Purpose: AI tip generation using GPT-4.1-mini model
  • Usage: Generates device-specific tips based on user input

Environment Variables

No environment variables are used in this workflow. All configuration is handled through node parameters and credentials.

Data Flow

Input Data

  • Name: User's name (text input)
  • Device: Selected device type (Mobile or Desktop)

Processing

  • Form data is mapped to Google Sheets columns (Name, Device)
  • 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
  • Spreadsheet Columns: Name, City, Device, Tips

Error Handling

No explicit error handling is implemented in this workflow. The workflow relies on: - Default n8n node error handling - Google Sheets API error responses - OpenAI API error responses

Consider adding error handling nodes for production use.

Known Limitations

  • No validation on form inputs
  • AI tip generation prompt has a typo ("less that lines" should be "less than X lines")
  • No duplicate prevention - same name can create multiple entries
  • No error handling for API failures
  • Switch node only handles Mobile/Desktop - no fallback for other values

No related workflows identified from the provided context.

Setup Instructions

1. Import Workflow

  1. Copy the workflow JSON
  2. In n8n, go to Workflows → Import from JSON
  3. Paste the JSON and save

2. Configure Credentials

  1. Google Sheets OAuth2:

    • Create Google Cloud project
    • Enable Google Sheets API
    • Create OAuth2 credentials
    • Add to n8n credentials store
  2. OpenAI API:

    • Get OpenAI API key
    • Add to n8n credentials store

3. Set Up Google Sheets

  1. Create or access the target spreadsheet
  2. Ensure it has columns: Name, City, Device, Tips
  3. Update the document ID in both Google Sheets nodes if using a different spreadsheet

4. Test the Workflow

  1. Activate the workflow
  2. Use the form trigger URL to submit test data
  3. Verify data appears in Google Sheets
  4. Check that AI tips are generated and stored

5. Customize (Optional)

  • Modify form fields in the Form Trigger node
  • Adjust AI prompt in the AI Agent node
  • Add additional device types to the Switch node
  • Implement error handling nodes