Back to Blog
Integration Guides

How to Integrate Twilio with Google Sheets: Step-by-Step Guide

Use Google Sheets as a lightweight SMS campaign manager by connecting it to Twilio via Apps Script or a no-code automation tool.

DA
Danial A
Senior Twilio Consultant, Telphi Consulting
June 22, 2026
7 min read
Twilio
Integration
Productivity
How to Integrate Twilio with Google Sheets: Step-by-Step Guide

Google Sheets and Twilio connect through Google Apps Script to turn a spreadsheet into a functional SMS campaign manager where each row represents a contact, a custom script sends the Twilio SMS, and a status column updates automatically with the delivery result. This setup is popular with small teams and solo operators who maintain their contact lists in Google Sheets and want a low-cost, no-server way to run SMS outreach without a dedicated marketing tool. You can also trigger this flow from Google Sheets formulas and time-based triggers so messages go out automatically on a schedule without any manual step.

What You Need Before You Start

Set up your Google Sheet with a consistent column structure: Column A for recipient name, Column B for phone number in E.164 format, Column C for the message body, Column D for a Sent status flag, and Column E for the timestamp, as the Apps Script will reference these column positions when iterating rows. Open the Apps Script editor by clicking Extensions, then Apps Script in your Google Sheet, which opens the script editor tied to this specific spreadsheet. From Twilio, collect your Account SID and Auth Token, and store them in the Apps Script project's Script Properties under Project Settings, then Script Properties rather than hardcoding them in the script, to avoid exposing credentials in the code. Verify your Twilio phone number is SMS-capable by checking the Console under Phone Numbers, then Active Numbers, and confirm the Messaging capability is enabled before running any script against it.

Step-by-Step Integration Guide

In the Apps Script editor, write a function named sendSMSFromSheet that retrieves your credentials from PropertiesService.getScriptProperties().getProperty('TWILIO_ACCOUNT_SID') and getProperty('TWILIO_AUTH_TOKEN'), then opens the active spreadsheet with SpreadsheetApp.getActiveSpreadsheet().getActiveSheet() and reads all data rows with sheet.getDataRange().getValues(). Iterate over the rows array starting at index 1 to skip the header, check that column index 3 (Sent) is not already marked as Sent to skip previously processed rows, and construct the Twilio API URL as 'https://api.twilio.com/2010-04-01/Accounts/' + accountSid + '/Messages.json'. Call UrlFetchApp.fetch with the URL, method set to post, payload set to an object with To, From, and Body fields, headers set to Authorization: 'Basic ' + Utilities.base64Encode(accountSid + ':' + authToken), and muteHttpExceptions set to true, then parse the JSON response and write Sent or Failed plus the current date to columns D and E on the same row using sheet.getRange(rowIndex + 1, 4).setValue('Sent'). Set up a time-based installable trigger by clicking the clock icon in the Apps Script editor under Triggers, adding a new trigger for your sendSMSFromSheet function with a time-driven source and your preferred interval such as every hour or a specific daily time to automate the send without manual execution.

Common Issues and How to Fix Them

UrlFetchApp calls to the Twilio API fail with a 403 Forbidden error when the Authorization header is formatted incorrectly, typically when the base64 encoding includes a newline character or space. Use Utilities.base64Encode(accountSid + ':' + authToken) exactly as shown, and verify the encoded string does not contain whitespace by logging it to the Apps Script Logger before including it in the header. Apps Script has an execution time limit of 6 minutes per run, which means a script iterating over thousands of rows will time out before completing the full send. Implement a batch size limit in your script that stops after processing 50 rows per execution and marks a checkpoint row in the sheet, then relies on the time-based trigger to resume on the next run from where the previous execution stopped. Phone numbers entered in Google Sheets often contain local formats, spaces, or dashes that Twilio rejects as invalid To numbers. Add a normalization step inside the row iteration that strips all non-digit characters from the phone value using JavaScript replace and a regex, then prepends the country code before passing to the payload, and skips rows where the resulting string is shorter than 10 digits.

How to Get More from This Integration

Add a custom menu to your Google Sheet by calling SpreadsheetApp.getUi().createMenu('Twilio SMS').addItem('Send to Selected Rows', 'sendSMSSelected').addToUi() in an onOpen function, giving non-technical users a one-click button to trigger the SMS send without opening the Apps Script editor. Build an inbound SMS logger by deploying your Apps Script as a web app using the Deploy menu and setting access to Anyone, then configuring your Twilio number's inbound webhook URL to the deployed web app URL, and in the doPost function appending the From, Body, and timestamp to a new row in a separate Responses sheet. Use Apps Script's Sheets API integration to filter recipients by a Google Sheets named range before sending, allowing marketing managers to select a named range like CampaignMarch and only send to contacts included in that range without modifying the main contact list. Integrate Google Sheets with Twilio Lookup by adding a script function that validates all phone numbers in the sheet before the campaign send, calling https://lookups.twilio.com/v2/PhoneNumbers/{number}?Fields=line_type_intelligence via UrlFetchApp and writing the line type back to a validation column so you can exclude landlines from SMS campaigns.

Conclusion

Google Sheets and Twilio together create a practical zero-infrastructure SMS tool that most teams can build and operate without a developer on staff once the initial script is set up. Talk to our team at Telphi Consulting to build, test, and automate this integration for your specific Google Sheets workflow.

Share this article:
0 views

Ready to Transform Your Business Communications?

Get a free consultation with our VoIP experts and discover how we can help you save costs, improve efficiency, and scale your business.

Comments (0)

Join the discussion and share your thoughts (AI-moderated for quality)

Protected by AI moderation

Be the first to comment

No comments yet. Share your thoughts below.