UNPKG

phonic

Version:

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [![npm shield](htt

161 lines (160 loc) 9.17 kB
import type * as Phonic from "../index.mjs"; export interface Agent { /** The ID of the agent. */ id: string; /** The name of the agent. */ name: string; /** The phone number that the agent uses to accept calls. `null` if the agent is not associated with a phone number, in which can the agent can be used via WebSockets. This field is deprecated. Use `phone_numbers` instead. */ phone_number: string | null; /** Array of phone numbers that the agent uses to accept phone calls. */ phone_numbers: string[]; /** The project the agent belongs to. */ project: Agent.Project; /** The timezone of the agent. Used to format system variables like `{{system_time}}`. */ timezone: string; /** The voice ID of the agent. */ voice_id: string; /** The audio format of the agent. If the agent has a phone number, the audio format will be `mulaw_8000`. */ audio_format: Agent.AudioFormat; /** The audio speed of the agent. Must be a multiple of 0.1. */ audio_speed: number; /** The background noise level of the agent. Must be between 0 and 1. */ background_noise_level: number; /** The background noise type. Can be "office", "call-center", "coffee-shop", or null. */ background_noise: Agent.BackgroundNoise | null; /** When `true`, the welcome message will be automatically generated and the `welcome_message` field will be ignored. */ generate_welcome_message: boolean; /** When `false`, the welcome message will not be interruptible by the user. */ is_welcome_message_interruptible: boolean; /** Number of seconds of inactivity before the conversation WebSocket is closed. */ websocket_timeout_sec?: number | undefined; /** Message to play when the conversation starts. Ignored when `generate_welcome_message` is `true`. */ welcome_message: string | null; /** Instructions for the conversation. */ system_prompt: string; /** Template variables that the agent can use in the welcome message and the system prompt. */ template_variables: Record<string, Agent.TemplateVariables.Value>; /** List of tools available to the agent. */ tools: Agent.Tools.Item[]; /** Tasks for the agent to complete during the conversation. */ tasks: Phonic.Task[]; /** Whether to have the no-input poke text be generated by AI. */ generate_no_input_poke_text: boolean; /** Number of seconds of silence before sending a poke message. `null` disables the poke message. */ no_input_poke_sec: number | null; /** The message to send after the specified silence. Ignored when generate_no_input_poke_text is true. */ no_input_poke_text: string; /** Seconds of silence before ending the conversation. */ no_input_end_conversation_sec: number; /** 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; /** 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[]; /** 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: Agent.MultilingualMode; /** Push to talk mode. User must send mute/unmute messages to turn on/off listening to audio. Defaults to false. */ push_to_talk: boolean; /** 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: Agent.IntelligenceLevel; /** These words, or short phrases, will be more accurately recognized by the agent. */ boosted_keywords: string[]; /** Names of observability integrations enabled for the agent. Each must be one of the supported providers. */ observability_integrations?: "braintrust"[] | undefined; /** Array of `{ word, pronunciation }` entries. Words must be unique. */ pronunciation_dictionary: Agent.PronunciationDictionary.Item[]; /** Minimum number of words required to interrupt the assistant. */ min_words_to_interrupt: number; /** When not `null`, the agent will call this endpoint to get configuration options. */ configuration_endpoint: Agent.ConfigurationEndpoint | null; /** Float between 0.0 and 1.0 representing the percentage of inbound calls handled by Agent. 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`. */ 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; /** The URL-friendly slug of the agent. */ slug?: string | undefined; /** When `true`, the assistant emits backchannel cues (e.g. "mm-hmm") while the user is speaking. */ enable_assistant_backchannel?: boolean | undefined; /** How aggressively the assistant backchannels, from 0 to 1. */ assistant_backchannel_aggressiveness?: number | undefined; /** Third-party integrations enabled for the agent. */ integrations?: Phonic.AgentIntegration[] | undefined; data_retention_policy?: Phonic.DataRetentionPolicy | undefined; } export declare namespace Agent { /** * The project the agent belongs to. */ interface Project { id: string; name: string; } /** The audio format of the agent. If the agent has a phone number, the audio format will be `mulaw_8000`. */ 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 | null; } } 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`, the agent will call this endpoint to get configuration options. */ interface ConfigurationEndpoint { url: string; headers: Record<string, string>; /** The timeout for the configuration endpoint in milliseconds. */ timeout_ms: number; } }