@azure/communication-call-automation
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Azure Communication Call Automation client library for JavaScript

This package contains a JavaScript SDK for Azure Communication Call Automation. Call Automation provides developers the ability to build server-based, intelligent call workflows, and call recording for voice and PSTN channels.

Overview of Call Automation | Product documentation

Getting started

Prerequisites

Installing

npm install @azure/communication-call-automation

Browser support

JavaScript Bundle

To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our bundling documentation.

Key concepts

Name Description
CallAutomationClient CallAutomationClient is the primary interface for developers using this client library. It can be used to initiate calls by createCall or answerCall.
CallConnection CallConnection represents a ongoing call. Once the call is established with createCall or answerCall, further actions can be performed for the call, such as transfer or addParticipant.
CallMedia CallMedia can be used to do media related actions, such as play, to play media file. This can be retrieved from established CallConnection.
CallRecording CallRecording can be used to do recording related actions, such as startRecording. This can be retrieved from CallAutomationClient.
Callback Events Callback events are events sent back during duration of the call. It gives information and state of the call, such as CallConnected. CallbackUrl must be provided during createCall and answerCall, and callback events will be sent to this url. You can use callAutomationEventParser to parse these events when it arrives.
Incoming Call Event When incoming call happens (that can be answered with answerCall), incoming call eventgrid event will be sent. This is different from Callback events above, and should be setup on Azure portal. See Incoming Call for detail.

Examples

Initialize CallAutomationClient

import { CallAutomationClient } from '@azure/communication-call-automation';

// Your unique Azure Communication service endpoint
const endpointUrl = '<ENDPOINT>';
const callAutomationClient = new CallAutomationClient(endpointUrl);

Create Call

import { PhoneNumberIdentifier } from "@azure/communication-common";
import { CallAutomationClient, CallInvite } from '@azure/communication-call-automation';

// target number and source number
const target: PhoneNumberIdentifier =
{
    phoneNumber: "+1..."
};
const source: PhoneNumberIdentifier =
{
    phoneNumber: "+1800..."
};

// make an invitation
const callInvite : CallInvite =
{
    targetParticipant: target,
    sourceCallIdNumber: source
}

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

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

Play Media

// from callconnection of response above, play media of filesource
const myFile: FileSource[] = [
    {
        kind: "fileSource",
        uri: "https://<FILE-SOURCE>/<SOME-FILE>.wav"
    }
]
const response = callConnection.getCallMedia().playToAll(myFile);

Troubleshooting

Next steps

Contributing

If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.

Package Sidebar

Install

npm i @azure/communication-call-automation

Weekly Downloads

686

Version

1.1.0

License

MIT

Unpacked Size

1.19 MB

Total Files

64

Last publish

Collaborators

  • microsoft1es
  • azure-sdk