Options
All
  • Public
  • Public/Protected
  • All
Menu

@azure/communication-sms

Package version

Azure Communication SMS client library for JavaScript

Azure Communication SMS services gives developers the ability to send SMS messages from a phone number that can be purchased through Communication Services.

Getting started

Prerequisites

Installing

npm install @azure/communication-sms

Key concepts

SmsClient

SmsClient is the primary interface for developers using this client library. It provides an asynchronous method to send SMS messages.

Examples

Authentication

You can get a key and/or connection string from your Communication Services resource in Azure Portal. Once you have a key, you may authenticate with any of the following methods:

Create a credential with AzureKeyCredential

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

const credential = new AzureKeyCredential("<Base64-Encoded-Key>");
const client = new SmsClient("<Host>", credential);

Using a connection string

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

const connectionString = `endpoint=<Host>;accessKey=<Base64-Encoded-Key>`;
const client = new SmsClient(connectionString);

Sending SMS

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

const credential = new AzureKeyCredential("<Base64-Encoded-Key>");
const client = new SmsClient("<Host>", credential);

const response = await client.send({
  from: "+12345678902",
  to: ["+12345678901"],
  message: "Hey there!"
});

Troubleshooting

Next steps

Please take a look at the samples directory for detailed examples on how to use this library.

Contributing

If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.

Related projects

Impressions

Generated using TypeDoc