@azure/communication-call-automation

中文文档
1.6.0发布于 2026/06/18MITTypeScriptESM + CJS近 30 天下载 19.6万

Azure 通信呼叫自动化服务的 Azure 客户端库

中文使用文档
文档目录13 节
  1. 开始
  2. 先决条件
  3. 安装
  4. 浏览器支持
  5. 关键概念
  6. 实例
  7. 初始化调用自动连接
  8. 创建调用
  9. 播放媒体
  10. 解决问题
  11. 日志
  12. 今后的步骤
  13. 捐款

Azure 通信呼叫 JavaScript 自动化客户端库

这个包包含一个用于Azure Conference Call Automation的JavaScript SDK. Call Automation为开发者提供了构建基于服务器,智能调用工作流程的能力,并为语音和PSTN频道提供调用录音.

呼叫自动化概览 | 产品文档

开始

先决条件

安装

npm install @azure/communication-call-automation

浏览器支持

Java 脚本套装

要在浏览器中使用此客户端库,首先需要使用捆绑器. 关于如何做到这一点的详情,请参见我们 捆绑文件。 。 。 .

关键概念

名称说明
调用自动连接CallAutomationClient 是开发者使用此客户端库的主要界面。 它可以用来启动呼叫 由 createCall 或者说 answerCall。 。 。 .
调用连接CallConnection 代表着不断发出的呼吁。 电话一旦确定 createCall 或者说 answerCall,可以对该呼吁采取进一步行动,例如: transfer 或者说 addParticipant。 。 。 .
调用媒体CallMedia 可用于开展媒体相关行动,例如 play,用于播放媒体文件。 可从已建立 CallConnection。 。 。 .
调用记录CallRecording 可用于记录相关的动作,例如 startRecording。可从 CallAutomationClient。 。 。 .
回调事件召回事件(英語:Callback events)是指在召回期间发回的事件. 它提供了信息和通话状态,例如: CallConnected。 。 。 . CallbackUrl 必须在 createCall 财务报告和审定财务报表 answerCall,然后将召回事件发送给此 URL。 你用得着 callAutomationEventParser 来分析这些事情.
来电事件当来电发生时( 可用 answerCall,将发送来电事件网。 这与上面的Callback事件不同,应该设置在Azure门户网站上. 见 来电 细节.

实例

初始化调用自动连接

import { DefaultAzureCredential } from "@azure/identity";
import { CallAutomationClient } from "@azure/communication-call-automation";

// Your unique Azure Communication service endpoint
const credential = new DefaultAzureCredential();
const endpointUrl = "<ENDPOINT>";
const callAutomationClient = new CallAutomationClient(endpointUrl, credential);

创建调用

import { DefaultAzureCredential } from "@azure/identity";
import { CallAutomationClient } from "@azure/communication-call-automation";

// Your unique Azure Communication service endpoint
const credential = new DefaultAzureCredential();
const endpointUrl = "<ENDPOINT>";
const callAutomationClient = new CallAutomationClient(endpointUrl, credential);

// target endpoint for ACS User
const target = {
  communicationUserId: "8:acs:...",
};

// make invitation
const callInvite = {
  targetParticipant: target,
};

// callback url to receive callback events
const callbackUrl = "https://<MY-EVENT-HANDLER-URL>/events";

// send out the invitation, creating call
const response = await callAutomationClient.createCall(callInvite, callbackUrl);

播放媒体

import { DefaultAzureCredential } from "@azure/identity";
import { CallAutomationClient, FileSource } from "@azure/communication-call-automation";

// Your unique Azure Communication service endpoint
const credential = new DefaultAzureCredential();
const endpointUrl = "<ENDPOINT>";
const callAutomationClient = new CallAutomationClient(endpointUrl, credential);

const target = { communicationUserId: "8:acs:..." };
const callInvite = { targetParticipant: target };
const callbackUrl = "https://<MY-EVENT-HANDLER-URL>/events";

const createCallResult = await callAutomationClient.createCall(callInvite, callbackUrl);
const callConnection = createCallResult.callConnection;
// from callconnection of response above, play media of media file
const myFile: FileSource = { url: "https://<FILE-SOURCE>/<SOME-FILE>.wav", kind: "fileSource" };
const response = await callConnection.getCallMedia().playToAll([myFile]);

解决问题

日志

允许伐木可能有助于发现有关失败的有用信息。 为了查看 HTTP 请求和回复的日志,设置 AZURE_LOG_LEVEL 环境变量改为 info。或者,可以在运行时拨打 setLogLevel 输入 @azure/logger数字 :

import { setLogLevel } from "@azure/logger";

setLogLevel("info");

今后的步骤

捐款

如果您想为图书馆捐钱 请读一下 贡献指南 学习如何构建和测试密码.

版本与发布记录

@azure/communication-call-automation 共发布 373 个版本,首次发布于 2023/03/16;过去 12 个月发布了 55 个版本。

版本发布日期距今
1.6.0latest2026/06/184 个月前
1.5.0-alpha.20260211.1dev2026/02/118 个月前
1.5.0-alpha.20260210.12026/02/108 个月前
1.5.0-alpha.20260209.12026/02/098 个月前
1.5.0-alpha.20260206.12026/02/069 个月前
1.5.0-alpha.20260205.12026/02/059 个月前

其他发布通道:next → 1.5.0-beta.2,beta → 1.6.0-beta.2,dev → 1.5.0-alpha.20260211.1。

关于 @azure/communication-call-automation 的常见问题

@azure/communication-call-automation 是什么?

Azure 通信呼叫自动化服务的 Azure 客户端库

如何安装 @azure/communication-call-automation?

在项目目录运行 npm install @azure/communication-call-automation,或使用 pnpm add / yarn add / bun add。

@azure/communication-call-automation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@azure/communication-call-automation 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@azure/communication-call-automation 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@azure/communication-call-automation 可以商用吗?

@azure/communication-call-automation 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@azure/communication-call-automation 的下载量有多少?

根据 npm 官方下载统计,@azure/communication-call-automation 在 2026/10/08 – 2026/11/06 这 30 天内被下载 195,744 次,日均约 6,525 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@azure/communication-call-automation 还在维护吗?

最新版本 1.6.0 发布于 2026/06/18(4 个月前);至今共发布 373 个版本,其中过去 12 个月发布了 55 个;首次发布于 2023/03/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。