dialSip

View as Markdown

dialSip

  • dialSip(params): Promise<Call>

Makes an outbound call to a SIP endpoint.

Parameters

params
objectRequired

Object containing the parameters for dialing a SIP endpoint.

from
stringRequired

The party the call is coming from. Must be a SignalWire number or SIP endpoint that you own.

to
stringRequired

The party you are attempting to call.

timeout
number

The time, in seconds, the call will ring before it is considered unanswered.

headers
SipHeader[]

Array of SipHeader objects. Must be X- headers only, see example below.

codecs
SipCodec[]

Optional array of desired codecs in order of preference. Supported values are PCMU, PCMA, OPUS, G729, G722, VP8, H264. Default is parent leg codec(s).

webrtcMedia
boolean

If true, WebRTC media is negotiated. Default is parent leg setting.

sessionTimeout
number

Non-negative value, in seconds, to use for the SIP Session-Expires header. If 0 or unset, SignalWire will pick the default (typically 600).

maxPricePerMinute
number

The 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.

listen
object

Object that contains callbacks to listen for events. List of Call events can be found here.

Returns

Promise<Call>

A call object.

Example

1import { SignalWire, Voice } from "@signalwire/realtime-api";
2
3const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })
4
5const voiceClient = client.voice
6
7try {
8 const call = await voiceClient.dialSip({
9 from: "sip:xxx@yyy.zz",
10 to: "sip:ppp@qqq.rr",
11 timeout: 30,
12 headers: [
13 { name: "X-SomeKeyA", value: "SomeValueA" },
14 { name: "X-SomeKeyB", value: "SomeValueB" }
15 ]
16 });
17 console.log("Call answered.", call);
18} catch (e) {
19 console.log("Call not answered.", e);
20}