---
title: "Apps Script से Google Sheets कॉन्टैक्ट Brevo में आयात करें"
description: "बार-बार चल सकने वाला Apps Script उदाहरण जो सहमति जांचता है, फ़ील्ड मैप करता है, अनसब्सक्राइब बचाता है और API त्रुटि दिखाता है।"
url: https://tajo.io/hi/blog/import-google-sheet-contacts-to-brevo-apps-script/
markdown: https://tajo.io/hi/blog/import-google-sheet-contacts-to-brevo-apps-script.md
lang: hi-IN
author: "Set Noa"
author_url: https://tajo.io/hi/set-noa/
published: 2026-04-30
updated: 2026-10-09
alternates: {en-US: /blog/import-google-sheet-contacts-to-brevo-apps-script.md, bg-BG: /bg/blog/import-google-sheet-contacts-to-brevo-apps-script.md, cs-CZ: /cz/blog/import-google-sheet-contacts-to-brevo-apps-script.md, de-DE: /de/blog/import-google-sheet-contacts-to-brevo-apps-script.md, da-DK: /dk/blog/import-google-sheet-contacts-to-brevo-apps-script.md, es-ES: /es/blog/import-google-sheet-contacts-to-brevo-apps-script.md, fr-FR: /fr/blog/import-google-sheet-contacts-to-brevo-apps-script.md, el-GR: /gr/blog/import-google-sheet-contacts-to-brevo-apps-script.md, id-ID: /in/blog/import-google-sheet-contacts-to-brevo-apps-script.md, hr-HR: /hr/blog/import-google-sheet-contacts-to-brevo-apps-script.md, hu-HU: /hu/blog/import-google-sheet-contacts-to-brevo-apps-script.md, it-IT: /it/blog/import-google-sheet-contacts-to-brevo-apps-script.md, ja-JP: /jp/blog/import-google-sheet-contacts-to-brevo-apps-script.md, ko-KR: /kr/blog/import-google-sheet-contacts-to-brevo-apps-script.md, ar-SA: /ar/blog/import-google-sheet-contacts-to-brevo-apps-script.md, nl-NL: /nl/blog/import-google-sheet-contacts-to-brevo-apps-script.md, no-NO: /no/blog/import-google-sheet-contacts-to-brevo-apps-script.md, pl-PL: /pl/blog/import-google-sheet-contacts-to-brevo-apps-script.md, pt-BR: /pt/blog/import-google-sheet-contacts-to-brevo-apps-script.md, ro-RO: /ro/blog/import-google-sheet-contacts-to-brevo-apps-script.md, ru-RU: /ru/blog/import-google-sheet-contacts-to-brevo-apps-script.md, sv-SE: /se/blog/import-google-sheet-contacts-to-brevo-apps-script.md, zh-CN: /zh-cn/blog/import-google-sheet-contacts-to-brevo-apps-script.md, sl-SI: /sl/blog/import-google-sheet-contacts-to-brevo-apps-script.md, sr-Latn-RS: /sr/blog/import-google-sheet-contacts-to-brevo-apps-script.md, th-TH: /th/blog/import-google-sheet-contacts-to-brevo-apps-script.md, tr-TR: /tr/blog/import-google-sheet-contacts-to-brevo-apps-script.md, ur-PK: /ur/blog/import-google-sheet-contacts-to-brevo-apps-script.md, vi-VN: /vi/blog/import-google-sheet-contacts-to-brevo-apps-script.md, sk-SK: /sk/blog/import-google-sheet-contacts-to-brevo-apps-script.md}
---

[API](https://tajo.io/hi/blog/?category=api)

[इंटीग्रेशन](https://tajo.io/hi/blog/?category=integrations)

# Apps Script से Google Sheets कॉन्टैक्ट Brevo में आयात करें

बार-बार चल सकने वाला Apps Script उदाहरण जो सहमति जांचता है, फ़ील्ड मैप करता है, अनसब्सक्राइब बचाता है और API त्रुटि दिखाता है।

google apps script brevo

Sheets से Brevo में संपर्क कैसे लाएं?

Sheet में email, firstName, lastName और consent कॉलम जोड़ें। BREVO\_API\_KEY को Script Properties में रखें, कोड में लिस्ट ID दें और syncSheetToBrevo चलाएं। केवल सहमति वाले रिकॉर्ड लिए जाते हैं; स्क्रिप्ट Brevo की अनसब्सक्राइब स्थिति जांचती है, डुप्लिकेट हटाती है और API त्रुटि पर रुकती है। यह आपका रखा हुआ Apps Script है, बिल्ट-इन कनेक्टर नहीं।

[और जानें](https://tajo.io/hi/blog/import-google-sheet-contacts-to-brevo-apps-script/#sheet-%E0%A4%94%E0%A4%B0-%E0%A4%B2%E0%A4%BF%E0%A4%B8%E0%A5%8D%E0%A4%9F-%E0%A4%A4%E0%A5%88%E0%A4%AF%E0%A4%BE%E0%A4%B0-%E0%A4%95%E0%A4%B0%E0%A5%87%E0%A4%82)

| स्रोत फ़ील्ड | गंतव्य फ़ील्ड | नमूना मान |
| --- | --- | --- |
| `email` | `email` | `alex@example.com` |
| `firstName` | `FNAME` | `Alex` |
| `lastName` | `LNAME` | `Example` |

किसी इवेंट के बारह पंजीकरण एक बार एक्सपोर्ट करना आसान है। दूसरी बार एक ईमेल दोहर सकता है और कोई दूसरा व्यक्ति Brevo में अनसब्सक्राइब हो चुका हो सकता है। दोहराए जा सकने वाले आयात को दोनों बातें देखनी चाहिए।

स्क्रिप्ट [Brevo के कॉन्टैक्ट पढ़ने, बनाने और अपडेट करने वाले एंडपॉइंट](https://developers.brevo.com/reference/create-contact) इस्तेमाल करती है। यह छोटे तय आयात के लिए है, बल्क लोडर या बिल्ट-इन Google Sheets कनेक्टर नहीं। ईमेल नहीं भेजती। सहमति का प्रमाण और स्क्रिप्ट चलाना आपकी जिम्मेदारी है।

## Sheet और लिस्ट तैयार करें

`Contacts` टैब में ठीक ये हेडर बनाएं। `consent` में चेकबॉक्स रखें और तय मार्केटिंग उपयोग के लिए अनुमति होने पर ही `TRUE` सेट करें।

| email | firstName | lastName | consent |
| --- | --- | --- | --- |
| [jane@example.com](mailto:jane@example.com) | Jane | Doe | TRUE |
| [alex@example.com](mailto:alex@example.com) | Alex | Lee | FALSE |

Brevo लिस्ट चुनें या बनाएं और उसकी संख्यात्मक ID को `LIST_ID` में डालें। Brevo में `FNAME` और `LNAME` एट्रिब्यूट होने चाहिए; केवल यही मैप होते हैं। Sheet में सहमति का समय और तरीका साबित न हो तो स्रोत रिकॉर्ड अलग रखें। `TRUE` सेल अपने आप प्रमाण नहीं है।

**Extensions → Apps Script → Project Settings → Script Properties** में `BREVO_API_KEY` जोड़ें। गुण स्क्रिप्ट उपयोगकर्ताओं में साझा होते हैं, इसलिए संपादन सीमित रखें। की को सेल या कोड में न रखें। [Google के एक्सेस नियम](https://developers.google.com/apps-script/guides/properties) देखें।

## स्क्रिप्ट

`Code.gs` को इस उदाहरण से बदलें और पहले रन से पहले `LIST_ID` सेट करें।

```javascript
const LIST_ID = 42; // Replace with your existing Brevo list ID.
const TAB = 'Contacts';
const BASE = 'https://api.brevo.com/v3';

function syncSheetToBrevo() {
  const key = PropertiesService.getScriptProperties().getProperty('BREVO_API_KEY');
  if (!key) throw new Error('Set BREVO_API_KEY in Script Properties first');
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(TAB);
  if (!sheet) throw new Error('Contacts tab missing');
  const values = sheet.getDataRange().getValues();
  const headers = values.shift().map(h => String(h).trim());
  const columns = ['email', 'firstName', 'lastName', 'consent']
    .map(name => headers.indexOf(name));
  if (columns.includes(-1)) throw new Error('Required header missing');
  const [emailCol, firstCol, lastCol, consentCol] = columns;
  const seen = new Set();
  const result = { written: 0, skipped: 0 };

  for (const row of values) {
    const email = String(row[emailCol] || '').trim().toLowerCase();
    if (row[consentCol] !== true || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email) || seen.has(email)) {
      result.skipped++;
      continue;
    }
    seen.add(email);
    const path = '/contacts/' + encodeURIComponent(email);
    const current = brevo_(key, path, 'get');
    if (current.code !== 200 && current.code !== 404) {
      throw new Error(`Contact read failed (${current.code}) for row ${result.written + result.skipped + 2}`);
    }
    if (current.code === 200) {
      const contact = JSON.parse(current.text);
      if (contact.emailBlacklisted || (contact.listUnsubscribed || []).includes(LIST_ID)) {
        result.skipped++;
        continue;
      }
    }
    const attributes = {};
    if (row[firstCol] !== '') attributes.FNAME = String(row[firstCol]);
    if (row[lastCol] !== '') attributes.LNAME = String(row[lastCol]);
    const body = { attributes, listIds: [LIST_ID] };
    const saved = current.code === 404
      ? brevo_(key, '/contacts', 'post', { email, ...body })
      : brevo_(key, path, 'put', body);
    if (![201, 204].includes(saved.code)) {
      throw new Error(`Contact write failed (${saved.code}) for ${email}: ${saved.text.slice(0, 200)}`);
    }
    result.written++;
  }
  Logger.log(JSON.stringify(result));
  return result;
}

function brevo_(key, path, method, body) {
  for (let attempt = 0; attempt < 3; attempt++) {
    const response = UrlFetchApp.fetch(BASE + path, {
      method,
      contentType: 'application/json',
      headers: { 'api-key': key },
      payload: body ? JSON.stringify(body) : undefined,
      muteHttpExceptions: true,
    });
    const code = response.getResponseCode();
    if (code !== 429) return { code, text: response.getContentText() };
    if (attempt === 2) return { code, text: response.getContentText() };
    const reset = Object.entries(response.getHeaders()).find(
      ([name]) => name.toLowerCase() === 'x-sib-ratelimit-reset'
    );
    const raw = Number(reset && reset[1]);
    const seconds = Number.isFinite(raw) && raw > 0 ? raw : 2 ** attempt;
    const waitSeconds = seconds + 2 ** attempt;
    if (waitSeconds > 60) return { code, text: response.getContentText() };
    Utilities.sleep(waitSeconds * 1000);
  }
}
```

सेव करें, `syncSheetToBrevo` चुनें और **Run** दबाएं। Google, Sheets और बाहरी अनुरोध की अनुमति पूछेगा। **Executions** में `{written, skipped}` लॉग देखें। पढ़ने पर 404 मिले तो नया कॉन्टैक्ट, 200 मिले तो अपडेट; बाकी त्रुटि पर रन रुकता है। कॉन्टैक्ट राइट सफल होने का मतलब अभियान भेजना नहीं है।

स्क्रिप्ट एक रन में दोहराए ईमेल हटाती है और अगले रन में Brevo फिर जांचती है। यह `emailBlacklisted` को `false` नहीं करती और पता नहीं बदलती। Brevo अगर वैश्विक ब्लॉक या लक्ष्य लिस्ट से अनसब्सक्राइब बताए, तो Sheet में `TRUE` होने पर भी पंक्ति छोड़ दी जाती है। इसे अनसब्सक्राइब पलटने के लिए न चलाएं। [Brevo बताता है](https://developers.brevo.com/reference/update-contact) कि ब्लॉक कॉन्टैक्ट का पता बदलने से ब्लॉक हट सकता है।

## शेड्यूल से पहले एक रन जांचें

अपनी टेस्ट लिस्ट और कॉन्टैक्ट लें। एक `TRUE`, एक `FALSE` और एक दोहराए ईमेल से एक राइट और दो स्किप अपेक्षित हैं। टेस्ट कॉन्टैक्ट को Brevo में अनसब्सक्राइब करके फिर चलाएं: उस पर राइट नहीं होनी चाहिए। त्रुटि जांचने के लिए अस्थायी गलत `LIST_ID` दें, **Executions** में HTTP त्रुटि देखें, ID वापस रखें और दोहराएं। असली ग्राहक डेटा पर टेस्ट न करें। कोड स्थानीय रूप से नकली Brevo रिस्पॉन्स पर जांचा गया है, कोई लाइव राइट नहीं।

**Apps Script → Triggers → Add Trigger** में `syncSheetToBrevo` और समय अंतराल चुनें। [ट्रिगर बनाने वाले के अकाउंट से चलता है](https://developers.google.com/apps-script/guides/triggers/installable), जिसे Sheet की पहुंच बनी रहनी चाहिए। छोटे Sheet पर रोज एक बार शुरू करें और त्रुटियां देखें। Google [रन समय और URL Fetch उपयोग सीमित करता है](https://developers.google.com/apps-script/guides/services/quotas); बड़े स्रोत को सीमित कार्यों में बांटें।

429 पर स्क्रिप्ट `x-sib-ratelimit-reset` पढ़कर अधिकतम दो बार फिर कोशिश करती है। जरूरी प्रतीक्षा 60 सेकंड से अधिक हो तो अगली बार के लिए 429 लौटा देती है, जल्दी रिट्राई नहीं करती। अन्य त्रुटि भी रन रोकती है; अगली बार शुरुआत से चलता है। पढ़ने और लिखने के बीच कॉन्टैक्ट अनसब्सक्राइब हो सकता है। यह छोटा अंतर स्वीकार हो तभी उदाहरण लें। ज्यादा सख्त सुरक्षा में इवेंट मिलान, भरोसेमंद सहमति स्रोत और भेजने से पहले अंतिम जांच चाहिए।

बड़े Sheet के लिए [Brevo का असिंक्रोनस आयात](https://developers.brevo.com/reference/import-contacts) `processId` देता है। यह कार्य स्वीकार होने का संकेत है, पूरा होने का नहीं। सफलता बताने से पहले नतीजा जांचें। यहां हर कॉन्टैक्ट का रास्ता त्रुटि वाली पंक्ति दिखाता है।

## अक्सर पूछे जाने वाले प्रश्न

**क्या बिल्ट-इन Google Sheets कनेक्टर चाहिए?**

नहीं। उदाहरण Sheet से जुड़े Apps Script प्रोजेक्ट में चलता है और Brevo कॉन्टैक्ट API कॉल करता है। स्क्रिप्ट, API की और तय ट्रिगर आप संभालते हैं।

**कौन-सी पंक्तियां Brevo भेजी जाती हैं?**

केवल consent TRUE और वैध ईमेल वाली। स्क्रिप्ट हर रन में डुप्लिकेट हटाती है और लिखने से पहले Brevo जांचती है।

**फिर चलाने पर अनसब्सक्राइब व्यक्ति वापस जुड़ जाएगा?**

स्क्रिप्ट Brevo में emailBlacklisted या लक्ष्य लिस्ट से अनसब्सक्राइब कॉन्टैक्ट छोड़ती है। यह emailBlacklisted: false नहीं भेजती और ईमेल नहीं बदलती। प्रोडक्शन से पहले अन्य सहमति और ब्लॉक स्रोत जांचें।

**असफल रन कैसे दोहराएं?**

Apps Script Executions में त्रुटि पढ़ें, वजह सुधारें और वही फ़ंक्शन फिर चलाएं। समान ईमेल और लिस्ट ID से पहले सफल पंक्ति नया कॉन्टैक्ट नहीं बनाती।

## संबंधित लेख

### [Brevo में CSV या Excel कॉन्टैक्ट्स को स्क्रिप्ट से कैसे इम्पोर्ट करें (Python, Node.js, cURL)](https://tajo.io/hi/blog/import-csv-contacts-to-brevo-with-a-script/)

30 अप्रैल 2026 · 6 मिनट पढ़ें

CSV → Brevo

### [VBA मैक्रो के साथ Excel कॉन्टैक्ट्स को Brevo में कैसे पुश करें (और Office Scripts विकल्प)](https://tajo.io/hi/blog/import-excel-contacts-to-brevo-with-vba-macro/)

30 अप्रैल 2026 · 7 मिनट पढ़ें

Microsoft Excel → Brevo

### [Brevo एकीकरण: ऐसा कनेक्शन चुनें जिसे जाँचा जा सके](https://tajo.io/hi/blog/brevo-connector-guide/)

19 अग॰ 2026 · 4 मिनट पढ़ें

6 खंड
