connectPhone

View as Markdown

connectPhone

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

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

Parameters

NameTypeDescription
paramsObject-
params.callStateEventsstring[]An optional array of event names to be notified about. Allowed values are created, ringing, answered, and ended. Default is ended.
params.callStateUrlstringOptional webhook URL to which SignalWire will send call status change notifications. See the payload specifications under CallState.
params.fromstringThe party the call is coming from. Must be a SignalWire number or SIP endpoint that you own.
params.maxPricePerMinute?numberThe maximum price in USD acceptable for the call to be created. If the rate for the call is greater than this value, the call will not be created. If not set, all calls will be created. Price can have a maximum of four decimal places, i.e. 0.0075.
params.ringback?VoicePlaylistRingback audio to play to call leg. You can play audio, TTS, silence or ringtone.
params.timeout?numberThe time, in seconds, the call will ring before it is considered unanswered.
params.tostringThe party you are attempting to call.

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.

Example

1const peer = await call.connectPhone({
2 from: "+xxxxxx",
3 to: "+yyyyyy",
4 timeout: 30,
5});
6
7await call.playTTS({ text: "You are peer 1" });
8await peer.playTTS({ text: "You are peer 2" });
9
10await call.disconnected();
11await call.playTTS({ text: "The peer disconnected" });