Clay Icon

Import New Google Sheet Rows to Table with Clay Integration

Β·
Β·

Hey! Is there a way for Clay to check for new rows on a Google Sheet, and import them directly to a table?

  • Avatar of Channeled
    Channeled
    APP
    Β·
    Β·

    You can import new rows from Google Sheets to Clay using webhooks. Here's how to set it up: 1. Create a new webhook import: β€’ Go to your Clay home page β€’ Click the + Create New button β€’ Scroll to the "Other" section β€’ Select "Import data from Webhook" β€’ Choose an existing table or create a new one 2. Set up Google Apps Script in your Google Sheet: β€’ Open your Google Sheet β€’ Click "Extensions > Apps Script" β€’ Add a script that will: β€’ Cycle through rows in your Sheet β€’ Send data to Clay via the webhook β€’ Mark processed rowsNote: The default script is designed for single-column data. If you have multiple columns, you'll need to customize the script accordingly. Sources: Import Data to Clay Using Webhooks Send Data from Google Sheets to Clay Using a Webhook

  • Avatar of Channeled
    Channeled
    APP
    Β·
    Β·

    Looks like you're still looking for help. We're escalating this over to our support team and someone should be in touch soon. In the meantime, feel free to include any other information that may be helpful in solving your issue!

  • Avatar of Nicolas P.
    Nicolas P.
    Β·
    Β·

    When I click the + Create New button, my only options available are 'Workbook', 'Table' and 'Folder'. There's no 'Other' section

  • Avatar of Daniel K.
    Daniel K.
    Β·
    Β·

    Hey there, thanks for reaching out! ☺️ 1. You can use Google Apps Script within Google Sheets to automate the data transfer to Clay. A video guide is available here 2. You can also use a service like Make.com to check the spreadsheet on a recurring basis, and send the new rows to Clay. We have a video on that sort of setup here: https://www.loom.com/share/7ea0148442bb4e7791ad7dd19e869a8a And the scripts from the video: JS

    const WEBHOOK_URL = 'https://your-clay-webhook-url.com'; // Replace with your webhook URL
    
    function sendNewRowsToClayWebhook() {
    const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    const data = sheet.getDataRange().getValues();
    
    const lastRowSent = PropertiesService.getScriptProperties().getProperty('lastRowSent') || 1; // Start after headers
    const headers = data[0]; // First row as column names
    
    const newRows = data.slice(lastRowSent); // Get rows added since the last run
    
    if (newRows.length > 0) {
    // Send each row as a separate request
    newRows.forEach(row => {
    const payload = row.reduce((obj, value, index) => {
    obj[headers[index]] = value || ''; // Map values to column names
    return obj;
    }, {});
    
    const options = {
    method: 'post',
    contentType: 'application/json',
    payload: JSON.stringify(payload),
    };
    
    UrlFetchApp.fetch(WEBHOOK_URL, options); // Send each row
    });
    
    // Update the last row sent
    PropertiesService.getScriptProperties().setProperty('lastRowSent', data.length);
    }
    }
    

    HTML

    <!DOCTYPE html>
    <html>
    <head>
    <base target="_top" />
    </head>
    <body>
    <h3>Send Data to Clay</h3>
    <label for="webhookUrl">Clay Webhook URL:</label><br />
    <input type="text" id="webhookUrl" style="width: 100%;" /><br /><br />
    <button onclick="sendData()">Send Data</button>
    <p id="status"></p>
    
    <script>
    function sendData() {
    const webhookUrl = document.getElementById('webhookUrl').value;
    
    if (!webhookUrl) {
    document.getElementById('status').innerText =
    'Please enter a valid webhook URL!';
    return;
    }
    
    google.script.run
    .withSuccessHandler(response => {
    document.getElementById('status').innerText = `Success: ${response}`;
    })
    .withFailureHandler(error => {
    document.getElementById('status').innerText = `Error: ${error.message}`;
    })
    .sendDataToClayWebhook(webhookUrl);
    }
    </script>
    </body>
    </html> 
    
    
  • Avatar of Nicolas P.
    Nicolas P.
    Β·
    Β·

    Thanks, I'll take a look and let you know

  • Avatar of Channeled
    Channeled
    APP
    Β·
    Β·

    Hey there - just wanted to check in here to see if you needed anything else! Feel free to reply back here if you do.

  • Avatar of Channeled
    Channeled
    APP
    Β·
    Β·

    We haven't heard back from you in a bit, so we're going to go ahead and close things out here - feel free to let us know if you still need something!

  • Avatar of Channeled
    Channeled
    APP
    Β·
    Β·

    Hi Nicolas P.! This thread was recently closed by our Support team. If you have a moment, please share your feedback: