//native
type Telnyx = {
apiKey: string
}
/**
* SIPREC start
* Start siprec session to configured in SIPREC connector SRS.
**Expected Webhooks:**
- `siprec.started`
- `siprec.stopped`
- `siprec.failed`
*/
export async function main(
auth: Telnyx,
call_control_id: string,
body: {
connector_name?: string
siprec_track?: 'inbound_track' | 'outbound_track' | 'both_tracks'
include_metadata_custom_headers?: false | true
secure?: false | true
session_timeout_secs?: number
client_state?: string
}
) {
const url = new URL(`https://api.telnyx.com/v2/calls/${call_control_id}/actions/siprec_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