connect

View as Markdown

connect

  • connect(params): Promise<Call> - See Call for more details.

Attempt to connect an existing call to a new outbound call. The two devices will hear each other. You can wait until the new peer is disconnected by calling disconnected.

This is a generic method that allows you to connect to multiple devices in series, parallel, or combinations of both with the use of a DeviceBuilder. For simpler use cases, prefer using connectPhone or connectSip.

Parameters

NameTypeDescription
paramsVoiceDeviceBuilder | { devices: VoiceDeviceBuilder ; ringback?: VoicePlaylist }Pass only the Dialer specifying the devices to call or an object with the Dialer and Ringback audio to play to call leg. You can play audio, TTS, silence or ringtone. See VoicePlaylist for more details.

Returns

Promise<Call> - See Call for more details.

A promise that resolves to a Call object that you can use to control the new peer. The promise resolves only after the new peer picks up the call.

Examples

Connecting to a new SIP call.

1const plan = new Voice.DeviceBuilder().add(
2 Voice.DeviceBuilder.Sip({
3 from: "sip:user1@domain.com",
4 to: "sip:user2@domain.com",
5 timeout: 30,
6 })
7);
8
9const peer = await call.connect(plan);
10
11await call.playTTS({ text: "You are peer 1" });
12await peer.playTTS({ text: "You are peer 2" });
13
14await call.disconnected();
15await call.playTTS({ text: "The peer disconnected" });

Connecting to a new SIP call, while playing ringback audio.

1const plan = new Voice.DeviceBuilder().add(
2 Voice.DeviceBuilder.Sip({
3 from: "sip:user1@domain.com",
4 to: "sip:user2@domain.com",
5 timeout: 30,
6 })
7);
8
9const ringback = new Voice.Playlist().add(
10 Voice.Playlist.Ringtone({
11 name: "it",
12 })
13);
14const peer = await call.connect({
15 devices: plan,
16 ringback: ringback,
17});