import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: 'My API Key',
});
const response = await client.calls.actions.answer('call_control_id');
console.log(response.data);{
"data": {
"result": "ok",
"recording_id": "d7e9c1d4-8b2a-4b8f-b3a7-9a671c9e9b0a"
}
}Answer an incoming call. You must issue this command before executing subsequent commands on an incoming call.
Expected Webhooks:
call.answeredstreaming.started, streaming.stopped or streaming.failed if stream_url was setWhen the record parameter is set to record-from-answer, the response will include a recording_id field.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: 'My API Key',
});
const response = await client.calls.actions.answer('call_control_id');
console.log(response.data);{
"data": {
"result": "ok",
"recording_id": "d7e9c1d4-8b2a-4b8f-b3a7-9a671c9e9b0a"
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Unique identifier and token for controlling the call
Answer call request
Use this field to set the Billing Group ID for the call. Must be a valid and existing Billing Group ID.
"f5586561-8ff0-4291-a0ac-84fe544797bd"
Use this field to add state to every subsequent webhook. It must be a valid Base-64 encoded string.
"aGF2ZSBhIG5pY2UgZGF5ID1d"
Use this field to avoid duplicate commands. Telnyx will ignore any command with the same command_id for the same call_control_id.
"891510ac-f3e4-11e8-af5b-de00688a4901"
Custom headers to be added to the SIP INVITE response.
[
{ "name": "head_1", "value": "val_1" },
{ "name": "head_2", "value": "val_2" }
]The list of comma-separated codecs in a preferred order for the forked media to be received.
G722,PCMU,PCMA,G729,OPUS,VP8,H264 "G722,PCMU,PCMA,G729,OPUS,VP8,H264"
SIP headers to be added to the SIP INVITE response. Currently only User-to-User header is supported.
[
{ "name": "User-to-User", "value": "value" }
]Use this field to modify sound effects, for example adjust the pitch.
Show child attributes
Set the pitch directly, value should be > 0, default 1 (lower = lower tone)
0.8
Adjust the pitch in semitones, values should be between -14 and 14, default 0
-10
Adjust the pitch in octaves, values should be between -1 and 1, default 0
-0.5
The track to which the sound modifications will be applied. Accepted values are inbound or outbound
"inbound"
{
"pitch": "0.8",
"semitone": -2,
"octaves": 0.1,
"track": "both"
}The destination WebSocket address where the stream is going to be delivered.
"wss://www.example.com/websocket"
Specifies which track should be streamed.
inbound_track, outbound_track, both_tracks "both_tracks"
Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the call will be used.
PCMU, PCMA, G722, OPUS, AMR-WB, L16, default "PCMA"
Configures method of bidirectional streaming (mp3, rtp).
mp3, rtp "rtp"
Indicates codec for bidirectional streaming RTP payloads. Used only with stream_bidirectional_mode=rtp. Case sensitive.
PCMU, PCMA, G722, OPUS, AMR-WB, L16 "G722"
Specifies which call legs should receive the bidirectional stream audio.
both, self, opposite "both"
Generate silence RTP packets when no transmission available.
true
Use this field to override the URL for which Telnyx will send subsequent webhooks to for this call.
"https://www.example.com/server-b/"
HTTP request type used for webhook_url.
POST, GET "GET"
Enable transcription upon call answer. The default value is false.
true
Show child attributes
Engine to use for speech recognition. Legacy values A - Google, B - Telnyx are supported for backward compatibility.
Google, Telnyx, Deepgram, A, B "Google"
Show child attributes
Engine identifier for Google transcription service
Google Language to use for speech recognition
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 "en"
Whether to send also interim results. If set to false, only final results will be sent.
true
Enables speaker diarization.
true
Defines minimum number of speakers in the conversation.
4
Defines maximum number of speakers in the conversation.
4
Enables profanity_filter.
true
Enables enhanced transcription, this works for models phone_call and video.
true
The model to use for transcription.
latest_long, latest_short, command_and_search, phone_call, video, default, medical_conversation, medical_dictation Hints to improve transcription accuracy.
[]Speech context to improve transcription accuracy.
Use this field to add state to every subsequent webhook. It must be a valid Base-64 encoded string.
"aGF2ZSBhIG5pY2UgZGF5ID1d"
Indicates which leg of the call will be transcribed. Use inbound for the leg that requested the transcription, outbound for the other leg, and both for both legs of the call. Will default to inbound.
"both"
Use this field to avoid duplicate commands. Telnyx will ignore any command with the same command_id for the same call_control_id.
"891510ac-f3e4-11e8-af5b-de00688a4901"
{
"language": "en",
"client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
"command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}Start recording automatically after an event. Disabled by default.
record-from-answer "record-from-answer"
Defines which channel should be recorded ('single' or 'dual') when record is specified.
single, dual "single"
Defines the format of the recording ('wav' or 'mp3') when record is specified.
wav, mp3 "wav"
Defines the maximum length for the recording in seconds when record is specified. The minimum value is 0. The maximum value is 43200. The default value is 0 (infinite).
1000
The number of seconds that Telnyx will wait for the recording to be stopped if silence is detected when record is specified. The timer only starts when the speech is detected. Please note that call transcription is used to detect silence and the related charge will be applied. The minimum value is 0. The default value is 0 (infinite).
100
The audio track to be recorded. Can be either both, inbound or outbound. If only single track is specified (inbound, outbound), channels configuration is ignored and it will be recorded as mono (single channel).
both, inbound, outbound "outbound"
When set to trim-silence, silence will be removed from the beginning and end of the recording.
trim-silence "trim-silence"
The custom recording file name to be used instead of the default call_leg_id. Telnyx will still add a Unix timestamp suffix.
1 - 40"my_recording_file_name"
Successful response upon making a call control command that includes recording_id.
{
"result": "ok",
"recording_id": "d7e9c1d4-8b2a-4b8f-b3a7-9a671c9e9b0a"
}Was this page helpful?