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");
다음 단계
- 호출 자동화 개요
- 수신 통화 개념
- 통화 자동화 사용하여 고객 상호 작용 워크플로 빌드
- 호출 자동화 사용하여 인바운드 전화 통신 호출 리디렉션
- 빠른 시작: 작업 재생
- 빠른 시작: 작업 인식
- Azure Communication Services 통화 기록에 대해 자세히 알아보세요.
- Event Grid 사용하여 통화 기록 및 다운로드
기여
이 라이브러리에 기여하려면 기여 가이드 읽어 코드를 빌드하고 테스트하는 방법에 대해 자세히 알아보세요.
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
Azure SDK for JavaScript