Check out our upcoming events and meetups! View events →
Initiate an outbound AI call with warm-up support. Validates parameters, builds an internal TeXML with an AI Assistant configuration, encodes instructions into client state, and calls the dial API. The Twiml, Texml, and Url parameters are not allowed and will result in a 422 error.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.texml.initiateAICall('connection_id', {
AIAssistantId: 'ai-assistant-id-123',
From: '+13120001234',
To: '+13121230000',
});
console.log(response.call_sid);{
"from": "+13120001234",
"to": "+13121230000",
"status": "queued",
"call_sid": "v3:example-call-sid"
}Documentation Index
Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
Use this file to discover all available pages before exploring further.
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
The ID of the TeXML connection to use for the call.
Initiate AI Call request object
The phone number of the party initiating the call. Phone numbers are formatted with a + and country code.
"+16175551212"
The phone number of the called party. Phone numbers are formatted with a + and country code.
"+16175551212"
The ID of the AI assistant to use for the call.
The version of the AI assistant to use.
Key-value map of dynamic variables to pass to the AI assistant.
Show child attributes
{
"customer_name": "John Doe",
"account_id": "12345"
}To be used as the caller id name (SIP From Display Name) presented to the destination (To number). The string should have a maximum of 128 characters, containing only letters, numbers, spaces, and -_~!.+ special characters. If omitted, the display name will be the same as the number in the From field.
"Info"
URL destination for Telnyx to send status callback events to for the call.
"https://www.example.com/callback"
The call events for which Telnyx should send a webhook. Multiple events can be defined when separated by a space. Valid values: initiated, ringing, answered, completed.
"initiated answered"
HTTP request type used for StatusCallback.
GET, POST "GET"
An array of URL destinations for Telnyx to send status callback events to for the call.
[
"https://www.example.com/callback1",
"https://www.example.com/callback2"
]Custom HTTP headers to be sent with the call. Each header should be an object with 'name' and 'value' properties.
Show child attributes
[
{
"name": "X-Custom-Header",
"value": "custom-value"
}
]URL destination for Telnyx to send conversation callback events to.
"https://www.example.com/conversation-callback"
HTTP request type used for ConversationCallback.
GET, POST "GET"
An array of URL destinations for conversation callback events.
[
"https://www.example.com/conversation-callback1",
"https://www.example.com/conversation-callback2"
]Enables Answering Machine Detection.
Enable, Disable, DetectMessageEnd "Enable"
Allows you to choose between Premium and Standard detections.
Premium, Regular "Premium"
Select whether to perform answering machine detection in the background. By default execution is blocked until Answering Machine Detection is completed.
true
URL destination for Telnyx to send AMD callback events to for the call.
"https://www.example.com/callback"
HTTP request type used for AsyncAmdStatusCallback.
GET, POST "GET"
Maximum timeout threshold in milliseconds for overall detection.
500 <= x <= 600005000
Maximum threshold of a human greeting. If greeting longer than this value, considered machine. Ignored when premium detection is used.
2000
Silence duration threshold after a greeting message or voice for it be considered human. Ignored when premium detection is used.
2000
If initial silence duration is greater than this value, consider it a machine. Ignored when premium detection is used.
2000
A string of passport identifiers to associate with the call.
The maximum duration of the call in seconds. The minimum value is 30 and the maximum value is 14400 (4 hours). Default is 14400 seconds.
30 <= x <= 144003600
The number of seconds to wait for the called party to answer the call before the call is canceled. The minimum value is 5 and the maximum value is 120. Default is 30 seconds.
5 <= x <= 12060
Whether to record the entire participant's call leg. Defaults to false.
false
The number of channels in the final recording. Defaults to mono.
mono, dual "dual"
The URL the recording callbacks will be sent to.
"https://example.com/recording_status_callback"
HTTP request type used for RecordingStatusCallback. Defaults to POST.
GET, POST "GET"
The changes to the recording's state that should generate a call to RecordingStatusCallback. Can be: in-progress, completed and absent. Separate multiple values with a space. Defaults to completed.
"in-progress completed absent"
The number of seconds that Telnyx will wait for the recording to be stopped if silence is detected. The timer only starts when the speech is detected. The minimum value is 0. The default value is 0 (infinite).
5
The audio track to record for the call. The default is both.
inbound, outbound, both "inbound"
Whether to trim any leading and trailing silence from the recording. Defaults to trim-silence.
trim-silence, do-not-trim "trim-silence"
Whether to send RecordingUrl in webhooks.
false
The list of comma-separated codecs to be offered on a call.
"PCMA,PCMU"
The username to use for SIP authentication.
"user"
The password to use for SIP authentication.
"1234"
Defines the SIP region to be used for the call.
US, Europe, Canada, Australia, Middle East "Canada"
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.texml.initiateAICall('connection_id', {
AIAssistantId: 'ai-assistant-id-123',
From: '+13120001234',
To: '+13121230000',
});
console.log(response.call_sid);{
"from": "+13120001234",
"to": "+13121230000",
"status": "queued",
"call_sid": "v3:example-call-sid"
}