Access the Voice API. You can instantiate a Voice.Client to make or receive calls. Please check Voice.VoiceClientApiEvents for the full list of events that a Voice.Client can subscribe to.
Example
The following example answers any call in the "office" context, and immediately plays some speech.
const client = new Voice.Client({
project: "<project-id>",
token: "<api-token>",
contexts: ['office']
})
client.on('call.received', async (call) => {
console.log('Got call', call.from, call.to)
try {
await call.answer()
console.log('Inbound call answered')
await call.playTTS({ text: "Hello! This is a test call."})
} catch (error) {
console.error('Error answering inbound call', error)
}
})
Classes
Interfaces
- Call
- Client
- VoiceCallPlayAudioMethodParams
- VoiceCallPlayRingtoneMethodParams
- VoiceCallPlaySilenceMethodParams
- VoiceCallPlayTTSMethodParams
- VoiceClientApiEvents
Type aliases
Ƭ VoiceCallPlayParams: VoiceCallPlayAudioParams
| VoiceCallPlayTTSParams
| VoiceCallPlaySilenceParams
| VoiceCallPlayRingtoneParams