Receive Real-Time Incoming SMS into Google Spreadsheet
In this tutorial, we'll demonstrate how to receive/capture incoming SMS messages real-time into Google Spreadsheet using Apps Script. Apps Script is a cloud-based JavaScript platform that lets you integrate with and automate tasks across Google products. Even if you've never written a line of code before, the process takes less than ten minutes to finish.
Using our apps script code, you can capture long code incoming SMS messages.
Before you Begin
- An SMS Gateway Center’s SMS account with credits in your account balance with a paid subscription.
- A completely functional Google account having access with Google Spreadsheets.
- You must have a keyword set in your account to receive incoming SMS messages to the assigned long code.
Ready your Google Spreadsheet
Go to your Google account, click on Sheets.
A new tab will be opened where you can start a new spreadsheet, Click on Blank from shown template gallery as shown below.
A new blank spreadsheet will open. Rename the Sheet from Untitled spreadsheet to Incoming SMS. Now add headers in the sheet. In row 1 of the spreadsheet, add column titles:
- Column 1 (A) = Date
- Column 2 (B) = VMN (Long code number)
- Column 3 (C) = Mobile
- Column 4 (D) = Keyword
- Column 5 (E) = Circle
- Column 6 (F) = Operator
- Column 7 (G) = Received Time
- Column 8 (H) = Message
Once you are done with column header in sheets, now head on to add our ready script. You can get our complete downloadable code, once you are recharged with your account from our team.
Go to Toolbar, Click on Extensions, then Apps Script.
A new Apps Script tab will open. Rename Untitled project to Receive Incoming SMS Code. By default, code.js editor will be shown.
Remove all codes from the editor window. Copy and paste the given code from our team on this window and edit the following constants. Update Sheet1 to as you have named your sheet, if you have not changed the sheet name, then leave it as it is. Once editing is done, click on save button. On the top right, Click on Deploy and click on New deployment.
A pop window will open, click on Cog icon, you will be shown with options. Click on Web app, and now you will be shown with options.
- Description: Enter a short description.
- Execute as: Select Me.
- Who has access: Select Anyone from the drop-down options.
At the bottom, click on Deploy.
Google requires permission, so it pops up a confirm window to authorize your account with the added script. Click on Authorize access.
By continuing, it will take you to select your Google account, select the account which you have used for your sheet.
Since our script is not verified from Google, it will give you a warning in the next window, click on Advanced.
Advanced option will be shown as shown below. Click on Go to Receive Incoming SMS Code (unsafe).
In the next window, it will show the list of permission which your script requires, scroll down below and click on Allow. Do not worry, you are giving permission to your own account and no one else can access your app code or sheet data.
Once Deployment successfully gets updated, Google will provide you with Deployment ID and Web app URL. Copy the URL.
Now login to your SMS Gateway center account. Go to sidebar, look for 2 Way SMS and under that click on Manage 2 Way SMS Keywords
On keywords manage page, click on Edit.
On edit page, do the following:
- Add Callback URL (HTTP): Select Yes
- Callback URL (HTTP): Select POST method from dropdown and paste the Google's Webhook (URL) which we copied earlier.
Click on Save changes.
Once you save changes, this will go to moderation and our team will approve at the earliest.
You are done, the moment you start getting incoming SMS, the data will be forwarded to your Google's web app URL.
You can also contact us if you are facing issues, our team will help you to install the code and insert the data smoothly.
This concludes with your integration. Learn more from our SMS API documentation.
👍 Setup Complete!
If you are having difficulty, write to us at contact@smsgatewaycenter.com for assistance.