Edits history of script submission #13018 for ' Conference recording start (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Conference recording start
     * Start recording the conference. Recording will stop on conference end, or via the Stop Recording command.
    
    **Expected Webhooks (see [callback schema](https://developers.telnyx.com/api/call-control/start-conference-recording#callbacks) below):**
    
    - `conference.recording.saved`
     */
    export async function main(
    	auth: Telnyx,
    	id: string,
    	body: {
    		format: 'wav' | 'mp3'
    		command_id?: string
    		play_beep?: false | true
    		trim?: 'trim-silence'
    		custom_file_name?: string
    	}
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/conferences/${id}/actions/record_start`)
    
    	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