Types
Helper types.
CollectDigitsConfig
A configuration object to specify how to collect digits.
Example
Collecting digits using call.collect():
const collectObj = await call.collect({
digits: {
max: 4,
digitTimeout: 5,
terminators: "#"
}
});
const { digits, terminator } = await collectObj.ended();
Prompting for digits with TTS using call.promptTTS():
const prompt = await call.promptTTS({
text: "Please enter your 4-digit PIN",
digits: {
max: 4,
digitTimeout: 5,
terminators: "#*"
}
});
const { type, digits, terminator } = await prompt.ended();
CollectSpeechConfig
A configuration object to specify how to collect speech.
Enable enhanced speech recognition at an additional cost. Accepted values are enhanced, enhanced.phone_call, or enhanced.video. The value enhanced will automatically detect whether to optimize with the phone_call or video setting.
Example
Collecting speech using call.collect():
const collectObj = await call.collect({
speech: {
endSilenceTimeout: 2,
speechTimeout: 30,
language: "en-US",
hints: ["yes", "no", "maybe"]
}
});
const { speech, text } = await collectObj.ended();
Prompting for speech with TTS using call.promptTTS():
const prompt = await call.promptTTS({
text: "Please say yes or no",
speech: {
endSilenceTimeout: 1,
speechTimeout: 60,
language: "en-US",
hints: ["yes", "no"]
}
});
const { type, text } = await prompt.ended();
SipCodec
A codec for SIP. Possible values are: "PCMU", "PCMA", "OPUS", "G729", "G722", "VP8", "H264".
Example
Using codecs when dialing a SIP endpoint with Voice.DeviceBuilder.Sip():
import { Voice } from "@signalwire/realtime-api";
const devices = new Voice.DeviceBuilder().add(
Voice.DeviceBuilder.Sip({
from: "sip:user1@domain.com",
to: "sip:user2@domain.com",
codecs: ["OPUS", "PCMU"]
})
);
const call = await client.voice.dial({ devices });
SipHeader
A header for SIP. It is an object with the following properties.
Properties
Example
Using custom headers when dialing a SIP endpoint with Voice.DeviceBuilder.Sip():
import { Voice } from "@signalwire/realtime-api";
const devices = new Voice.DeviceBuilder().add(
Voice.DeviceBuilder.Sip({
from: "sip:user1@domain.com",
to: "sip:user2@domain.com",
headers: [
{ name: "X-Custom-Header", value: "my-value" },
{ name: "X-Account-ID", value: "12345" }
]
})
);
const call = await client.voice.dial({ devices });
RingtoneName
The name of a ringtone, based on country-specific ring patterns.
| Value | Country |
|---|---|
at | Austria |
au | Australia |
be | Belgium |
bg | Bulgaria |
br | Brazil |
ch | Switzerland |
cl | Chile |
cn | China |
cz | Czech Republic |
de | Germany |
dk | Denmark |
ee | Estonia |
es | Spain |
fi | Finland |
fr | France |
gr | Greece |
hu | Hungary |
il | Israel |
in | India |
it | Italy |
jp | Japan |
lt | Lithuania |
mx | Mexico |
my | Malaysia |
nl | Netherlands |
no | Norway |
nz | New Zealand |
ph | Philippines |
pl | Poland |
pt | Portugal |
ru | Russia |
se | Sweden |
sg | Singapore |
th | Thailand |
tw | Taiwan |
uk | United Kingdom |
us | United States |
ve | Venezuela |
za | South Africa |
Example
Playing a ringtone with Voice.Playlist.Ringtone():
import { Voice } from "@signalwire/realtime-api";
const playlist = new Voice.Playlist()
.add(Voice.Playlist.Ringtone({ name: "us", duration: 10 }));
await call.play(playlist);
Prompting with a ringtone using call.promptRingtone():
const prompt = await call.promptRingtone({
name: "it",
duration: 10,
digits: {
max: 1,
digitTimeout: 5
}
});
const { digits } = await prompt.ended();
VoiceCallPhoneParams
A device configuration object for calling a phone number. Returned by Voice.DeviceBuilder.Phone() and passed to DeviceBuilder.add().
Properties
Webhook URL to which SignalWire will send call status change notifications. See CallState.
["ended"]Array of event names to be notified about. Allowed values are created, ringing, answered, and ended.
VoiceCallSipParams
A device configuration object for calling a SIP endpoint. Returned by Voice.DeviceBuilder.Sip() and passed to DeviceBuilder.add().
Properties
Array of desired codecs in order of preference. See SipCodec.
Array of headers. Must be X- headers only. See SipHeader.
Webhook URL to which SignalWire will send call status change notifications. See CallState.
["ended"]Array of event names to be notified about. Allowed values are created, ringing, answered, and ended.
TapDevice
A device to use as a destination for tap.
This can be either an RTP device or a WebSocket device.
Properties
RTP (type = "rtp")
An RTP device has the following properties in addition to the general ones:
Optional codec to use. It will be the same as the tapped audio if not set.
Optional packetization time in milliseconds. It will be the same as the tapped audio if not set.
WebSocket (type = "ws")
A WebSocket device has the following properties in addition to the general ones:
Optional codec to use. It will be the same as the tapped audio if not set.
Example
Tapping audio to a WebSocket endpoint using call.tapAudio():
const tap = await call.tapAudio({
direction: "both",
device: {
type: "ws",
uri: "wss://example.domain.com/endpoint"
}
});
// Stop the tap when done
await tap.stop();
Tapping audio to an RTP endpoint using call.tap():
const tap = await call.tap({
audio: {
direction: "speak"
},
device: {
type: "rtp",
addr: "192.0.2.1",
port: "1234",
codec: "PCMU"
}
});
await tap.stop();