다음을 통해 공유


JavaScript용 Azure Communication Call Automation 클라이언트 라이브러리 - 버전 1.3.1

이 패키지에는 Azure Communication Call Automation용 JavaScript SDK가 포함되어 있습니다. 호출 자동화는 개발자에게 서버 기반의 지능형 통화 워크플로를 빌드하고 음성 및 PSTN 채널에 대한 통화 녹음/녹화 기능을 제공합니다.

통화 자동화 | 제품 설명서 개요

시작

필수 구성 요소

  • Azure 구독.
  • 기존 Communication Services 리소스입니다. 리소스를 만들어야 하는 경우 Azure Portal, Azure PowerShell또는 azure CLI사용할 수 있습니다.

설치

npm install @azure/communication-call-automation

브라우저 지원

JavaScript 번들

브라우저에서 이 클라이언트 라이브러리를 사용하려면 먼저 번들러를 사용해야 합니다. 이 작업을 수행하는 방법에 대한 자세한 내용은 번들링 설명서참조하세요.

주요 개념

이름 묘사
CallAutomationClient CallAutomationClient 이 클라이언트 라이브러리를 사용하는 개발자를 위한 기본 인터페이스입니다. createCall 또는 answerCall호출을 시작하는 데 사용할 수 있습니다.
CallConnection CallConnection 진행 중인 호출을 나타냅니다. createCall 또는 answerCall호출이 설정되면 transfer 또는 addParticipant같은 호출에 대한 추가 작업을 수행할 수 있습니다.
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");

다음 단계

기여

이 라이브러리에 기여하려면 기여 가이드 읽어 코드를 빌드하고 테스트하는 방법에 대해 자세히 알아보세요.