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 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, notably through HTTPS encryption.

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 SMS sending service from Web pages and applications using JavaScript or Node. JS-based methods. Very simple queries to integrate into your development, you can configure sending and receiving SMS to a recipient just like managing the entire account (contact file, available credits, scheduling the date and Time of dispatch, consultation of the Status of reception, personalization of the issuer, 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

20 Free Javascript or Node. js SMS
Free registration and account creation in 30 seconds.
No credit card required.

CREATE A FREE ACCOUNT

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 monitored continuously. You can have access to the performance of your SMS shipments through our Kibana traffic monitoring system. At a glance, you follow through the detailed results and statistics delivered in real time, the success of your SMS campaigns, just as you are alerted to possible slowdowns of the system.

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