//native
type Telnyx = {
apiKey: string
}
/**
* Join a conference
* Join an existing call leg to a conference.
*/
export async function main(
auth: Telnyx,
id: string,
body: {
call_control_id: string
client_state?: string
command_id?: string
end_conference_on_exit?: false | true
soft_end_conference_on_exit?: false | true
hold?: false | true
hold_audio_url?: string
hold_media_name?: string
mute?: false | true
start_conference_on_enter?: false | true
supervisor_role?: 'barge' | 'monitor' | 'none' | 'whisper'
whisper_call_control_ids?: string[]
beep_enabled?: 'always' | 'never' | 'on_enter' | 'on_exit'
}
) {
const url = new URL(`https://api.telnyx.com/v2/conferences/${id}/actions/join`)
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