Azure Communication Services – JavaScript SDK

Send SMS with Azure Communication Services

This guide shows how to send SMS messages using the Azure Communication Services JavaScript SDK.

Prerequisites

Installation

npm install @azure/communication-sms

Code Example

import { SmsClient } from "@azure/communication-sms";

const connectionString = "";

const smsClient = new SmsClient(connectionString);

async function sendSms() {
  try {
    const sendResult = await smsClient.send({
      from: "",
      to: ["+1234567890"],
      message: "Hello from Azure Communication Services!",
      enableDeliveryReport: true,
      tag: "demo-sms"
    });
    console.log("SMS sent successfully:", sendResult);
  } catch (err) {
    console.error("Failed to send SMS:", err);
  }
}

sendSms();

Run the Example

Save the code to a file sendSms.js and execute:

node sendSms.js

API Reference

SmsClient.send(options)