JavaScript SDK Guide¶
The Azure Communication Services (ACS) JavaScript SDK provides comprehensive tools for building communication features in web browsers and Node.js applications.
SDK Packages¶
The SDK is modular, allowing you to install only the features you need.
| Feature | Package |
|---|---|
| Identity | @azure/communication-identity |
| SMS | @azure/communication-sms |
@azure/communication-email | |
| Chat | @azure/communication-chat |
| Calling (Client) | @azure/communication-calling |
| UI Library | @azure/communication-react |
| Phone Numbers | @azure/communication-phone-numbers |
| Call Automation | @azure/communication-call-automation |
Prerequisites¶
- Node.js 18 or later
- npm or yarn
- An active Azure subscription
- An ACS resource (see Local Setup)
Quick Start: Send SMS (Node.js)¶
const { SmsClient } = require("@azure/communication-sms");
const connectionString = "YOUR_CONNECTION_STRING";
const smsClient = new SmsClient(connectionString);
async function main() {
const sendResults = await smsClient.send({
from: "<registered-phone-number>",
to: ["<recipient-phone-number>"],
message: "Hello from ACS JavaScript SDK!"
});
for (const sendResult of sendResults) {
if (sendResult.successful) {
console.log("Success: ", sendResult.messageId);
} else {
console.error("Error: ", sendResult.errorMessage);
}
}
}
main();
SDK Workflow¶
The general workflow for ACS JavaScript SDKs involves initializing a client and performing operations using that client.
graph TD
Config[Config / Env Vars] --> ClientInit[Initialize Client]
ClientInit --> Operation[Perform Operation]
Operation --> Response[Handle Response / Exceptions] Unique Feature: Browser-based Calling¶
Unlike the Python SDK, the JavaScript SDK provides a specialized library for browser-based voice and video calling, including pre-built UI components.
- Calling UI Library: Add video calling with minimal code.
- Voice & Video Calling: Full control over media streams.
Explore More¶
- Tutorials: Step-by-step guides for common scenarios.
- Recipes: Focused code snippets for specific tasks.