import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: 'My API Key',
});
const response = await client.calls.actions.gatherUsingAI('call_control_id', {
parameters: {
properties: {
age: { description: 'The age of the customer.', type: 'integer' },
location: { description: 'The location of the customer.', type: 'string' },
},
required: ['age', 'location'],
type: 'object',
},
});
console.log(response.data);{
"data": {
"result": "ok",
"conversation_id": "d7e9c1d4-8b2a-4b8f-b3a7-9a671c9e9b0a"
}
}Gather parameters defined in the request payload using a voice assistant.
You can pass parameters described as a JSON Schema object and the voice assistant will attempt to gather these informations.
Expected Webhooks:
call.ai_gather.endedcall.conversation.endedcall.ai_gather.partial_results (if send_partial_results is set to true)call.ai_gather.message_history_updated (if send_message_history_updates is set to true)import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: 'My API Key',
});
const response = await client.calls.actions.gatherUsingAI('call_control_id', {
parameters: {
properties: {
age: { description: 'The age of the customer.', type: 'integer' },
location: { description: 'The location of the customer.', type: 'string' },
},
required: ['age', 'location'],
type: 'object',
},
});
console.log(response.data);{
"data": {
"result": "ok",
"conversation_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
Gather using AI request
The parameters described as a JSON Schema object that needs to be gathered by the voice assistant. See the JSON Schema reference for documentation about the format
{
"properties": {
"age": {
"description": "The age of the customer.",
"type": "integer"
},
"location": {
"description": "The location of the customer.",
"type": "string"
}
},
"required": ["age", "location"],
"type": "object"
}Assistant configuration including choice of LLM, custom instructions, and tools.
Show child attributes
The model to be used by the voice assistant.
"meta-llama/Meta-Llama-3.1-70B-Instruct"
The system instructions that the voice assistant uses during the gather command
"You are a friendly voice assistant."
This is necessary only if the model selected is from OpenAI. You would pass the identifier for an integration secret /v2/integration_secrets that refers to your OpenAI API Key. Warning: Free plans are unlikely to work with this integration.
"my_openai_api_key"
The tools that the voice assistant can use.
Show child attributes
book_appointment Show child attributes
Reference to an integration secret that contains your Cal.com API key. You would pass the identifier for an integration secret /v2/integration_secrets that refers to your Cal.com API key.
"my_calcom_api_key"
The settings associated with speech to text for the voice assistant. This is only relevant if the assistant uses a text-to-text language model. Any assistant using a model with native audio support (e.g. fixie-ai/ultravox-v0_4) will ignore this field.
Show child attributes
The speech to text model to be used by the voice assistant.
distil-whisper/distil-large-v2 is lower latency but English-only.openai/whisper-large-v3-turbo is multi-lingual with automatic language detection but slightly higher latency.google is a multi-lingual option, please describe the language in the language field."distil-whisper/distil-large-v2"
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"
The voice to be used by the voice assistant. Currently we support ElevenLabs, Telnyx and AWS voices.
Supported Providers:
AWS.Polly.<VoiceId> (e.g., AWS.Polly.Joanna). For neural voices, which provide more realistic, human-like speech, append -Neural to the VoiceId (e.g., AWS.Polly.Joanna-Neural). Check the available voices for compatibility.ElevenLabs.<ModelId>.<VoiceId> (e.g., ElevenLabs.BaseModel.John). The ModelId part is optional. To use ElevenLabs, you must provide your ElevenLabs API key as an integration secret under "voice_settings": {"api_key_ref": "<secret_id>"}. See integration secrets documentation for details. Check available voices.Telnyx.<model_id>.<voice_id>"Telnyx.KokoroTTS.af"
The settings associated with the voice selected
Show child attributes
The identifier for an integration secret /v2/integration_secrets that refers to your ElevenLabs API key. Warning: Free plans are unlikely to work with this integration.
"my_elevenlabs_api_key"
Text that will be played when the gathering starts, if none then nothing will be played when the gathering starts. The greeting can be text for any voice or SSML for AWS.Polly.<voice_id> voices. There is a 3,000 character limit.
"Hello, can you tell me your age and where you live?"
Default is false. If set to true, the voice assistant will send partial results via the call.ai_gather.partial_results callback in real time as individual fields are gathered. If set to false, the voice assistant will only send the final result via the call.ai_gather.ended callback.
false
Default is false. If set to true, the voice assistant will send updates to the message history via the call.ai_gather.message_history_updated callback in real time as the message history is updated.
false
The message history you want the voice assistant to be aware of, this can be useful to keep the context of the conversation, or to pass additional information to the voice assistant.
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"
The number of milliseconds to wait for a user response before the voice assistant times out and check if the user is still there.
5000
Successful response upon making a call control command that includes conversation_id.
Was this page helpful?