phonic
Version:
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [ • 10.6 kB
text/typescript
import type * as Phonic from "../index.mjs";
export interface CreateAgentRequest {
/** The name of the agent. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
name: string;
/** URL-friendly agent slug. Can only contain lowercase letters, numbers and hyphens. Must be unique within the project. */
slug?: string | undefined;
/** When set to `null`, the agent will not be associated with a phone number. When set to `"assign-automatically"`, the agent will be assigned a random phone number. When set to `"custom"`, you must provide `custom_phone_numbers`. */
phone_number?: (CreateAgentRequest.PhoneNumber | null) | undefined;
/** The custom phone number to use for the agent in E.164 format (e.g., +1234567890). This field is deprecated. Use `custom_phone_numbers` instead. */
custom_phone_number?: (string | null) | undefined;
/** Array of custom phone numbers in E.164 format (e.g., ["+1234567890", "+0987654321"]). The agent will be able to receive phone calls on any of these numbers. Required when `phone_number` is set to `"custom"`. All phone numbers must be unique. */
custom_phone_numbers?: string[] | undefined;
/** The timezone of the agent. Used to format system variables like `{{system_time}}`. */
timezone?: string | undefined;
/** The voice ID to use. */
voice_id?: string | undefined;
/** The audio format of the agent. */
audio_format?: CreateAgentRequest.AudioFormat | undefined;
/** The audio speed of the agent. */
audio_speed?: number | undefined;
/** The background noise level of the agent. */
background_noise_level?: number | undefined;
/** The background noise type. Can be "office", "call-center", "coffee-shop", or null. */
background_noise?: (CreateAgentRequest.BackgroundNoise | null) | undefined;
/** When `true`, the welcome message will be automatically generated and the `welcome_message` field will be ignored. */
generate_welcome_message?: boolean | undefined;
/** When `false`, the welcome message will not be interruptible by the user. */
is_welcome_message_interruptible?: boolean | undefined;
/** Number of seconds of inactivity before the conversation WebSocket is closed. */
websocket_timeout_sec?: number | undefined;
/** Message to play when the conversation starts. Can contain template variables like `{{customer_name}}`. Ignored when `generate_welcome_message` is `true`. */
welcome_message?: (string | null) | undefined;
/** Instructions for the conversation. Can contain template variables like `{{subject}}`. */
system_prompt?: string | undefined;
/** Variables that can be used in the welcome message and the system prompt. */
template_variables?: Record<string, CreateAgentRequest.TemplateVariables.Value> | undefined;
/** Array of built-in or custom tool names to use. */
tools?: CreateAgentRequest.Tools.Item[] | undefined;
/** Array of task objects with `name` and `description` fields. */
tasks?: Phonic.Task[] | undefined;
/** Whether to have the no-input poke text be generated by AI. */
generate_no_input_poke_text?: boolean | undefined;
/** Number of seconds of silence before sending a poke message. `null` disables the poke message. */
no_input_poke_sec?: (number | null) | undefined;
/** The message to send after the specified silence. Ignored when generate_no_input_poke_text is true. */
no_input_poke_text?: string | undefined;
/** Seconds of silence before ending the conversation. */
no_input_end_conversation_sec?: number | undefined;
/** When `true`, the assistant will produce backchannel responses (e.g. "mm-hmm") while the user is speaking. */
enable_assistant_backchannel?: boolean | undefined;
/** How aggressively the assistant produces backchannel responses. Only relevant when `enable_assistant_backchannel` is `true`. */
assistant_backchannel_aggressiveness?: number | undefined;
/** Controls how long transcripts and audio recordings are retained before deletion. */
data_retention_policy?: Phonic.DataRetentionPolicy | undefined;
/** ISO 639-1 language code that sets the agent's default language to recognize and speak. Welcome message and no input poke text should be in this language. */
default_language?: Phonic.LanguageCode | undefined;
/** Array of additional ISO 639-1 language codes that the agent should be able to recognize and speak. Should not include `default_language`. When `multilingual_mode` is `"auto"`, a maximum of 2 additional languages is allowed. */
additional_languages?: Phonic.LanguageCode[] | undefined;
/** Array of ISO 639-1 language codes that the agent should be able to recognize. This field is deprecated. Use `default_language` and `additional_languages` instead. */
languages?: Phonic.LanguageCode[] | undefined;
/** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). If `"initial"` the first turn user audio determines the language for the rest of the conversation. */
multilingual_mode?: CreateAgentRequest.MultilingualMode | undefined;
/** Push to talk mode. User must send mute/unmute messages to turn on/off listening to audio. Defaults to false. */
push_to_talk?: boolean | undefined;
/** The intelligence level of the agent. `high` uses a more capable model for more complex reasoning, while `standard` is optimized for lower latency. */
intelligence_level?: CreateAgentRequest.IntelligenceLevel | undefined;
/** These words, or short phrases, will be more accurately recognized by the agent. */
boosted_keywords?: string[] | undefined;
/** Array of `{ word, pronunciation }` entries. Words must be unique. */
pronunciation_dictionary?: CreateAgentRequest.PronunciationDictionary.Item[] | undefined;
/** Minimum number of words required to interrupt the assistant. */
min_words_to_interrupt?: number | undefined;
/** When not `null`, at the beginning of the conversation the agent will make a POST request to this endpoint to get configuration options. */
configuration_endpoint?: (CreateAgentRequest.ConfigurationEndpoint | null) | undefined;
/** Float between 0.0 and 1.0 representing the percentage of inbound calls handled by Agent. Defaults to `1.0`. Requires `phone_number` to be set when less than 1.0. */
inbound_rollout?: number | undefined;
/** E.164 formatted phone number where non-agent calls will be forwarded. Required when `inbound_rollout < 1.0`, must be `null` when `inbound_rollout = 1.0`. Defaults to `null`. */
inbound_rollout_forward_phone_number?: (string | null) | undefined;
/** Voice activity detection prebuffer duration in milliseconds. */
vad_prebuffer_duration_ms?: number | undefined;
/** Minimum speech duration for voice activity detection in milliseconds. */
vad_min_speech_duration_ms?: number | undefined;
/** Minimum silence duration for voice activity detection in milliseconds. */
vad_min_silence_duration_ms?: number | undefined;
/** Voice activity detection threshold. */
vad_threshold?: number | undefined;
/** When `true`, PII and PHI are redacted from text transcripts (e.g. replaced with tags like `[PHONE NUMBER]`) and bleeped from audio recordings after the conversation ends. */
enable_redaction?: boolean | undefined;
/** Array of MCP server IDs to make available to the agent. */
mcp_server_ids?: string[] | undefined;
/** Names of observability integrations to enable for the agent. Each must be one of the supported providers. */
observability_integrations?: "braintrust"[] | undefined;
}
export declare namespace CreateAgentRequest {
const PhoneNumber: {
readonly AssignAutomatically: "assign-automatically";
readonly Custom: "custom";
};
type PhoneNumber = (typeof PhoneNumber)[keyof typeof PhoneNumber];
/** The audio format of the agent. */
const AudioFormat: {
readonly Pcm44100: "pcm_44100";
readonly Pcm24000: "pcm_24000";
readonly Pcm16000: "pcm_16000";
readonly Pcm8000: "pcm_8000";
readonly Mulaw8000: "mulaw_8000";
};
type AudioFormat = (typeof AudioFormat)[keyof typeof AudioFormat];
/** The background noise type. Can be "office", "call-center", "coffee-shop", or null. */
const BackgroundNoise: {
readonly Office: "office";
readonly CallCenter: "call-center";
readonly CoffeeShop: "coffee-shop";
};
type BackgroundNoise = (typeof BackgroundNoise)[keyof typeof BackgroundNoise];
namespace TemplateVariables {
interface Value {
default_value: string;
is_boosted_keyword?: boolean | undefined;
}
}
type Tools = Tools.Item[];
namespace Tools {
type Item = "keypad_input" | "natural_conversation_ending"
/**
* Custom tool */
| string;
}
/** If `"auto"`, each user audio is automatically identified for the language to respond in. If `"request"`, user must request to change language (recommended). If `"initial"` the first turn user audio determines the language for the rest of the conversation. */
const MultilingualMode: {
readonly Auto: "auto";
readonly Request: "request";
readonly Initial: "initial";
};
type MultilingualMode = (typeof MultilingualMode)[keyof typeof MultilingualMode];
/** The intelligence level of the agent. `high` uses a more capable model for more complex reasoning, while `standard` is optimized for lower latency. */
const IntelligenceLevel: {
readonly Standard: "standard";
readonly High: "high";
};
type IntelligenceLevel = (typeof IntelligenceLevel)[keyof typeof IntelligenceLevel];
type PronunciationDictionary = PronunciationDictionary.Item[];
namespace PronunciationDictionary {
interface Item {
word: string;
pronunciation: string;
}
}
/**
* When not `null`, at the beginning of the conversation the agent will make a POST request to this endpoint to get configuration options.
*/
interface ConfigurationEndpoint {
/** URL to call */
url: string;
/** Object of key-value pairs. */
headers?: Record<string, string> | undefined;
/** Timeout in milliseconds for the endpoint call. */
timeout_ms?: number | undefined;
}
}