次の方法で共有


JavaScript 用 Azure Communication Call Automation クライアント ライブラリ - バージョン 1.4.0

このパッケージには、Azure Communication Call Automation 用の JavaScript SDK が含まれています。 通話オートメーションを使用すると、開発者は、サーバーベースのインテリジェントな通話ワークフローを構築し、音声および PSTN チャネルの通話記録を行うことができます。

Call Automation | 製品ドキュメントの概要

はじめ

前提 条件

装着

npm install @azure/communication-call-automation

ブラウザーのサポート

JavaScript バンドル

ブラウザーでこのクライアント ライブラリを使用するには、まず、バンドルを使用する必要があります。 これを行う方法の詳細については、バンドルドキュメントを参照してください。

主な概念

名前 形容
CallAutomationClient (英語) CallAutomationClient は、このクライアント ライブラリを使用する開発者向けの主要なインターフェイスです。 これは、createCall または answerCallによって呼び出しを開始するために使用できます。
コールコネクション CallConnection は、進行中の呼び出しを表します。 呼び出しが createCall または answerCallで確立されると、transferaddParticipantなど、呼び出しに対してさらにアクションを実行できます。
コールメディア CallMedia を使用して、メディア ファイルを再生するために、playなどのメディア関連のアクションを実行できます。 これは、確立された CallConnectionから取得できます。
通話録音 CallRecording を使用して、startRecordingなどの関連するアクションを記録できます。 これは、CallAutomationClientから取得できます。

CallAutomationClient の初期化

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");

次の手順

貢献

このライブラリに投稿する場合は、コードをビルドしてテストする方法の詳細については、投稿ガイド を参照してください。