Chat Flow
Flow Builder
Blocks
Database
Google Sheets

Google Sheets Database Block

The Google Sheets block transforms Google Sheets into a dynamic database for your bot, enabling seamless CRUD operations (Create, Read, Update, Delete), advanced data processing, and spreadsheet functionalities like formulas and charts.

Complete authentication setup (OAuth 2.0 or service account) before configuring the block to ensure secure access.

Features

  • CRUD Operations: Read, write, update, or delete spreadsheet data effortlessly.
  • Range Operations: Target specific cells or named ranges for precise control.
  • Batch Processing: Execute multiple actions in a single API call for efficiency.
  • Formulas and Functions: Use Google Sheets formulas (e.g., SUM, TODAY) for dynamic calculations.
  • Formatting: Customize cell styles, colors, and conditional formatting.
  • Charts: Create or update visual data representations.

Authentication

OAuth 2.0 Setup

  1. Google Cloud Console Setup:

    • Create or select a project in Google Cloud Console.
    • Enable the Google Sheets API.
    • Generate OAuth 2.0 credentials (Client ID and Secret).
    • Configure authorized redirect URIs for secure token handling.
  2. Required Scopes:

    https://www.googleapis.com/auth/spreadsheets
    https://www.googleapis.com/auth/drive.file
  3. Service Account (Optional):

    • Create a service account in Google Cloud Console.
    • Share target spreadsheets with the service account’s email.
    • Use for automated, non-interactive bot workflows.

Use OAuth 2.0 for user-driven flows requiring consent; service accounts are best for automated processes like scheduled data updates.

Flow Editor Setup

  1. Drag the Google Sheets block from the Integrations category into your flow.
  2. Select an operation (e.g., Read, Write, Update, Delete).
  3. Enter the Spreadsheet ID, Sheet Name, and other relevant settings.
  4. Test the configuration in preview mode to verify connectivity.

CRUD Operations

Read Operation

Retrieve data from specific ranges or entire sheets with customizable rendering options.

Configuration Options:

  • Spreadsheet ID: Unique identifier of the Google Sheet.
  • Sheet Name: Target worksheet (e.g., Sheet1).
  • Range: Cells in A1 notation (e.g., A1:E100) or named range.
  • Value Render Option: FORMATTED_VALUE for styled data, UNFORMATTED_VALUE for raw values.
  • Date Time Render Option: FORMATTED_STRING for readable dates.

Example Operations:

// Read entire sheet
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1",
  "valueRenderOption": "UNFORMATTED_VALUE"
}
 
// Read specific range
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1!A1:E100",
  "valueRenderOption": "FORMATTED_VALUE",
  "dateTimeRenderOption": "FORMATTED_STRING"
}
 
// Read named range
{
  "spreadsheetId": "1ABC123...",
  "range": "CustomerData",
  "majorDimension": "ROWS"
}
 
// Read with headers
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1!A:Z",
  "includeHeaders": true,
  "skipEmptyRows": true
}

Write Operation

Add new data to spreadsheets with flexible insertion methods.

Configuration Options:

  • Spreadsheet ID: Target spreadsheet.
  • Range: Starting cell or range for data insertion.
  • Values: 2D array of data to write.
  • Value Input Option: USER_ENTERED to parse formulas, RAW for literal values.
  • Insert Data Option: INSERT_ROWS to append, OVERWRITE to replace.

Example Operations:

// Write header row
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1!A1",
  "values": [
    ["Name", "Email", "Status", "Date"]
  ],
  "valueInputOption": "USER_ENTERED"
}
 
// Write multiple rows
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1!A2",
  "values": [
    ["Alice Brown", "alice@example.com", "Active", "2024-02-01"],
    ["Bob Carter", "bob@example.com", "Pending", "2024-02-02"],
    ["Clara Davis", "clara@example.com", "Inactive", "2024-02-03"]
  ],
  "valueInputOption": "USER_ENTERED"
}
 
// Append with formula
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1",
  "values": [
    ["New User", "new@example.com", "Active", "=TODAY()"]
  ],
  "valueInputOption": "USER_ENTERED",
  "insertDataOption": "INSERT_ROWS"
}

Update Operation

Modify existing data with precision using targeted updates or formulas.

Configuration Options:

  • Spreadsheet ID: Target spreadsheet.
  • Range: Cells to update.
  • Values: New data or formulas.
  • Value Input Option: Parsing method for input data.

Example Operations:

// Update specific cells
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1!C2:C4",
  "values": [
    ["Processed"],
    ["Approved"],
    ["Rejected"]
  ],
  "valueInputOption": "USER_ENTERED"
}
 
// Update with formulas
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1!F2:F5",
  "values": [
    ["=B2*C2"],
    ["=B3*C3"],
    ["=B4*C4"],
    ["=B5*C5"]
  ],
  "valueInputOption": "USER_ENTERED"
}
 
// Conditional update
{
  "spreadsheetId": "1ABC123...",
  "updateCondition": {
    "range": "Sheet1!B:B",
    "criteria": { "type": "TEXT_CONTAINS", "value": "Pending" }
  },
  "updateValues": {
    "range": "Sheet1!C:C",
    "values": [["Updated"]]
  }
}

Delete Operation

Remove rows, columns, or clear cell contents safely.

Configuration Options:

  • Spreadsheet ID: Target spreadsheet.
  • Sheet ID: Worksheet identifier (numeric ID).
  • Dimension: ROWS or COLUMNS to delete.
  • Start/End Index: Range boundaries for deletion.

Example Operations:

// Delete rows
{
  "spreadsheetId": "1ABC123...",
  "requests": [
    {
      "deleteDimension": {
        "range": {
          "sheetId": 0,
          "dimension": "ROWS",
          "startIndex": 5,
          "endIndex": 10
        }
      }
    }
  ]
}
 
// Clear cell contents
{
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1!A1:Z50",
  "clearContent": true
}
 
// Delete columns
{
  "spreadsheetId": "1ABC123...",
  "requests": [
    {
      "deleteDimension": {
        "range": {
          "sheetId": 0,
          "dimension": "COLUMNS",
          "startIndex": 2,
          "endIndex": 4
        }
      }
    }
  ]
}

Advanced Operations

Batch Operations

Optimize performance by combining multiple actions into a single request.

{
  "spreadsheetId": "1ABC123...",
  "requests": [
    {
      "updateCells": {
        "range": {
          "sheetId": 0,
          "startRowIndex": 0,
          "endRowIndex": 1,
          "startColumnIndex": 0,
          "endColumnIndex": 4
        },
        "rows": [
          {
            "values": [
              { "userEnteredValue": { "stringValue": "Customer" } },
              { "userEnteredValue": { "stringValue": "Contact" } },
              { "userEnteredValue": { "stringValue": "Status" } },
              { "userEnteredValue": { "stringValue": "Revenue" } }
            ]
          }
        ],
        "fields": "userEnteredValue"
      }
    },
    {
      "repeatCell": {
        "range": {
          "sheetId": 0,
          "startRowIndex": 0,
          "endRowIndex": 1,
          "startColumnIndex": 0,
          "endColumnIndex": 4
        },
        "cell": {
          "userEnteredFormat": {
            "backgroundColor": { "red": 0.9, "green": 0.9, "blue": 0.9 },
            "textFormat": { "bold": true, "fontSize": 12 }
          }
        },
        "fields": "userEnteredFormat(backgroundColor,textFormat)"
      }
    }
  ]
}

Formula and Function Operations

Utilize Google Sheets’ formulas for automated data analysis.

// Statistical summary
{
  "spreadsheetId": "1ABC123...",
  "range": "Analytics!A1:B8",
  "values": [
    ["Metric", "Result"],
    ["Total Revenue", "=SUM(Data!E:E)"],
    ["Average Sale", "=AVERAGE(Data!E:E)"],
    ["Unique Customers", "=COUNTA(Data!B:B)-1"],
    ["Highest Sale", "=MAX(Data!E:E)"],
    ["Lowest Sale", "=MIN(Data!E:E)"],
    ["Current Date", "=TODAY()"],
    ["Last Update", "=NOW()"]
  ],
  "valueInputOption": "USER_ENTERED"
}
 
// Conditional formatting
{
  "spreadsheetId": "1ABC123...",
  "requests": [
    {
      "addConditionalFormatRule": {
        "rule": {
          "ranges": [
            {
              "sheetId": 0,
              "startRowIndex": 1,
              "startColumnIndex": 4,
              "endColumnIndex": 5
            }
          ],
          "booleanRule": {
            "condition": {
              "type": "CUSTOM_FORMULA",
              "values": [{ "userEnteredValue": "=E2>500" }]
            },
            "format": {
              "backgroundColor": { "red": 0.9, "green": 1, "blue": 0.9 }
            }
          }
        },
        "index": 0
      }
    }
  ]
}

Data Validation

Ensure data quality with custom validation rules.

{
  "spreadsheetId": "1ABC123...",
  "requests": [
    {
      "setDataValidation": {
        "range": {
          "sheetId": 0,
          "startRowIndex": 1,
          "startColumnIndex": 3,
          "endColumnIndex": 4
        },
        "rule": {
          "condition": {
            "type": "ONE_OF_LIST",
            "values": [
              { "userEnteredValue": "Active" },
              { "userEnteredValue": "Inactive" },
              { "userEnteredValue": "Pending" }
            ]
          },
          "showCustomUi": true,
          "strict": true
        }
      }
    }
  ]
}

Pivot Tables

Create pivot tables for advanced data insights.

{
  "spreadsheetId": "1ABC123...",
  "requests": [
    {
      "updateCells": {
        "range": {
          "sheetId": 1,
          "startRowIndex": 0,
          "startColumnIndex": 0
        },
        "rows": [
          {
            "values": [
              {
                "pivotTable": {
                  "source": {
                    "sheetId": 0,
                    "startRowIndex": 0,
                    "startColumnIndex": 0,
                    "endRowIndex": 1000,
                    "endColumnIndex": 8
                  },
                  "rows": [
                    {
                      "sourceColumnOffset": 1,
                      "showTotals": true,
                      "sortOrder": "ASCENDING"
                    }
                  ],
                  "values": [
                    {
                      "summarizeFunction": "SUM",
                      "sourceColumnOffset": 4
                    }
                  ]
                }
              }
            ]
          }
        ],
        "fields": "pivotTable"
      }
    }
  ]
}

Custom Operations

Data Import/Export

Simplify data transfers with CSV support.

// Import CSV
{
  "operation": "importData",
  "spreadsheetId": "1ABC123...",
  "sheetName": "DataImport",
  "csvData": "Name,Email,Status\nAlice,alice@example.com,Active\nBob,bob@example.com,Pending",
  "delimiter": ",",
  "skipLeadingRows": 0
}
 
// Export to CSV
{
  "operation": "exportData",
  "spreadsheetId": "1ABC123...",
  "range": "Sheet1!A1:F500",
  "format": "csv",
  "includeHeaders": true
}

Sheet Management

Organize worksheets dynamically.

// Create new sheet
{
  "spreadsheetId": "1ABC123...",
  "requests": [
    {
      "addSheet": {
        "properties": {
          "title": "DataArchive",
          "gridProperties": {
            "rowCount": 500,
            "columnCount": 20
          }
        }
      }
    }
  ]
}
 
// Duplicate sheet
{
  "spreadsheetId": "1ABC123...",
  "requests": [
    {
      "duplicateSheet": {
        "sourceSheetId": 0,
        "newSheetName": "Sheet1Backup"
      }
    }
  ]
}

Troubleshooting

Common Issues

  • Authentication Errors: Ensure OAuth tokens or service account credentials are valid and unexpired.
  • Permission Errors: Confirm the spreadsheet is shared with the correct OAuth user or service account email.
  • Quota Exceeded: Monitor Google Sheets API limits and use batch operations to reduce requests.
  • Invalid Range: Verify A1 notation (e.g., Sheet1!A1:Z100) or named range syntax.
  • WhatsApp Compatibility: Use simple data formats (e.g., plain text, .mp4 for media) for WhatsAppβ€”see WhatsApp Guide.
  • Formula Errors: Check formula syntax and ensure referenced ranges exist.
⚠️

Validate all operations in the Indite editor’s preview mode to catch errors before deployment.

Error Handling

Address common API errors:

  • Authentication Errors: Invalid or expired tokens.
  • Permission Errors: Missing spreadsheet access.
  • Quota Exceeded: Exceeded API rate limits.
  • Invalid Range: Incorrect A1 notation or out-of-bounds ranges.
  • Validation Errors: Non-compliant data for defined rules.

Response Mapping

Map API responses to bot variables:

  • Cell Values: Extract single cell data.
  • Row Data: Process rows as objects.
  • Range Data: Handle 2D data arrays.
  • Metadata: Retrieve sheet properties and formatting.
  • Operation Results: Confirm successful actions.

Best Practices

Performance

  • Batch Operations: Combine requests to minimize API calls.
  • Range Optimization: Target specific cells to reduce processing time.
  • Caching: Store frequently accessed data locally.
  • Pagination: Break large datasets into manageable chunks.

Data Management

  • Validation: Use rules to ensure data consistency.
  • Formatting: Apply consistent styles for clarity.
  • Structure: Maintain organized sheet layouts.
  • Backup: Export critical data regularly.

Security

  • Access Control: Restrict sharing to authorized users.
  • Authentication: Securely store OAuth tokens.
  • Audit Trail: Track changes for accountability.
  • Data Privacy: Protect sensitive information.

Integration

  • Error Handling: Implement robust error recovery.
  • Retry Logic: Handle transient API failures.
  • Logging: Record operations for debugging.
  • Monitoring: Track API usage and performance.

Workflow Engine Execution

πŸ”„ How Google Sheets Blocks Execute in InditeAI

Understanding how Google Sheets blocks operate within InditeAI's workflow engine helps you build more efficient and reliable automation:

Execution Order & Dependencies

// Workflow Engine Processing:
1. **Block Initialization**: Validate configuration and authenticate
2. **Input Processing**: Receive and parse data from previous blocks
3. **Operation Execution**: Perform Google Sheets API calls
4. **Output Generation**: Format results for next blocks
5. **State Management**: Update workflow variables and logs
6. **Error Handling**: Manage failures and recovery actions
 
// Execution Flow Example:
Webhook Trigger (instant) β†’ 
Google Sheets Read (2-3s) β†’ 
OpenAI Processing (5-10s) β†’ 
Google Sheets Write (1-2s) β†’ 
Email Action (3-4s)

⚑ Performance Characteristics

Operation TypeTypical Execution TimeFactors Affecting Speed
Read Operations1-3 secondsRange size, cell count, formulas
Write Operations2-4 secondsData volume, validation rules
Update Operations1-3 secondsNumber of cells updated
Batch Operations3-8 secondsNumber of operations combined
Formula Calculations2-10 secondsComplexity of formulas

🧠 State Management

Google Sheets blocks maintain workflow state through:

// Workflow Variables Updated:
{
  "google_sheets": {
    "operation_result": "success|failure",
    "rows_affected": 42,
    "execution_time": "2.3s",
    "last_modified": "2024-01-15T10:30:00Z",
    "spreadsheet_id": "1ABC123...",
    "range_processed": "A1:E100",
    "data_summary": {
      "total_rows": 100,
      "columns": 5,
      "empty_cells": 12
    }
  }
}
 
// These variables can be used in subsequent blocks:
- {{google_sheets.rows_affected}}
- {{google_sheets.data_summary.total_rows}}
- {{google_sheets.execution_time}}

πŸ”„ Concurrent Execution

InditeAI's workflow engine handles concurrent Google Sheets operations intelligently:

  • Same Spreadsheet: Operations are queued to prevent conflicts
  • Different Spreadsheets: Executed in parallel for optimal performance
  • Rate Limit Awareness: Automatic throttling to respect API limits
  • Connection Pooling: Efficient reuse of authenticated connections

πŸ“Š Execution Monitoring

Track your Google Sheets block performance:

// Available Metrics:
{
  "performance": {
    "average_execution_time": "2.1s",
    "success_rate": "98.5%",
    "api_calls_per_hour": 150,
    "data_throughput": "1.2MB/hour",
    "error_frequency": "1.5%"
  },
  "usage_patterns": {
    "peak_hours": ["9AM-11AM", "2PM-4PM"],
    "most_used_operations": ["read", "insert", "update"],
    "average_data_size": "50KB"
  }
}

πŸŽ›οΈ Optimization Strategies

For High-Volume Workflows:

  • Use batch operations instead of individual cell updates
  • Implement caching for frequently accessed data
  • Schedule heavy operations during off-peak hours
  • Use specific ranges instead of entire sheet queries

For Real-Time Workflows:

  • Minimize data transfer with targeted ranges
  • Use conditional logic to skip unnecessary operations
  • Implement smart retry logic with exponential backoff
  • Cache authentication tokens for faster execution

For Complex Data Processing:

  • Leverage Google Sheets formulas for in-sheet calculations
  • Use aggregation pipelines for data summarization
  • Implement data validation at the block level
  • Consider data partitioning for large datasets

Node Display

  • Operation Details: Shows action type (read/write/update/delete) and range.
  • Sheet Information: Displays spreadsheet and sheet names.
  • Status: Indicates success/failure and affected row count.
  • Errors: Provides actionable error messages.
Indite Documentation v1.4.0
PrivacyTermsSupport