//native
type Telnyx = {
apiKey: string
}
/**
* Dial a new conference participant
* Dials a new conference participant
*/
export async function main(
auth: Telnyx,
account_sid: string,
conference_sid: string,
body: {
Beep?: 'true' | 'false' | 'onEnter' | 'onExit'
StatusCallback?: string
StatusCallbackMethod?: 'GET' | 'POST'
StatusCallbackEvent?: string
To?: string
From?: string
Timeout?: number
Muted?: false | true
StartConferenceOnEnter?: false | true
EndConferenceOnExit?: false | true
EarlyMedia?: false | true
ConferenceStatusCallback?: string
ConferenceStatusCallbackMethod?: 'GET' | 'POST'
ConferenceStatusCallbackEvent?: string
WaitUrl?: string
MaxParticipants?: number
Coaching?: false | true
CallSidToCoach?: string
CallerId?: string
TimeLimit?: number
MachineDetection?: 'Enable' | 'DetectMessageEnd'
MachineDetectionTimeout?: number
MachineDetectionSpeechThreshold?: number
MachineDetectionSpeechEndThreshold?: number
MachineDetectionSilenceTimeout?: number
AmdStatusCallback?: string
AmdStatusCallbackMethod?: 'GET' | 'POST'
CancelPlaybackOnMachineDetection?: false | true
CancelPlaybackOnDetectMessageEnd?: false | true
PreferredCodecs?: string
Record?: false | true
RecordingChannels?: 'mono' | 'dual'
RecordingStatusCallback?: string
RecordingStatusCallbackMethod?: 'GET' | 'POST'
RecordingStatusCallbackEvent?: string
RecordingTrack?: 'inbound' | 'outbound' | 'both'
SipAuthPassword?: string
SipAuthUsername?: string
Trim?: 'trim-silence' | 'do-not-trim'
ConferenceRecord?: 'true' | 'false' | 'record-from-start' | 'do-not-record'
ConferenceRecordingStatusCallback?: string
ConferenceRecordingStatusCallbackMethod?: 'GET' | 'POST'
ConferenceRecordingStatusCallbackEvent?: string
ConferenceRecordingTimeout?: number
ConferenceTrim?: 'trim-silence' | 'do-not-trim'
}
) {
const url = new URL(
`https://api.telnyx.com/v2/texml/Accounts/${account_sid}/Conferences/${conference_sid}/Participants`
)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: 'Bearer ' + auth.apiKey
},
body: new URLSearchParams(body as Record<string, string>)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago