Skip to content

AsrorbekQ/CleanCorrect-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CleanCorrect

Lead form pipeline

The lead form now posts to /api/leads. The API does the following for every submission:

  • Appends lead data to Google Sheets (through a Google Apps Script webhook)
  • Sends an instant Telegram alert
  • Applies IP-based rate limiting
  • Suppresses duplicate submissions by phone within a cooldown window

1) Configure environment variables

Create .env.local from .env.example and fill values:

  • LEADS_GOOGLE_SCRIPT_URL: deployed Google Apps Script Web App URL
  • TELEGRAM_BOT_TOKEN: bot token from BotFather
  • TELEGRAM_CHAT_ID: target chat/channel id for notifications
  • LEADS_RATE_LIMIT_WINDOW_MS: rate-limit window in milliseconds (optional)
  • LEADS_RATE_LIMIT_MAX_REQUESTS: max submissions per IP within window (optional)
  • LEADS_DUPLICATE_WINDOW_MS: duplicate suppression window by phone in milliseconds (optional)

2) Create Google Apps Script webhook

Create a Google Sheet with a tab named Leads, then open Apps Script and use:

function doPost(e) {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ss.getSheetByName('Leads');
  const body = JSON.parse(e.postData.contents || '{}');

  sheet.appendRow([
    body.timestamp || '',
    body.name || '',
    body.phone || '',
    body.language || '',
    body.pageUrl || '',
    body.utm_source || '',
    body.utm_medium || '',
    body.utm_campaign || '',
    body.utm_content || '',
    body.utm_term || '',
    body.ip || '',
    body.userAgent || '',
    body.origin || '',
  ]);

  return ContentService
    .createTextOutput(JSON.stringify({ ok: true }))
    .setMimeType(ContentService.MimeType.JSON);
}

Deploy as Web App:

  • Execute as: Me
  • Who has access: Anyone

Copy the Web App URL into LEADS_GOOGLE_SCRIPT_URL.

3) Run locally

npm install
npm run dev

Vite dev server includes /api/leads middleware, so local form testing works without extra backend setup.

Netlify deployment

This repo includes netlify.toml and a Netlify function at netlify/functions/leads.mjs.

  • Frontend calls /api/leads
  • Netlify redirects it to /.netlify/functions/leads

Set the same environment variables in Netlify Site Settings -> Environment variables.

Telegram alert format

Each alert includes:

  • Name
  • Click-to-call phone link
  • Language code
  • Landing page URL
  • Condensed UTM summary
  • Submission timestamp

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors