次の方法で共有


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

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

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

はじめ

前提 条件

装着

npm install @azure/communication-call-automation

ブラウザーのサポート

JavaScript バンドル

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

主な概念

名前 形容
CallAutomationClient CallAutomationClient は、このクライアント ライブラリを使用する開発者向けの主要なインターフェイスです。 これは、createCall または answerCallによって呼び出しを開始するために使用できます。
CallConnection CallConnection は、進行中の呼び出しを表します。 呼び出しが createCall または answerCallで確立されると、transferaddParticipantなど、呼び出しに対してさらにアクションを実行できます。
CallMedia CallMedia を使用して、メディア ファイルを再生するために、playなどのメディア関連のアクションを実行できます。 これは、確立された CallConnectionから取得できます。
CallRecording CallRecording を使用して、startRecordingなどの関連するアクションを記録できます。 これは、CallAutomationClientから取得できます。
コールバック イベント コールバック イベントは、呼び出しの実行中に返されるイベントです。 CallConnectedなど、通話の情報と状態を提供します。 CallbackUrl createCall および answerCall中に指定する必要があり、コールバック イベントはこの URL に送信されます。 callAutomationEventParser を使用して、これらのイベントが到着したときにこれらのイベントを解析できます。
着信呼び出しイベント 着信呼び出しが発生すると (answerCallで応答できます)、着信呼び出し eventgrid イベントが送信されます。 これは上記のコールバック イベントとは異なり、Azure portal でセットアップする必要があります。 詳細については、「着信通話 を する」を参照してください。

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

次の手順

貢献

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