Inbound Tool
Google sheets
Google Sheets Inbound Tool
This tool monitors a Google Sheet for new entries and automatically sends them to the SixtyFour AI enrichment API for processing.
Overview
The tool is implemented as a Google Apps Script that:
- Monitors the active sheet for new rows
- Sanitizes column headers to create valid JSON keys
- Formats the data according to the API requirements
- Sends the data to the enrichment endpoint
Implementation
The main function sendNewRowToAPI()
performs the following steps:
-
Data Collection:
- Gets the active sheet and all its data
- Extracts headers from the first row
- Gets the last row of data (new entry)
-
Data Sanitization:
- Cleans column headers by:
- Removing newlines, carriage returns, and tabs
- Converting spaces to underscores
- Removing non-alphanumeric characters
- Converting to lowercase
- Removing leading underscores
- Cleans column headers by:
-
Data Formatting:
- Creates a JSON object using sanitized headers as keys
- Adds required fields:
id
: Empty string (to be populated by API)created_at
: Current UTC timestampcompany_id
: Set to “bild-ai”
-
API Integration:
- Sends data to
https://api.inbound.sixtyfour.ai/enrich-lead
- Includes additional fields:
heard_about_us
: Set to “Website Form”terms_agreed
: Set to null
- Requires API key authentication
- Sends data to
Complete Code
Copy and paste the following code into your Google Apps Script editor:
Configuration
Before using the tool, you need to set the following variables in the code:
Error Handling
The function includes error handling that:
- Logs successful API responses
- Catches and logs any errors during the API call
Usage
- Open your Google Sheet
- Go to Extensions > Apps Script
- Create a new script
- Copy and paste the function code
- Set up your API key and customer ID
- Create a trigger to run the function when new rows are added
Example Payload
The function sends data in this format:
Notes
- The function processes only the last row of the sheet
- Column headers are automatically sanitized to create valid JSON keys
- All timestamps are in UTC format
- The API requires authentication via x-api-key header