//native
type Telnyx = {
apiKey: string
}
/**
* Bridge calls
* Bridge two call control calls.
**Expected Webhooks (see [callback schema](https://developers.telnyx.com/api/call-control/bridge-call#callbacks) below):**
- `call.bridged` for Leg A
- `call.bridged` for Leg B
*/
export async function main(
auth: Telnyx,
call_control_id: string,
body: {
call_control_id: string
client_state?: string
command_id?: string
queue?: string
video_room_id?: string
video_room_context?: string
park_after_unbridge?: string
play_ringtone?: false | true
ringtone?:
| 'at'
| 'au'
| 'be'
| 'bg'
| 'br'
| 'ch'
| 'cl'
| 'cn'
| 'cz'
| 'de'
| 'dk'
| 'ee'
| 'es'
| 'fi'
| 'fr'
| 'gr'
| 'hu'
| 'il'
| 'in'
| 'it'
| 'jp'
| 'lt'
| 'mx'
| 'my'
| 'nl'
| 'no'
| 'nz'
| 'ph'
| 'pl'
| 'pt'
| 'ru'
| 'se'
| 'sg'
| 'th'
| 'tw'
| 'uk'
| 'us-old'
| 'us'
| 've'
| 'za'
record?: 'record-from-answer'
record_channels?: 'single' | 'dual'
record_format?: 'wav' | 'mp3'
record_max_length?: number
record_timeout_secs?: number
record_track?: 'both' | 'inbound' | 'outbound'
record_trim?: 'trim-silence'
record_custom_file_name?: string
}
) {
const url = new URL(`https://api.telnyx.com/v2/calls/${call_control_id}/actions/bridge`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago