paint-brush
Using Plivo APIs For Sending SMS messages With Node.js by@plivo
538 reads
538 reads

Using Plivo APIs For Sending SMS messages With Node.js

by PlivoApril 4th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

This article guides you through how to use Plivo SMS API to send SMS from your application with Node.js. We'll send an SMS message with GSM characters, Unicode characters, and emojis, and a multipart message in the text body. Getting started is easy and only takes five minutes! Sign up today to send your first SMS message using Plivo’s Node.JS SDK. You must have an SMS-enabled Plivo phone number to send messages to the US and Canada.

Company Mentioned

Mention Thumbnail
featured image - Using Plivo APIs For Sending SMS messages With Node.js
Plivo HackerNoon profile picture
You can send your first SMS message using Node.js SDK within 5 minutes. This article guides you through how to use to send SMS from your application with . First, let’s make sure you meet the prerequisites before we dive into the code.

Prerequisites

 for a Plivo account if you haven't already!

Plivo Auth ID and Auth Token: You will find your Plivo Auth ID and Auth Token on the home screen of your .

Plivo Phone Number: You must have an SMS-enabled Plivo phone number to send messages to the US and Canada. Purchase numbers from the Numbers section of your . You can also purchase numbers using the .

Install  if you haven't already!Install :
npm install -g plivo

Send an SMS message

In this section, we'll send an SMS message with GSM characters, Unicode characters, and emojis, and a multipart message in the text body.

Send an SMS message with GSM characters

Now you’re ready to start. Create a file called sendSms.js and paste in this code:
const plivo = require('plivo');
const client = new plivo.Client('<auth_id>','<auth_token>');

client.messages.create(
  '+',
  '+',
  'Hello, world!'
).then(function(message_created) {
  console.log(message_created)
});

Send an SMS message with emojis

You can use this code to send an SMS with emojis in the message body:
const plivo = require('plivo');
const client = new plivo.Client('<auth_id>','<auth_token>');

client.messages.create(
  '+',
  '+',
  '👋 Hello from Plivo!'
).then(function(message_created) {
  console.log(message_created)
});

Send an SMS message with Unicode characters

You can use this code to send an SMS with Unicode characters in the message body:
const plivo = require('plivo');
const client = new plivo.Client('<auth_id>','<auth_token>');

client.messages.create(
  '+',
  '+',
  '您好,世界级!'
).then(function(message_created) {
  console.log(message_created)
});

Send a multipart SMS message

You can use this code to send an SMS message with a multipart message body. The message will be sent to the destination number in parts and will be concatenated at the recipient's end.
const plivo = require('plivo');
const client = new plivo.Client('<auth_id>','<auth_token>');

client.messages.create(
  '+',
  '+',
  'This randomly generated text can be used in your layout (webdesign , websites, books, posters ... ) for free. This text is entirely free of law. Feel free to link to this site by using the image below or by making a simple text link'
).then(function(message_created) {
  console.log(message_created)
});
Replace the placeholders auth_id and auth_token with actual values from your . Save the file and run it with the command:
node sendSms.js
An SMS message will be sent to the destination number specified in the code. To receive incoming SMS messages on your Plivo number, follow our .

Note: You can check our  to learn how Plivo manages GSM/Unicode characters in the message body.

Conclusion

And that’s all there is to sending SMS messages using Plivo’s Node.js SDK. Don’t use Node.js? Don’t worry — we have SDKs for , , , , , , and .Haven’t tried Plivo yet? Getting started is easy and only takes five minutes!  today.

Previously published at

바카라사이트 바카라사이트 온라인바카라