Edits history of script submission #13440 for ' Recording start (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Recording start
     * Start recording the call. Recording will stop on call hang-up, or can be initiated via the Stop Recording command.
    
    **Expected Webhooks (see [callback schema](https://developers.telnyx.com/api/call-control/start-call-record#callbacks) below):**
    
    - `call.recording.saved`
    
     */
    export async function main(
    	auth: Telnyx,
    	call_control_id: string,
    	body: {
    		format: 'wav' | 'mp3'
    		channels: 'single' | 'dual'
    		client_state?: string
    		command_id?: string
    		play_beep?: false | true
    		max_length?: number
    		timeout_secs?: number
    		recording_track?: 'both' | 'inbound' | 'outbound'
    		trim?: 'trim-silence'
    		custom_file_name?: string
    		transcription?: false | true
    		transcription_engine?: 'A' | 'B'
    		transcription_language?:
    			| 'af'
    			| 'sq'
    			| 'am'
    			| 'ar'
    			| 'hy'
    			| 'az'
    			| 'eu'
    			| 'bn'
    			| 'bs'
    			| 'bg'
    			| 'my'
    			| 'ca'
    			| 'yue'
    			| 'zh'
    			| 'hr'
    			| 'cs'
    			| 'da'
    			| 'nl'
    			| 'en'
    			| 'et'
    			| 'fil'
    			| 'fi'
    			| 'fr'
    			| 'gl'
    			| 'ka'
    			| 'de'
    			| 'el'
    			| 'gu'
    			| 'iw'
    			| 'hi'
    			| 'hu'
    			| 'is'
    			| 'id'
    			| 'it'
    			| 'ja'
    			| 'jv'
    			| 'kn'
    			| 'kk'
    			| 'km'
    			| 'ko'
    			| 'lo'
    			| 'lv'
    			| 'lt'
    			| 'mk'
    			| 'ms'
    			| 'ml'
    			| 'mr'
    			| 'mn'
    			| 'ne'
    			| 'no'
    			| 'fa'
    			| 'pl'
    			| 'pt'
    			| 'pa'
    			| 'ro'
    			| 'ru'
    			| 'rw'
    			| 'sr'
    			| 'si'
    			| 'sk'
    			| 'sl'
    			| 'ss'
    			| 'st'
    			| 'es'
    			| 'su'
    			| 'sw'
    			| 'sv'
    			| 'ta'
    			| 'te'
    			| 'th'
    			| 'tn'
    			| 'tr'
    			| 'ts'
    			| 'uk'
    			| 'ur'
    			| 'uz'
    			| 've'
    			| 'vi'
    			| 'xh'
    			| 'zu'
    			| 'he'
    			| 'la'
    			| 'mi'
    			| 'cy'
    			| 'br'
    			| 'sn'
    			| 'yo'
    			| 'so'
    			| 'oc'
    			| 'be'
    			| 'tg'
    			| 'sd'
    			| 'yi'
    			| 'fo'
    			| 'ht'
    			| 'ps'
    			| 'tk'
    			| 'nn'
    			| 'mt'
    			| 'sa'
    			| 'lb'
    			| 'bo'
    			| 'tl'
    			| 'mg'
    			| 'as'
    			| 'tt'
    			| 'haw'
    			| 'ln'
    			| 'ha'
    			| 'ba'
    			| 'jw'
    			| 'auto_detect'
    		transcription_profanity_filter?: false | true
    		transcription_speaker_diarization?: false | true
    		transcription_min_speaker_count?: number
    		transcription_max_speaker_count?: number
    	}
    ) {
    	const url = new URL(`https://api.telnyx.com/v2/calls/${call_control_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