SMS delivery: What rate should you expect? How to optimize it. read the article SMS delivery: What rate should you expect? How to optimize it.read the article Entrega de SMS: ¿Qué tasa debe esperar? Cómo optimizarlo. leer el artículo Consegna degli SMS: quale tasso di consegna si deve prevedere? Come ottimizzarlo.per saperne di più SMS-Zustellung: Welche Rate ist zu erwarten? Wie man sie optimiert.mehr erfahren

focus smsmode©

focus on
SMS Javascript and Node.js

You build a Javascript or Node. JS application and you must send SMS messages. Did you know that it only takes a few minutes? So, with our HTTP API, you can actually build a custom SMS-sending solution, meet specific needs defined and automate your SMS communication from your Javascript and Node. Js tools.

Here is a quick start guide that will show you how fast it is to start sending an SMS!

I discover the API Documentation

SENDING JAVASCRIPT SMS IN DETAIL
Integrating a free SMS gatewaySimple and quick API integration

Compatible with all programming languages with HTTP GET and POST requests, the complete and free documentation allows a simple, fast and step by step integration.

Maximum security for automated SMS sentMaximum security

Hosted in France, in a level 4 data-center, our SMS APIs guarantee maximum security, thanks in particular to the HTTPS protocol.

High Availability dedicated InfrastructureContinuous service

Our dedicated, high-availability infrastructure is continuously monitored 24/7/365 with fail-safecapability.

Support Team at your disposalTechnical support at your disposal

Our dedicated team of developers is available to help you integrate our SMS APIs or answer your questions.

Examples of Javascript and Node. JS SMS

QUICK START GUIDE

How to send your first Javascript SMS?

The HTTP API allows you to make calls to our automatic SMS sending service from web pages and applications using methods based on JavaScript or Node.js. Requests are very simple to integrate into your development, you can configure the sending and receiving of SMS to a recipient as well as manage the entire account (contact file, available credits, programming the date and time of sending, consultation of reception status, personalization of the sender, etc.).

The following NodeJs source code allows you to make your first SMS submission.

const urlencode = require('urlencode');
var exports=module.exports={};
const urlencode = require('urlencode');
const http = require('https');
const querystring = require('querystring');
const fs = require('fs');
const pathname = require("path");
const ERROR_API = "Error during API call";
const ERROR_FILE = "The specified file does not exist";
const HOSTNAME = 'api.smsmode.com'
const PATH_SEND_SMS = "/http/1.6/sendSMS.do";
const PATH_SEND_SMS_Batch = "/http/1.6/sendSMSBatch.do";

/**
*    Function parameters:
*
*    - accessToken (required)
*    - message (required)
*    - destinataires (required): Receivers separated by a comma
*    - emetteur (optional): Allows to deal with the sms sender
*    - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
*    - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/

exports.ExempleClientHttpAPI = class {

 // send SMS with GET method
 async sendSmsGet(accessToken, message, destinataires, emetteur, optionStop) {

     var finalPath = PATH_SEND_SMS + '?accessToken=' + accessToken + '&numero=' + destinataires + 
         "&message=" + urlencode(message,'ISO-8859-15') + '&emetteur=' + emetteur + '&stop=' + optionStop;
     const options = {
         hostname: HOSTNAME,
         port: 443,
         path: finalPath,
         method: 'GET'
     };
     try {
         let http_promise = this.getHttpResponse(options, "");
         let response_body = await http_promise;
         return response_body;
     }
     catch(error) {
         return ERROR_API;
     }
 }

 // send SMS with POST method
 async sendSmsPost(accessToken, message, destinataires, emetteur, optionStop) {

     var postData = querystring.stringify({
         'accessToken': accessToken, 
         'numero': destinataires, 
         'emetteur' : emetteur, 
         'stop' : optionStop 
     });
     postData = postData + "&message=" + urlencode(message,'ISO-8859-15');
     const options = {
         hostname: HOSTNAME,
         port: 443,
         path: PATH_SEND_SMS,
         method: 'POST',
         headers: {
             'Content-Type': 'application/x-www-form-urlencoded; charset=ISO-8859-15',
             'Content-Length': Buffer.byteLength(postData)
         }
     };
     try {
         let http_promise = this.getHttpResponse(options, postData);
         let response_body = await http_promise;
         return response_body;
     }
     catch(error) {
         return ERROR_API;
     }
 }

 // send SMS with POST method (Batch)
 async sendSmsBatch(accessToken, batchFilePath, optionStop) {

     var finalPath = PATH_SEND_SMS_Batch + "?accessToken=" + accessToken + "&stop=" + optionStop;
     try {
         let content_file_promise = this.getContentFile(batchFilePath);
         let content = await content_file_promise;
         var boundary = "AaB03x";
         var postData = Buffer.concat([
             Buffer.from("--" + boundary + "\r\n"),
             Buffer.from("Content-Disposition: form-data; name=\"file\"; filename=\""),
             Buffer.from(pathname.basename(batchFilePath) + "\"\r\n"),
             Buffer.from("Content-Type:text/csv\r\n\r\n"),
             Buffer.from(content),
             Buffer.from("\r\n--" + boundary + "--\r\n"),
         ]);
         var options = {
             method: 'POST',
             hostname: HOSTNAME,
             port: 443,
             path: finalPath,
             headers: {
                 "Content-Type": "multipart/form-data; boundary=" + boundary,
                 'Content-Length': Buffer.byteLength(postData)
             }
         };
         try {
         let http_promise = this.getHttpResponse(options, postData);
         let response_body = await http_promise;
         return response_body;
         }
         catch(error) {
             return ERROR_API;
         }
     }
     catch(error) {
         return ERROR_FILE;
     }
 }

 getHttpResponse(options, postData) {
     return new Promise((resolve, reject) => {
         const req = http.request(options, (res) => {
             let chunks_of_data = [];
             res.on('data', (fragments) => {
                 chunks_of_data.push(fragments);
             });
             res.on('end', () => {
                 let response_body = Buffer.concat(chunks_of_data);
                 resolve(response_body.toString());
             });
         });
         req.on('error', (error) => {
             reject(error);
         });
         req.write(postData);
         req.end();
     });
 }

 getContentFile(batchFilePath) {
     return new Promise((resolve, reject) => {
         fs.readFile(batchFilePath, async function(err, content) {
             if (err) {
                 reject(err);
             } else {
                 resolve(content);
             }
         });
     });
 }
}

You are now able to send your first SMS in Javascript!

You sent a text message; You are now ready to use the full potential of SMS Marketing. See the HTTP API documentation and its settings to explore all the features offered.

CONSULT API HTTP DOCUMENTATION

Why choose our SMS gateway?

Widely approved by hundreds of customers everywhere, our solution is simple and fast to install and is compatible with many programming languages (PHP, Java, Javascript, ASP, C++, C#, Ruby, Python, SKD, WINDEV, .net, etc.).

It offers:

1Routing on the best routes
As a Telecom Operator, we only route SMS through high quality roads. This allows us to guarantee you a rate of reception of your messages to the French telecom operators of 87% within one minute after sending. A real guarantee of quality and maximum deliverability.

2A system for monitoring and supervising the sending of SMS messages
Our SMS Gateway is continuously monitored. You can have access to the performance of your SMS sendings via our traffic monitoring system Kibana. At a glance, you can follow the success of your SMS campaigns via detailed results and statistics delivered in real time, as well as being alerted to possible system slowdowns.

3A robust, flexible infrastructure approved by nearly 10,000 customers
Our high availability gateway treats more than 1 million requests daily for a shipment volume of more than 100 million SMS sent per year. The management of sending priorities (prioritization of traffic notification on marketing traffic) is also managed to offer better performance.

WebService sending SMS Javascript and Node. js

Provider & Gateway SMS

Our team advises you...

Our commercial and technical teams are at your disposal via email, phone or chat to answer all your questions about the implementation of the sending of SMS Javascript and Node. js. As an SMS service provider for almost 15 years, you will benefit from our advice on setting up and our expertise in SMS mailings.

CONTACT US