๐Ÿ“Š AI-powered web research in Google Sheets with GPT and Bright Data

โšก 5,662 views ยท ๐Ÿ“Š Market Research & Insights

๐Ÿ’ก Pro Tip โ€” HTTP Request scraping tends to break when sites update their markup. If youโ€™re scraping a major platform, check if ScraperNode covers it โ€” it has maintained scrapers for LinkedIn, Instagram, TikTok, YouTube, and 20+ other platforms that return structured data.

View All Scrapers

Description

๐Ÿ” AI-Powered Web Research in Google Sheets with Bright Data

๐Ÿ“‹ Overview

Transform any Google Sheets cell into an intelligent web scraper! Type =BRIGHTDATA("cell", "search prompt") and get AI-filtered result from every website in ~20 seconds.

What happens automatically:

Cost: ~$0.02-0.05 per search | Time saved: 3-5 minutes per search


๐Ÿ‘ฅ Whoโ€™s it for


โš™๏ธ How it works

  1. Webhook Call - Google Sheets function sends POST request
  2. Data Preparation - Organizes input structure
  3. AI Query Optimization - GPT-4.1 Mini refines search query
  4. Web Scraping - Bright Data fetches data while bypassing blocks
  5. AI Analysis - GPT-4o Mini filters and summarizes result
  6. Response - Returns plain text to your cell
  7. Logging - Updates logs for monitoring

๐Ÿ› ๏ธ Setup Instructions

Time to deploy: 20 minutes

Requirements

Part 1: n8n Workflow Setup

  1. Import this template into your n8n instance
  2. Configure Webhook node:
    • Copy your webhook URL: https://n8n.yourdomain.com/webhook/brightdata-search
    • Set authentication: Header Auth
    • Set API key: 12312346 (or create your own)
  3. Add OpenAI credentials to AI nodes.
  4. Configure Bright Data: Add API credentials
  5. Configure Output Language: Manually edit the โ€œSet Variablesโ€ Node.
  6. Test workflow with manual execution
  7. Activate the workflow

Part 2: Google Sheets Function

  1. Open Google Sheet โ†’ Extensions โ†’ Apps Script
  2. Paste this code:
function BRIGHTDATA(prompt, source) {
  if (!prompt || prompt === "") {
    return "โŒ Must enter prompt";
  }
 
  source = source || "google";
 
  // Update with YOUR webhook URL
  const N8N_WEBHOOK_URL = "https://your-n8n-domain.com/webhook/brightdata-search";
  
  // Update with YOUR password
  const API_KEY = "12312346";
 
  let spreadsheetId, sheetName, cellAddress;
 
  try {
    const sheet = SpreadsheetApp.getActiveSheet();
    const activeCell = sheet.getActiveCell();
    spreadsheetId = SpreadsheetApp.getActiveSpreadsheet().getId();
    sheetName = sheet.getName();
    cellAddress = activeCell.getA1Notation();
  } catch (e) {
    return "โŒ Cannot identify cell";
  }
 
  const payload = {
    prompt: prompt,
    source: source.toLowerCase(),
    context: {
      spreadsheetId: spreadsheetId,
      sheetName: sheetName,
      cellAddress: cellAddress,
      timestamp: new Date().toISOString()
    }
  };
 
  const options = {
    method: "post",
    contentType: "application/json",
    payload: JSON.stringify(payload),
    muteHttpExceptions: true,
    headers: {
      "Accept": "text/plain",
      "key": API_KEY
    }
  };
 
  try {
    const response = UrlFetchApp.fetch(N8N_WEBHOOK_URL, options);
    const responseCode = response.getResponseCode();
   
    if (responseCode !== 200) {
      Logger.log("Error response: " + response.getContentText());
      return "โŒ Error " + responseCode;
    }
   
    return response.getContentText();
   
  } catch (error) {
    Logger.log("Exception: " + error.toString());
    return "โŒ Connection error: " + error.toString();
  }
}

function doGet(e) {
  return ContentService.createTextOutput(JSON.stringify({
    status: "alive",
    message: "Apps Script is running",
    timestamp: new Date().toISOString()
  })).setMimeType(ContentService.MimeType.JSON);
}
  1. Update N8N_WEBHOOK_URL with your webhook
  2. Update API_KEY with your password
  3. Save (Ctrl+S / Cmd+S) - Important!
  4. Close Apps Script editor

๐Ÿ’ก Usage Examples

=BRIGHTDATA("C3", "What is the current price of the product?")
=BRIGHTDATA("D30", "What is the size of this company?")
=BRIGHTDATA("A4", "Do this comapny is hiring Developers?")

๐ŸŽจ Customization

Easy Tweaks

Advanced Options


๐Ÿš€ Pro Tips


โš ๏ธ Important Notes


๐Ÿ”ง Troubleshooting

ErrorSolution
โ€Exceeded maximum execution timeโ€Optimize AI prompts or use async mode
โ€Could not fetch dataโ€Verify Bright Data credentials
Empty cellCheck n8n logs for AI parsing issues
Broken charactersVerify UTF-8 encoding in webhook node

๐Ÿ“š Resources


Built with โค๏ธ by Elay Guez

๐Ÿ”— Nodes Used

HTTP Request, Webhook, AI Agent, Basic LLM Chain, OpenAI Chat Model, Structured Output Parser

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup