You're ready to let Google Apps Script move orders, send emails, and update inventory automatically. The first question most small‑business owners ask is: Will the script keep running when my sales spike? The answer depends on knowing the platform's quotas and building a flow that survives quota‑related failures.
Direct answer: Check limits, design retries, and monitor logs before you go live
Before you publish any script, review the official quota list, calculate the maximum calls your workflow will need each day, and add explicit error handling (try/catch, exponential back‑off). Deploy the script in a test sheet, enable email alerts for failures, and verify that the daily quota never exceeds the limits. If the script reaches a limit, the fallback should pause further processing and notify you, so you can intervene without losing orders or cash flow.
Prerequisites
- A Google account with edit access to the target Google Sheet.
- Basic familiarity with Apps Script editor (menu → Extensions → Apps Script).
- Understanding of the business process you want to automate (e.g., order confirmation, inventory deduction).
1. Understanding Google Apps Script Limits
Google enforces several quotas to protect shared resources. The most relevant for e‑commerce automations are:
- Execution time per script run: 6 minutes for consumer accounts, 30 minutes for Workspace accounts.
- Daily total execution time: 90 minutes for free accounts, higher for paid Workspace plans.
- Triggers per user: 20 time‑driven triggers (e.g., every hour) and 20 installable triggers (e.g., onEdit).
- Read/write calls to Google Sheets: 500 reads and 500 writes per minute per user.
- Mail service quota: 100 emails/day for free accounts, 1,500 for Workspace.
All limits are listed on the official Apps Script quotas page. They can change, so check the page whenever you modify a workflow.
Why does this matter for cash flow? If a script stops because it hit a quota, orders may sit in your sheet without confirmation emails, leading to delayed shipments and unhappy customers. Knowing the limits lets you size your automation to match your sales volume or upgrade to a Workspace plan before the bottleneck appears.
2. Designing a Failure‑Resilient Automation Flow
Even with careful quota planning, occasional spikes or temporary service hiccups happen. Build resilience in three layers:
2.1 Use try/catch and exponential back‑off
Wrap every external call (MailApp, SpreadsheetApp, UrlFetchApp) in a try block. If the call throws an error, pause briefly and retry. Exponential back‑off means the wait time doubles after each failure, reducing the chance of hitting the same limit again.
function sendOrderEmail(row) { var maxAttempts = 5; var delay = 1000; // 1 second for (var i = 0; i < maxAttempts; i++) { try { MailApp.sendEmail(row.email, 'Order Confirmation', 'Your order is received'); return true; // success } catch (e) { Logger.log('Attempt ' + (i+1) + ' failed: ' + e.message); if (i == maxAttempts - 1) throw e; // re‑throw after final attempt Utilities.sleep(delay); delay *= 2; // exponential back‑off } } }2.2 Split heavy work into batches
Instead of processing 1,000 rows in a single run, process 200 rows, record the last processed row number in a hidden cell, and schedule the next batch with a time‑driven trigger. This keeps each run well under the 6‑minute execution limit and spreads sheet read/write calls over time.
2.3 Centralised logging and alerting
Use Logger.log() for debugging and the built‑in Stackdriver Logging for production monitoring. Additionally, send an email to the admin when a script fails after all retries:
function notifyAdmin(error) { MailApp.sendEmail('[email protected]', 'Apps Script Failure', error.stack); }Combine the two ideas: catch the final error, log it, and call notifyAdmin.
3. Realistic Example: Order Confirmation Sheet
Imagine a Shopify store that exports daily orders to a Google Sheet called Orders. Each row contains:
- Order ID
- Customer email
- SKU
- Quantity
- Status (Pending / Confirmed / Error)
Goal: automatically send a confirmation email and mark the row as Confirmed. Assume an average of 150 orders per day, with occasional peaks up to 300.
Step‑by‑step quota check:
- Each email uses MailApp.sendEmail → 150 emails/day (well under the free 100‑email limit, so a Workspace upgrade is advisable).
- Reading the sheet once (500 rows) is a single read call; writing status for each row is 150 writes, well under the 500 writes/minute limit.
- Execution time: processing 150 rows with the batch size of 50 takes ~2 minutes, far below the 6‑minute cap.
If a spike pushes orders to 300, the email quota becomes the bottleneck. Options:
- Upgrade to Workspace (1,500 emails/day).
- Add a second script that queues emails in a separate sheet and sends them in batches over several hours.
Below is a minimal script that respects the batch size and includes error handling:
function processOrders() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Orders'); const lastRow = sheet.getLastRow(); const batchSize = 50; const startRow = Number(sheet.getRange('Z1').getValue()) || 2; // Z1 stores last processed row const endRow = Math.min(startRow + batchSize - 1, lastRow); const data = sheet.getRange(startRow, 1, endRow - startRow + 1, 5).getValues(); data.forEach((row, index) => { if (row[4] !== 'Pending') return; // skip non‑pending rows try { MailApp.sendEmail(row[1], 'Order Confirmation', `Your order ${row[0]} is confirmed.`); sheet.getRange(startRow + index, 5).setValue('Confirmed'); } catch (e) { Logger.log('Error on row ' + (startRow + index) + ': ' + e.message); sheet.getRange(startRow + index, 5).setValue('Error'); notifyAdmin(e); } }); // Store next start row for the following trigger run const nextRow = endRow + 1; sheet.getRange('Z1').setValue(nextRow