Skip to main content

Overview

This guide shows how to send an SMS notification using Plivo’s APIs and the Node.js SDK.

Prerequisites

  • A Plivo account — sign up for free if you don’t have one.
  • An SMS-enabled Plivo phone number to send messages to the US and Canada. You can rent a number from the Plivo console.
  • Node.js and the Plivo Node.js SDK installed. See our Node.js setup guide.

Create and run the application

Create a file named send_sms.js and paste this code into it. This script sends a notification using the messages.create function.Replace the <auth_id>, <auth_token>, <sender_id>, and <destination_number> placeholders with your actual values.
const plivo = require('plivo');

async function sendSmsNotification() {
  const client = new plivo.Client("<auth_id>", "<auth_token>");
  try {
    const response = await client.messages.create({
      src: "<sender_id>",
      dst: "<destination_number>",
      text: "Appointment reminder: 12:00 noon tomorrow. Please reply to this message if you need to make a change"
    });
    console.log("Message sent successfully:", response);
  } catch (error) {
    console.error("Error sending message:", error);
  }
}

sendSmsNotification();

Test

Save the file and run it from your terminal.
node send_sms.js
You should receive the SMS notification on your destination phone.