A very hacky way to transpose form data into rows

This community has shared some great ways to solve this problem, so I should preface with the fact that I’m building prototypes and need to ship quickly without much worry for scaling and best practices. I’m not certain this method would be the best way to build a production level app.

TL;DR:

  • I embedded an external service form (fillout.com, could be any form)
  • Sent the data to zapier
  • Used the code block to run a very simple script (included below - thank you ChatGPT) transposed each input and then sent it via Glide API to their own rows in their appropriate tables with the right reference data (i.e. email)

Why I did this?
I’ve been struggling with creating forms and user inputs in particular:

  1. How to accept user input into forms and turning each input it’s own row.
  2. Creating forms that need countless tables for dropdown inputs

Use cases
(Instances where you want to analyze user inputs on an individual basis)

  • Accepting a users sets/reps for each exercise in a workout
  • Categorizing/tagging a users response to a quiz/form on a per response basis
  • Using AI in your app to generate content based only a specific type of response/rows in the response table…I’m finding this in particular to be extremely powerful. Saves hours of dev time trying to query a table and analyzing the data…again, prototyping.

Hope this helps!

Python script to use within zapier

import requests

def add_row_to_glide(app_id, table_name, column_values, headers):
    """
    Sends a POST request to Glide to add a new row to a specified table.

    Parameters:
    app_id (str): The unique identifier for the Glide application.
    table_name (str): The name of the table in the Glide app where the row will be added.
    column_values (dict): A dictionary containing the column data to be added.
    headers (dict): Headers for the POST request, typically including authorization tokens.
    """
    json_payload = {
        "appID": app_id,
        "mutations": [
            {
                "kind": "add-row-to-table",
                "tableName": table_name,
                "columnValues": column_values
            }
        ]
    }
    response = requests.post(
        "https://api.glideapp.io/api/function/mutateTables",
        headers=headers,
        json=json_payload
    )
    return response.json()

# Configuration for Glide API (replace with actual values)
app_id = "YOUR_APP_ID"
table_name = "YOUR_TABLE_NAME"
headers = {"Authorization": "Bearer YOUR_AUTH_TOKEN"}

# Assuming 'input_data' is provided by an external source like Zapier
# containing all the necessary fields
for i in range(1, 4):  # Adjust this range based on the actual number of questions
    # Construct the column values for each entry, using placeholders and current iteration index
    # Replace 'COLUMN_KEY' with actual Glide column keys
    column_values = {
    #Do not include 'i' for inputs that you want to be the same on every row. Ex: Email 
        'COLUMN_KEY_FOR_COLUMN1': input_data.get(f'input1'),
        'COLUMN_KEY_FOR_COLUMN2': input_data.get(f'input{i}_value2'),
        'COLUMN_KEY_FOR_COLUMN3': input_data.get(f'input{i}_value3'),
        # Add additional keys and values as needed
    }
    
    # Remove any key-value pairs where the value is None
    column_values = {k: v for k, v in column_values.items() if v is not None}
    
    # If all values are None, skip sending this row
    if not column_values:
        continue
    
    # Send the data to Glide and print the result
    result = add_row_to_glide(app_id, table_name, column_values, headers)
    print(result)

Can you explain more about point 1? May us see a sample form you’re using with this approach?