Azure Communication SMS services gives developers the ability to send SMS messages from a phone number that can be purchased through Communication Services.
npm install @azure/communication-sms
SmsClient
is the primary interface for developers using this client library. It provides an asynchronous method to send SMS messages.
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:
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);
import { SmsClient } from "@azure/communication-sms";
const connectionString = `endpoint=<Host>;accessKey=<Base64-Encoded-Key>`;
const client = new SmsClient(connectionString);
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!"
});
Please take a look at the samples directory for detailed examples on how to use this library.
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.
Generated using TypeDoc