//native
type Telnyx = {
apiKey: string
}
/**
* Play audio to conference participants
* Play audio to all or some participants on a conference call.
*/
export async function main(
auth: Telnyx,
id: string,
body: {
audio_url?: string
media_name?: string
loop?: string | number
call_control_ids?: string[]
}
) {
const url = new URL(`https://api.telnyx.com/v2/conferences/${id}/actions/play`)
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