Skip to main content

Overview

This guide shows how to send an SMS message to multiple phone numbers at once using Plivo’s APIs and the Node.js SDK.

Prerequisites


Create and run the application

Create a file named send_bulk_sms.js and paste this code into it. To send a message to multiple numbers, join the destination numbers with the delimiter <.Replace the <auth_id>, <auth_token>, and <sender_id> placeholders with your actual values, and add the destination numbers to the destinations array.
const plivo = require('plivo');

async function sendBulkSms() {
  const client = new plivo.Client("<auth_id>", "<auth_token>");

  const destinations = [
    "<destination_number_1>", // E.g., "+14155551234"
    "<destination_number_2>"  // E.g., "+14155555678"
  ];

  try {
    const response = await client.messages.create({
      src: "<sender_id>",
      dst: destinations.join("<"), // Delimiter is '<'
      text: "Flash sale — half price on all products — offer expires at midnight. Use code 50OFF at checkout"
    });
    console.log("Message sent successfully:", response);
  } catch (error) {
    console.error("Error sending message:", error);
  }
}

sendBulkSms();

Test

Save the file and run it from your terminal.
node send_bulk_sms.js
You should receive the SMS on all destination phones.