visit
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 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)
});
node sendSms.js
Note: You can check our to learn how Plivo manages GSM/Unicode characters in the message body.
Previously published at