Automating SMS Notifications: A Guide to Enhancing Customer Engagement

January 16, 2025, 11:48 pm
МТС Exolve
МТС Exolve
Location: Russia
Employees: 201-500
In the digital age, communication is the lifeblood of business. SMS notifications have emerged as a powerful tool for engaging customers. They cut through the noise, delivering messages directly to the palm of a user's hand. This article explores how to automate SMS notifications using Google Sheets and the MTS Exolve API, and how to notify customers about price drops in 1C-Bitrix.

Imagine a world where you can send instant alerts to your customers. Picture a system that automatically informs them of price drops on their favorite products. This is not just a dream; it’s a reality that can be achieved with the right tools and a bit of coding.

Sending SMS from Google Sheets


Google Sheets is more than just a spreadsheet tool. It’s a canvas for automation. With Google Apps Script, you can transform a simple sheet into a powerful communication hub.

Step 1: Setting Up Your Sheet


Start by creating a new Google Sheet. In cell A1, write your message. In cell B1, enter the recipient's phone number. This simple setup is the foundation for your SMS automation.

Step 2: Writing the Script


Open the Apps Script editor by navigating to Extensions > Apps Script. Here, you’ll write a script that pulls data from your sheet and sends an SMS via the MTS Exolve API.

```javascript
function sendSMSFromCell() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var messageCell = sheet.getRange('A1');
var destinationCell = sheet.getRange('B1');
var smsContent = messageCell.getValue();
var phoneNumber = destinationCell.getValue();
sendSMS('YOUR_SENDER_NUMBER', String(phoneNumber), smsContent);
}

function sendSMS(number, destination, text) {
var apiUrl = 'https://api.exolve.ru/messaging/v1/SendSMS';
var payload = {
'number': number,
'destination': destination,
'text': text
};
var options = {
'method': 'post',
'contentType': 'application/json',
'headers': {
'Authorization': 'Bearer YOUR_API_TOKEN'
},
'payload': JSON.stringify(payload),
'muteHttpExceptions': true
};
UrlFetchApp.fetch(apiUrl, options);
}
```

This script extracts the message and phone number from your sheet and sends it via the API.

Step 3: Running the Script


After writing your script, click “Run.” You’ll need to authorize the script to access your Google account. Once authorized, your SMS will be sent.

Step 4: Automating with Triggers


To automate SMS sending, set up a trigger. In the Apps Script editor, select “Triggers” and create a new trigger for the `sendSMSFromCell` function. Choose “On change” as the event type. Now, every time you update the sheet, an SMS will be sent automatically.

Mass SMS Sending


For bulk notifications, modify your script to loop through a list of phone numbers and messages. Create two columns in your sheet: one for phone numbers and another for messages. The script will send each message to its corresponding number.

```javascript
function sendBulkSMS() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = sheet.getDataRange().getValues();
const apiUrl = 'https://api.exolve.ru/messaging/v1/SendSMS';
const apiKey = 'YOUR_API_KEY';

for (let i = 1; i < data.length; i++) {
const phoneNumber = String(data[i][0]);
const message = data[i][1];
if (phoneNumber && message) {
const payload = {
"number": "YOUR_SENDER_NUMBER",
"destination": phoneNumber,
"text": message
};
const options = {
method: 'post',
contentType: 'application/json',
payload: JSON.stringify(payload),
headers: {
'Authorization': 'Bearer ' + apiKey
}
};
UrlFetchApp.fetch(apiUrl, options);
}
}
}
```

This bulk sending feature allows you to reach multiple customers at once, enhancing your marketing efforts.

Notifying Customers of Price Drops in 1C-Bitrix


In the realm of e-commerce, keeping customers informed about price changes is crucial. 1C-Bitrix offers a robust platform for managing customer interactions.

Automating Price Checks


Set up a PHP script to regularly check for price changes on products marked as favorites by users. This script will compare current prices with historical data and notify users of any changes.

Step 1: Fetching Favorite Products


Use the built-in methods of 1C-Bitrix to retrieve a list of products marked as favorites.

```php
$userFavorites = getUserFavorites($userId);
```

Step 2: Comparing Prices


Fetch current prices and compare them with previous values stored in your database. If a price drop is detected, prepare a notification.

```php
if ($currentPrice < $oldPrice) {
$changedPrices[] = [
'ID' => $productId,
'NAME' => $productName,
'OLD_PRICE' => $oldPrice,
'NEW_PRICE' => $currentPrice,
];
}
```

Step 3: Sending Notifications


Integrate with the MTS Exolve API to send SMS notifications to users about price drops. Personalize the messages to enhance engagement.

```php
$message = "Hello, {$userName}! The price of {$productName} has dropped from {$oldPrice} to {$newPrice}. Check it out!";
```

Conclusion


Automating SMS notifications can significantly enhance customer engagement. Whether sending individual alerts or bulk messages, the integration of Google Sheets with the MTS Exolve API provides a seamless solution. Additionally, notifying customers about price drops in 1C-Bitrix keeps them informed and encourages purchases.

In a world where attention is fleeting, these automated systems ensure your messages are seen. They create a bridge between your business and your customers, fostering loyalty and driving sales. Embrace automation, and watch your customer engagement soar.