Edits history of script submission #13432 for ' Play audio to conference participants (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //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