UNPKG

@voximplant/voxengine-ci

Version:

Manage Voximplant Platform `applications`, `rules` and `scenarios` from your own environment

1,637 lines (1,532 loc) 817 kB
/** * [ACDRequest] parameters. Can be passed as arguments to the [VoxEngine.enqueueACDRequest] method. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.ACD); * ``` */ declare interface ACDEnqueueParameters { /** * Priority (1-100, 1 is the highest priority). * If two or more objects have the same priorities, they are handled according to the order of HTTP requests from JS scenario to the ACD queue. */ priority: number; /** * Optional. Extra headers to be passed with the call to the agent. * Custom header names have to begin with the 'X-' prefix except the 'VI-CallTimeout': '60' which switches to another agent if current one does not answer after the timeout (in seconds, the default value is **60**, must not be less than **10** or greater than **400**). * The "X-" headers could be handled by a SIP phone or WEB SDK (e.g. see the [incomingCall](/docs/references/websdk/voximplant/events#incomingcall) event). Example: {'X-header':'value'} */ headers?: { [header: string]: string }; /** * Whether the call has video support. Please note that prices for audio only and video calls are different. */ video: boolean; /** * Custom data for the current call object. */ customData: string; } /** * Add the following line to your scenario code to use the events: * ``` * require(Modules.ACD); * ``` * @event */ declare enum ACDEvents { /** * Triggered when an agent is reached. * @typedef _ACDReachedEvent */ OperatorReached = 'ACD.OperatorReached', /** * Triggered when an ACD makes a call to a user via the [callUser] method. * @typedef _ACDCallAttempt */ OperatorCallAttempt = 'ACD.OperatorCallAttempt', /** * Triggered when an ACD request tries to reach an agent, but the agent declines the call. IMPORTANT NOTE: This is just a notification, the request processing does not stop. The ACD request automatically redirects to the next free agent. * @typedef _ACDFailedEvent */ OperatorFailed = 'ACD.OperatorFailed', /** * Triggers if the ACD service returns an internal error. The JS scenarios are not able to cause internal errors because these errors depend on internal and network issues. * @typedef _ACDErrorEvent */ Error = 'ACD.Error', /** * Triggers as a result of the [ACDRequest.getStatus] method call. * @typedef _ACDWaitingEvent */ Waiting = 'ACD.Waiting', /** * Triggered when an [ACDRequest] is put to the queue. * @typedef _ACDQueuedEvent */ Queued = 'ACD.Queued', /** * Triggers if all agents that can handle a request in the specified queue are offline. In this case, the request is not queued. * @typedef _ACDOfflineEvent */ Offline = 'ACD.Offline', /** * Triggered when we have one more request to put in the queue but the maximum number of requests (max_queue_size) is already reached. In this case, the new request is not queued. The max_queue_size and max_waiting_time default values are “unlimited”, you can change these values for every new or existing queue in the [control panel](https://manage.voximplant.com/applications). * @typedef _ACDQueueFullEvent */ QueueFull = 'ACD.QueueFull', } /** * @private */ declare interface _ACDEvents { [ACDEvents.OperatorReached]: _ACDReachedEvent; [ACDEvents.OperatorCallAttempt]: _ACDCallAttempt; [ACDEvents.OperatorFailed]: _ACDFailedEvent; [ACDEvents.Error]: _ACDErrorEvent; [ACDEvents.Waiting]: _ACDWaitingEvent; [ACDEvents.Queued]: _ACDQueuedEvent; [ACDEvents.Offline]: _ACDOfflineEvent; [ACDEvents.QueueFull]: _ACDQueueFullEvent; } /** * @private */ declare interface _ACDBaseEvent { /** * Request that generated the event */ request: ACDRequest; } /** * @private */ declare interface _ACDReachedEvent extends _ACDBaseEvent { /** * Established call with agent */ operatorCall: Call; } /** * @private */ declare interface _ACDCallAttempt extends _ACDBaseEvent { /** * Agent's call */ operatorCall: Call; } /** * @private */ declare interface _ACDFailedEvent extends _ACDBaseEvent { /** * Username of failed agent */ operatorUserName: string; /** * Call status code */ statusCode: number; } /** * @private */ declare interface _ACDErrorEvent extends _ACDBaseEvent { /** * Error message */ error: string; } /** * @private */ declare interface _ACDWaitingEvent extends _ACDBaseEvent { /** * Estimated waiting time in minutes (value of 0 is also possible) */ ewt: number; /** * Position of the request in the queue */ position: number; } /** * @private */ declare interface _ACDQueuedEvent extends _ACDBaseEvent {} /** * @private */ declare interface _ACDOfflineEvent extends _ACDBaseEvent {} /** * @private */ declare interface _ACDQueueFullEvent extends _ACDBaseEvent {} /** * Represents a request that is put to the ACD queue. * <br> * Add the following line to your scenario code to use the class: * ``` * require(Modules.ACD); * ``` */ declare class ACDRequest { /** * Returns the request's id. It can be used as the <b>acd\_request\_id</b> parameter in the [GetACDHistory](/docs/references/httpapi/managing_history#getacdhistory) method to search in ACD history. */ id(): string; /** * Gets status of the current request. Not to be called before the request is successfully queued (the [ACDEvents.Queued] event). This method's call triggers the [ACDEvents.Waiting] event; it is possible to retrieve an estimated waiting time in minutes via the <b>ewt</b> property of the event. */ getStatus(): void; /** * Adds a handler for the specified [ACDEvents] event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called. * @param event Event class (i.e., [ACDEvents.Offline]) * @param callback Handler function. A single parameter is passed - object with event information */ addEventListener<T extends keyof _ACDEvents>( event: ACDEvents | T, callback: (event: _ACDEvents[T]) => any, ): void; /** * Removes a handler for the specified [ACDEvents] event. * @param event Event class (i.e., [ACDEvents.Offline]) * @param callback Optional. Handler function. If not specified, all handler functions are removed */ removeEventListener<T extends keyof _ACDEvents>( event: ACDEvents | T, callback?: (event: _ACDEvents[T]) => any, ): void; /** * Cancel pending request and remove it from the queue */ cancel(): void; } /** * The AI module provides additional methods that use Artificial Intelligence. These methods allow solving business tasks in a more productive way. * <br> * Add the following line to your scenario code to use the namespace: * ``` * require(Modules.AI); * ``` */ declare namespace AI {} declare namespace AI { /** * Creates a new [AI.Dialogflow] instance which provides resources for exchanging data with the Dialogflow API, handling events, etc. You can attach media streams later via the [AI.DialogflowInstance.sendMediaTo] or [VoxEngine.sendMediaBetween] methods. * <br> * Add the following line to your scenario code to use the function: * ``` * require(Modules.AI); * ``` * @param parameters Dialogflow parameters */ function createDialogflow(parameters: DialogflowSettings): DialogflowInstance; } declare namespace AI { /** * Represents a parameters of the voicemail recognition session. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` * @deprecated Use [AMD] instead **/ interface DetectVoicemailParameters { /** * Optional. Recognition model. The possible values are **ru**, **colombia**. The default value is **ru**. */ model?: string; /** * Optional. Detection threshold in the **0.0 - 1.0 milliseconds** range. Durations shorter than this value are considered human speech, and durations longer than this value are considered voicemail. The default value is **0.8**. Available only with the **latam** model. */ threshold?: number; } } declare namespace AI { /** * Start a voicemail recognition session. You can check how many times voicemail was detected in the call history. * <br> * Add the following line to your scenario code to use the function: * ``` * require(Modules.AI); * ``` * @param call * @param parameters * @deprecated Use [AMD] instead */ function detectVoicemail( call: Call, parameters: DetectVoicemailParameters ): Promise<AI.Events>; } declare namespace AI { /** * Dialogflow events allow matching intents by event name instead of the natural language input. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` */ interface DialogflowEventInput { /** * The unique identifier of the event. */ name: string; /** * The collection of parameters associated with the event */ parameters: { [key: string]: any }; /** * The language ot this conversation query */ languageCode: DialogflowLanguage; } } declare namespace AI { /** * Represents a Dialogflow instance. * <br> * Add the following line to your scenario code to use the class: * ``` * require(Modules.AI); * ``` */ class DialogflowInstance { /** * @param id * @param parameters Dialogflow parameters */ constructor(id: string, parameters: Object); /** * Returns the dialogflow instance's id. */ id(): string; /** * Set parameters for the intents. * @param queryParameters Query parameters */ setQueryParameters(queryParameters: DialogflowQueryParameters): void; /** * Set a collection of phrase hints for the intents. * @param phraseHints The collection of phrase hints to boost the speech recognition accuracy */ setPhraseHints(phraseHints: { [id: string]: string }): void; /** * Update the audio output configuration. * @param outputAudioConfig Config of the audio output */ setOutputAudioConfig(outputAudioConfig: DialogflowOutputAudioConfig): void; /** * Stop and destroy the current Dialogflow instance. */ stop(): void; /** * Send a query to the DialogFlow instance. You can send either a text string up to **256 characters** or an event object with the event name and additional data. * @param dialogflowQuery Text string (up to **256 characters**) or an event object */ sendQuery(dialogflowQuery: DialogflowQueryInput): void; /** * Add a Dialogflow speech synthesis playback marker. The [AI.Events.DialogflowPlaybackMarkerReached](/docs/references/voxengine/ai/events#dialogflowplaybackmarkerreached) event is triggered when the marker is reached. * @param offset Positive/negative offset in milliseconds from the start/end of media */ addMarker(offset: number): void; /** * Starts sending media (voice) from a Dialogflow participant to the media unit. * @param mediaUnit Media unit that receives media * @param parameters Optional. WebSocket interaction only parameters */ sendMediaTo(mediaUnit: VoxMediaUnit, parameters?: SendMediaParameters): void; /** * Stops sending media (voice) from a Dialogflow participant to the media unit. */ stopMediaTo(mediaUnit: VoxMediaUnit): void; /** * Adds a handler for the specified [AI.Events]. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called. * @param event Event class (i.e., [AI.Events.DialogflowResponse]) * @param callback Handler function. A single parameter is passed: object with event information */ addEventListener<T extends keyof AI._Events>( event: AI.Events | T, callback: (event: AI._Events[T]) => any, ): void; /** * Removes a handler for the specified [AI.Events] event. * @param event Event class (i.e., [AI.Events.DialogflowResponse]) * @param callback Optional. Handler function. If not specified, all handler functions are removed */ removeEventListener<T extends keyof AI._Events>( event: AI.Events | T, callback?: (event: AI._Events[T]) => any, ): void; } } declare namespace AI { /** * Instructs the speech synthesizer on how to generate the output audio content. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` */ interface DialogflowOutputAudioConfig { /** * Optional. Configuration of how speech should be synthesized. */ synthesizeSpeechConfig?: DialogflowSynthesizeSpeechConfig; } } declare namespace AI { /** * Represents a Dialogflow query input. It can contain either: * 1. A conversational query in the form of text * 2. An event that specifies which intent to trigger * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` */ interface DialogflowQueryInput { /** * The natural language text to be processed. */ text: DialogflowTextInput; /** * The event to be processed. */ event: DialogflowEventInput; } } declare namespace AI { /** * Represents a parameters of the conversational query. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` **/ interface DialogflowQueryParameters { /** * Optional. The time zone of the conversational query from the time zone database, e.g., America/New_York, Europe/Paris. If not provided, the system uses the time zone specified in agent settings. */ timeZone?: string; /** * Optional. The geolocation of the conversational query. */ geoLocation?: { [key: string]: any }; /** * Optional. The collection of contexts to be activated before the query execution. */ contexts?: any[]; /** * Optional. Whether to delete all contexts in the current session before activation of a new one. */ resetContexts?: boolean; /** * Optional. The collection of session entity types to replace or extend developer entities with for this query only. The entity synonyms apply to all languages. */ sessionEntityTypes?: any[]; /** * Optional. Use this field to pass custom data into the webhook associated with the agent. Arbitrary JSON objects are supported. */ payload?: { [key: string]: any }; } } declare namespace AI { /** * Represents a Dialogflow intent response. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` */ interface DialogflowResponse { /** * The unique identifier of the response. Use it to locate a response in the training example set or for reporting issues. */ responseId: string; /** * Optional. The result of the conversational query or event processing. */ queryResult?: DialogflowResult; /** * Optional. The result of speech recognition. */ recognitionResult?: DialogflowStreamingRecognitionResult; /** * Status of the webhook request. */ webhookStatus: { [id: string]: any }; } } declare namespace AI { /** * Represents a result of an intent response. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` **/ interface DialogflowResult { /** * The original conversational query text: - If natural language text was provided as input, query_text contains a copy of the input. - If natural language speech audio was provided as input, query_text contains the speech recognition result. If speech recognizer produced multiple alternatives, a particular one is picked. - If an event was provided as input, query_text is not set. */ queryText: string; /** * The action name from the matched intent. */ action: string; /** * The collection of extracted parameters. */ parameters: { [id: string]: any }; /** * Whether all the required parameters are present. This field is set to: - false if the matched intent has required parameters and not all the required parameter values have been collected. - true if all required parameter values have been collected, or if the matched intent does not contain any required parameters. */ allRequiredParamsPresent: boolean; /** * This field is set to: - false if the matched intent has required parameters and not all the required parameter values have been collected. - true if all required parameter values have been collected, or if the matched intent does not contain any required parameters. * @deprecated */ fulfillmentText: string; /** * The collection of rich messages to present to the user. */ fulfillmentMessages: any[]; /** * The intent that matched the conversational query. Some, not all fields are filled in this message, including but not limited to: name, display_name and webhook_state. */ intent: { [id: string]: any }; /** * The intent detection confidence. Values range from 0.0 (completely uncertain) to 1.0 (completely certain). */ intentDetectionConfidence: number; /** * The free-form diagnostic info. For example, this field could contain webhook call latency. */ diagnosticInfo: { [id: string]: any }; /** * The language that was triggered during intent detection. See [Language support](https://cloud.google.com/dialogflow/docs/reference/language) for a list of the currently supported language codes. */ languageCode: string; } } declare namespace AI { /** * Settings for setting up a new Dialogflow instance * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` **/ interface DialogflowSettings { /** * Language for the Dialogflow instance. */ lang: DialogflowLanguage; /** * Optional. The collection of phrase hints to boost accuracy of speech recognition. */ phraseHints?: any[]; /** * Initial query parameters. */ queryParameters: DialogflowQueryParameters; /** * Whether to enable single utterance. */ singleUtterance: boolean; /** * Instructs the speech synthesizer how to generate the output audio content. */ outputAudioConfig: DialogflowOutputAudioConfig; /** * Optional. Dialogflow session id. Use it for connection to the existing Dialogflow session or to specify your own id for a new session. */ sessionId?: string; /** * Optional. ID of the Dialogflow agent certificate to use. It can be any of the certificates previously added in the [control panel](https://manage.voximplant.com/applications), see the Dialogflow Connector section in your Voximplant application. You do not need to specify agentId if you have only one Dialogflow agent certificate in your Voximplant application. */ agentId?: number; /** * Optional. Part of the Dialogflow [session](https://cloud.google.com/dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2beta1#google.cloud.dialogflow.v2beta1.StreamingDetectIntentRequest) name. If Environment ID is not specified, we assume default ‘draft’ environment. */ environmentId?: string; /** * Optional. Part of the Dialogflow [session](https://cloud.google.com/dialogflow/docs/reference/rpc/google.cloud.dialogflow.v2beta1#google.cloud.dialogflow.v2beta1.StreamingDetectIntentRequest) name. If User ID is not specified, we use “-”. */ userId?: string; /** * Optional. Whether to use beta. The Voximplant Dialogflow Connector uses Dialogflow v2 Beta by default. Set false to use the non-Beta version of Dialogflow v2. */ beta?: boolean; /** * Optional. The agent’s location. */ region?: string; /** * Optional. Machine learning model to transcribe your audio file. */ model?: DialogflowModel; /** * Optional. Variant of the specified Speech model to use. */ modelVariant?: DialogflowModelVariant; } } declare namespace AI { /** * Contains a speech recognition result, corresponding to a portion of the audio that is currently being processed; or an indication that this is the end of the single requested utterance. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` */ interface DialogflowStreamingRecognitionResult { /** * Type of the result message. */ messageType: string; /** * Optional. Transcript text representing the words that the user spoke. */ transcript: string; /** * The default of **0.0** is a sentinel value indicating confidence was not set. If **false**, the *StreamingRecognitionResult* represents an interim result that may change. If **true**, the recognizer does not return any further hypotheses about this piece of the audio. */ isFinal: boolean; /** * The Speech confidence between **0.0** and **1.0** for the current portion of audio. The default of **0.0** is a sentinel value indicating that confidence was not set. Note that the field is typically only provided if **is_final: true**, and you should not rely on it being accurate or even set. */ confidence: number; } } declare namespace AI { /** * Configuration of how speech should be synthesized. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` */ interface DialogflowSynthesizeSpeechConfig { /** * Optional. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is the normal native speed supported by the specific voice. 2.0 is twice as fast, and 0.5 is half as fast. If not set (0.0), defaults to the native 1.0 speed. Any other values < 0.25 or > 4.0 return an error. */ speakingRate?: number; /** * Optional. Speaking pitch, in the range [-20.0, 20.0]. 20 means increase 20 semitones from the original pitch. -20 means decrease 20 semitones from the original pitch. */ pitch?: number; /** * Optional. Volume gain (in dB) of the normal native volume supported by the specific voice, in the range [-96.0, 16.0]. If not set, or set to a value of 0.0 (dB), plays at normal native signal amplitude. A value of -6.0 (dB) plays at approximately half the amplitude of the normal native signal amplitude. A value of +6.0 (dB) plays at approximately twice the amplitude of the normal native signal amplitude. We strongly recommend not to exceed +10 (dB) as there is usually no effective increase in loudness for any value greater than that. */ volumeGainDb?: number; /** * Optional. An identifier which selects 'audio effects' profiles that are applied on (post synthesized) text to speech. Effects are applied on top of each other in the order they are given. */ effectsProfileId?: string[]; /** * Optional. The desired voice of the synthesized audio. */ voice?: DialogflowVoiceSelectionParameters; } } declare namespace AI { /** * Represents a natural language text to be processed. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` */ interface DialogflowTextInput { /** * The UTF-8 encoded natural language text to be processed. Text length must not exceed 256 bytes */ text: string; /** * The language ot the conversation query */ languageCode: DialogflowLanguage; } } declare namespace AI { /** * Description of which voice to use for speech synthesis. * <br> * Add the following line to your scenario code to use the interface: * ``` * require(Modules.AI); * ``` */ interface DialogflowVoiceSelectionParameters { /** * Optional. The name of the voice. If not set, the service chooses a voice based on the other parameters such as language_code and gender. */ name?: string; /** * Optional. The preferred gender of the voice. If not set, the service chooses a voice based on the other parameters such as language_code and name. Note that this is only a preference, not requirement. If a voice of the appropriate gender is not available, the synthesizer should substitute a voice with a different gender rather than failing the request. */ ssmlGender?: DialogflowSsmlVoiceGender; } } declare namespace AI { /** * Add the following line to your scenario code to use the events: * ``` * require(Modules.AI); * ``` * @event */ enum Events { /** * Triggered when a Dialogflow instance returns a query result. * @typedef _DialogflowQueryResultEvent */ DialogflowQueryResult = 'AI.Events.DialogflowQueryResult', /** * Triggered when a Dialogflow instance returns a recognition result. * @typedef _DialogflowRecognitionResultEvent */ DialogflowRecognitionResult = 'AI.Events.DialogflowRecognitionResult', /** * Triggered when a Dialogflow instance returns an intent response. * @typedef _DialogflowResponseEvent */ DialogflowResponse = 'AI.Events.DialogflowResponse', /** * Triggered when a Dialogflow instance causes error. * @typedef _DialogflowErrorEvent */ DialogflowError = 'AI.Events.DialogflowError', /** * Triggered when a Dialogflow instance is stopped. * @typedef _DialogflowStoppedEvent */ DialogflowStopped = 'AI.Events.DialogflowStopped', /** * Triggered when a playback of a single phrase is finished successfully or in case of playback error. * @typedef _DialogflowPlaybackFinishedEvent */ DialogflowPlaybackFinished = 'AI.Events.DialogflowPlaybackFinished', /** * Triggered when a playback of a single phrase is started. * @typedef _DialogflowPlaybackStartedEvent */ DialogflowPlaybackStarted = 'AI.Events.DialogflowPlaybackStarted', /** * Triggered when 'DialogflowInstance.addMarker' is reached. * @typedef _DialogflowPlaybackMarkerReachedEvent */ DialogflowPlaybackMarkerReached = 'AI.Events.DialogflowPlaybackMarkerReached', /** * Triggered when an answering machine or voicemail is detected. * @typedef _VoicemailDetectedEvent * @deprecated Use [AMD] instead */ VoicemailDetected = 'AI.Events.VoicemailDetected', /** * Triggered when an answering machine or voicemail is not detected. * @typedef _VoicemailNotDetectedEvent * @deprecated Use [AMD] instead */ VoicemailNotDetected = 'AI.Events.VoicemailNotDetected', } /** * @private */ interface _Events { [Events.DialogflowQueryResult]: _DialogflowQueryResultEvent; [Events.DialogflowRecognitionResult]: _DialogflowRecognitionResultEvent; [Events.DialogflowResponse]: _DialogflowResponseEvent; [Events.DialogflowError]: _DialogflowErrorEvent; [Events.DialogflowStopped]: _DialogflowStoppedEvent; [Events.DialogflowPlaybackFinished]: _DialogflowPlaybackFinishedEvent; [Events.DialogflowPlaybackStarted]: _DialogflowPlaybackStartedEvent; [Events.DialogflowPlaybackMarkerReached]: _DialogflowPlaybackMarkerReachedEvent; [Events.VoicemailDetected]: _VoicemailDetectedEvent; [Events.VoicemailNotDetected]: _VoicemailNotDetectedEvent; } /** * @private */ interface _DialogflowEvent { /** * Link to the Dialogflow instance. */ dialogflow: DialogflowInstance; } /** * @private */ interface _DialogflowQueryResultEvent extends _DialogflowEvent { /** * The results of the conversational query or event processing. */ result: DialogflowResult; } /** * @private */ interface _DialogflowRecognitionResultEvent extends _DialogflowEvent { /** * The default of **0.0** is a sentinel value indicating confidence was not set. If **false**, the *StreamingRecognitionResult* represents an interim result that may change. If **true**, the recognizer does not return any further hypotheses about this piece of the audio. */ isFinal: boolean; } /** * @private */ interface _DialogflowResponseEvent extends _DialogflowEvent { /** * The intent response. */ response: DialogflowResponse; } /** * @private */ interface _DialogflowErrorEvent extends _DialogflowEvent { /** * The cause of the event. */ cause: string; } /** * @private */ interface _DialogflowStoppedEvent extends _DialogflowEvent { /** * The cause of the event. */ cause: string; } /** * @private */ interface _DialogflowPlaybackFinishedEvent extends _DialogflowEvent { error?: string; } /** * @private */ interface _DialogflowPlaybackStartedEvent extends _DialogflowEvent { /** * Playback duration. */ duration: number; } /** * @private */ interface _DialogflowPlaybackMarkerReachedEvent extends _DialogflowEvent { /** * Marker offset. */ offset: number; } /** * @private */ interface _VoicemailBaseEvent { /** * Call that triggers the event. */ call: Call; } /** * @private */ interface _VoicemailDetectedEvent extends _VoicemailBaseEvent { /** * Recognition confidence. Values range from **0** (completely uncertain) to **100** (completely certain). The value is not guaranteed to be accurate, consider it while handling the event. */ confidence: number; } /** * @private */ interface _VoicemailNotDetectedEvent extends _VoicemailBaseEvent {} } declare namespace AMD { /** * Parameters for the [AMD.create] method. */ interface AMDParameters { /** * Recognition model - [AMD.Model]. */ model: AMD.Model; /** * Optional. Detection timeout in milliseconds. Note that the timeout is only triggered after the [CallEvents.Connected] event. The default value is **6500**. Must not be less than **0** or greater than **20000**. */ timeout?: number; /** * Optional. Detection threshold in the range **0.0** - **1.0**. */ thresholds?: AMD.Thresholds; } } /** * Answering Machine Detection provides methods that allow developers to recognize voicemail prompts with the help of artificial intelligence. * Read more about the topic in the [Voicemail detection](/docs/guides/calls/voicemail-detection) article. */ declare namespace AMD {} declare namespace AMD { /** * Answering machine or voicemail detector class. */ class AnsweringMachineDetector { readonly call?: Call; readonly model: AMD.Model; readonly timeout?: number; /** * Returns the Answering machine detector's id. */ id(): string; /** * Starts answering machine or voicemail recognition session. */ detect(): Promise<AMD.Events>; /** * Adds a handler for the specified [AMD.Events]. Use only functions as handlers; anything except a function leads to an error and scenario termination when a handler is called. * @param event Event class (e.g., [AMD.Events.DetectionComplete]) * @param callback Handler function. A single parameter is passed - object with event information */ addEventListener<T extends keyof AMD._Events>( event: AMD.Events | T, callback: (event: AMD._Events[T]) => any, ): void; /** * Removes a handler for the specified [AMD.Events] event. * @param event Event class (i.e., [AMD.Events.DetectionComplete]) * @param callback Optional. Handler function. If not specified, all handler functions are removed */ removeEventListener<T extends keyof AMD._Events>( event: AMD.Events | T, callback?: (event: AMD._Events[T]) => any, ): void; } } declare namespace AMD { /** * Creates a new [AMD.AnsweringMachineDetector](answering machine or voicemail detector) instance. You can attach sources later via the [VoxMediaUnit] **sendMediaTo** method. */ function create(parameters: AMD.AMDParameters): AMD.AnsweringMachineDetector; } declare namespace AMD { /** * @event */ enum Events { /** * Triggered when answering machine or voicemail detection is complete. * @typedef AMD._DetectionCompleteEvent */ DetectionComplete = 'AMD.Events.DetectionComplete', /** * Triggered when answering machine detector throw an error. * @typedef AMD._DetectionErrorEvent */ DetectionError = 'AMD.Events.DetectionError', } /** * @private */ interface _Events { [AMD.Events.DetectionComplete]: AMD._DetectionCompleteEvent; [AMD.Events.DetectionError]: AMD._DetectionErrorEvent; } /** * @private */ interface _AMDEvent { /** * AMD istance that generated the event */ amd: AMD.AnsweringMachineDetector; } /** * @private */ interface _DetectionCompleteEvent extends _AMDEvent{ /** * Call that triggers the event. */ call: Call; /** * The id of the Call. */ callId: string; /** * Answering machine result class, such as human, voicemail, timeout or call termination. */ resultClass: AMD.ResultClass; /** * Answering machine result subtype, such as MIMIC or NONE. */ resultSubtype?: AMD.ResultSubtype; /** * Recognition confidence. Values range from 0 (completely uncertain) to 100 (completely certain). The value is not guaranteed to be accurate, consider it while handling the event. */ confidence?: number; } /** * @private */ interface _DetectionErrorEvent extends _AMDEvent{ /** * The id of the Call. */ callId?: string; /** * Error message. */ message: string; } } declare namespace AMD { /** * Answering machine or voicemail detector model. */ enum Model { /** * Brazil */ BR = 'br', /** * Chile */ CL = 'cl', /** * Colombia */ CO = 'colombia', /** * Kazakhstan */ KZ = 'kz', /** * Mexico */ MX = 'mx', /** * Russia */ RU = 'ru', /** * Philippines */ PH = 'ph', /** * Peru */ PE = 'pe', /** * United States */ US = 'us', /** * General European multilingual model */ EU_GENERAL = 'eu_general', } } declare namespace AMD { /** * Answering machine result class, such as human, voicemail, timeout or call termination. */ enum ResultClass { /** * AMD detected a voicemail prompt. */ VOICEMAIL = 'VOICEMAIL', /** * AMD detected a human answering. */ HUMAN = 'HUMAN', /** * AMD reached the recognition timeout. */ TIMEOUT = 'TIMEOUT', /** * AMD detected a call hangup. */ CALL_ENDED = 'CALL_ENDED', } } declare namespace AMD { /** * Answering machine result subtype, such as mimic or none. */ enum ResultSubtype { MIMIC = 'MIMIC', NONE = 'NONE', } } declare namespace AMD { /** * Detection threshold in the range **0.0** - **1.0** */ interface Thresholds { human?: number; voicemail?: number; mimic?: number; } } /** * @event */ declare enum AppEvents { /** * Triggered when an incoming call arrives. * @typedef _CallAlertingEvent */ CallAlerting = 'Application.CallAlerting', /** * Triggered when a session is about to terminate. Triggers in two cases:<br> * 1) when there are no calls and/or ACD requests in a call session. See the [session limits](/docs/guides/voxengine/limits) for details;<br> * 2) when the [VoxEngine.terminate](/docs/references/voxengine/voxengine/terminate) method is called. Timers and any other external resources are not available after this event is triggered, * but you can perform one HTTP request inside the event handler (e.g. to notify an external system about the fact that the session is finished). * When that request is finished (or no such request is made), the [AppEvents.Terminated] event is triggered. * @typedef _TerminatingEvent */ Terminating = 'Application.Terminating', /** * Triggered when a session is terminated and after the [AppEvents.Terminating] event is triggered. * The time between these events depends on handler for [AppEvents.Terminating] event. * Use the event just for debugging, only the [Logger.write] method could be used in a handler. * @typedef _TerminatedEvent */ Terminated = 'Application.Terminated', /** * The very first event is triggered due to incoming call or HTTP request to Voximplant cloud over the internet. * Triggers only once in a session, so if you execute the same HTTP request again it creates the new, separate session. * Note that usage of the event in your JS scenario is optional. * @typedef _StartedEvent */ Started = 'Application.Started', /** * Triggered when the managing HTTP request is received by the session. * If you [start a call session with HTTP request](/docs/references/httpapi/managing_scenarios#startscenarios), you get an answer: an object with media\_session\_access\_url property. * The property's value is the managing URL for the specified session, so it can be used in managing HTTP request that triggers [AppEvents.HttpRequest] event. * @typedef _HttpRequestEvent */ HttpRequest = 'Application.HttpRequest', /** * Triggered when there is a new connection to a WebSocket. * @typedef _NewWebSocketEvent */ WebSocket = 'AppEvents.NewWebSocketConnection', /** * Triggered when a WebSocket fails. It can happen when the number of incoming WebSocket connections exceeds the number of calls in one session + 3. * @typedef _NewWebSocketFailedEvent */ NewWebSocketFailed = 'Application.OnNewWebSocketFailed', } /** * @private */ declare interface _AppEvents { [AppEvents.CallAlerting]: _CallAlertingEvent; [AppEvents.Terminating]: _TerminatingEvent; [AppEvents.Terminated]: _TerminatedEvent; [AppEvents.Started]: _StartedEvent; [AppEvents.HttpRequest]: _HttpRequestEvent; [AppEvents.WebSocket]: _NewWebSocketEvent; [AppEvents.NewWebSocketFailed]: _NewWebSocketFailedEvent; } /** * @private */ declare interface _HttpRequestEvent { /** * HTTP request method. E.g. 'POST'. */ method: string; /** * HTTP path requested (without the domain name). E.g. '/request/1d61f27ba2faad53.1500645140.80028_185.164.148.244/eb4b0539b13e2401'. */ path: string; /** * HTTP request content. E.g. '{"param1": "value1", "param2": "value2"}'. */ content: string; /** * List of dictionaries with key and value fields representing HTTP headers (the ones starting with "X-"). */ headers: { key: string; value: string }[]; } /** * @private */ declare interface _NewWebSocketFailedEvent extends _HttpRequestEvent { reason: string; } /** * @private */ declare interface _NewWebSocketEvent extends _HttpRequestEvent { websocket: WebSocket; } /** * @private */ declare interface _StartedEvent { /** * HTTP URL that can be used to send commands to this scenario from the external systems. */ accessURL: string; /** * HTTPS URL that can be used to send commands to this scenario from the external systems. */ accessSecureURL: string; /** * Unique identification number of the Voximplant account. Can be used as one of the [authentication parameters](/docs/references/httpapi/auth_parameters) in management API methods. */ accountId: number; /** * Unique identification number of Voximplant application. Can be used in [Managing Applications](/docs/references/httpapi/managing_applications) in management API methods. */ applicationId: number; /** * Direct link to the call's log. */ logURL: string; /** * Identification number of JS session that is unique within an account and its child accounts. Can be used in [Managing History](/docs/references/httpapi/managing_history) in management API methods. */ sessionId: number; /** * Conference name that is passed to the conference session created via the management API. */ conference_name: string; } /** * @private */ declare interface _TerminatedEvent {} /** * @private */ declare interface _TerminatingEvent {} /** * @private */ declare interface _CallAlertingEvent { /** * Incoming call that triggered the event. */ call: Call; /** * Name of the event - "Application.CallAlerting". */ name: string; /** * CallerID for current call. */ callerid: string; /** * Dialed number. */ destination: string; /** * Dialed SIP URI. */ toURI: string; /** * Source CallerID with domain or SIP URI for incoming SIP call. */ fromURI: string; /** * Displayable name of the caller. */ displayName: string; /** * Custom SIP headers received with the call (the ones starting with "X-"). */ headers: { [header: string]: string }; /** * Optional. Custom data for the current call object. It can be passed from Web SDK via the [Client.call](/docs/references/websdk/voximplant/client#call) method in the *customData* parameter. */ customData?: string; /** * Internal information about codecs, should be passed to the [VoxEngine.callUser], [VoxEngine.callUserDirect], [VoxEngine.callSIP], [VoxEngine.callConference], [Call.answer], [Call.answerDirect], [Call.startEarlyMedia] methods call. */ scheme: string; } /** * Represents an application storage object to manipulate key-value pairs. * <br> * Add the following line to your scenario code to use the class: * ``` * require(Modules.ApplicationStorage); * ``` */ declare namespace ApplicationStorage { } declare namespace ApplicationStorage { /** * Retrieves a value of the specified key. * @param key Key to get */ function get(key: string): Promise<StorageKey | null>; } declare namespace ApplicationStorage { /** * Retrieves all the keys assigned to a Voximplant application. * @param pattern Optional. Namespace that keys should contain */ function keys(pattern?: string): Promise<StoragePage>; } declare namespace ApplicationStorage { /** * Creates a key-value pair. If an already existing **key** is passed, the method updates its **value**. * <br> * The keys should be unique within a Voximplant application. * @param key Key to create/update, up to 200 characters. A key can contain a namespace that is written before a colon, for example, test:1234. Thus, namespace "test" can be used as a **pattern** in the [keys](/docs/references/voxengine/applicationstorage#keys) method to find the keys with the same namespace. If no namespace is set, the key itself is considered as namespace * @param value Value for the specified key, up to 2000 characters * @param ttl Key expiry time in seconds. The value is in range of 0..7,776,000 (90 days). The TTL is converted to an `expireAt` Unix timestamp field as part of the storage object. Note that the pricing is tiered in three day-based pieces: 0-30, 31-60, 61-90. See the details [here](https://voximplant.com/pricing) */ function put(key: string, value: string, ttl: number): Promise<StorageKey>; } declare namespace ApplicationStorage { /** * Removes the specified key. Note that the returned **StorageKey** always has zero **ttl**. * @param key Key to delete */ function remove(key: string): Promise<StorageKey>; } /** * List of available dictionaries for ASR. * <br> * Add the following line to your scenario code to use the enum: * ``` * require(Modules.ASR); * ``` * @deprecated Use [ASRModelList] instead */ declare enum ASRDictionary { /** * ASR Russian addresses dictionary * @deprecated Use [ASRModelList] instead */ ADDRESS_RU = 'asr-dict-address-ru', /** * ASR Turkish addresses dictionary * @deprecated Use [ASRModelList] instead */ ADDRESS_TR = 'asr-dict-address-tr', /** * ASR addresses dictionary * Available languages 'ru-RU','en-US','uk-UK','tr-TR','de-DE','fr-FR','es-ES' * @deprecated Use [ASRModelList] instead */ ADDRESS = 'asr-dict-yand-maps', /** * ASR notes dictionary * @deprecated Use [ASRModelList] instead */ NOTES = 'asr-dict-yand-notes', /** * ASR queries dictionary * Available languages 'ru-RU','en-US','uk-UK','tr-TR' * @deprecated Use [ASRModelList] instead */ SEARCH_QUERIES = 'asr-dict-yand-queries', /** * ASR music dictionary * @deprecated Use [ASRModelList] instead */ MUSIC = 'asr-dict-yand-music', /** * ASR buying dictionary * @deprecated Use [ASRModelList] instead */ ECOMMERCE = 'asr-dict-yand-buying', /** * ASR Russian phone numbers dictionary * @deprecated Use [ASRModelList] instead */ NUMBERS_RU = 'asr-dict-yand-numbers', /** * ASR Russian general dictionary * @deprecated Use [ASRModelList] instead */ GENERAL_RU = 'asr-dict-yand-general', /** * ASR Russian date dictionary * @deprecated Use [ASRModelList] instead */ DATE_RU = 'asr-dict-yand-dates', /** * ASR Russian names dictionary * @deprecated Use [ASRModelList] instead */ NAMES_RU = 'asr-dict-yand-names', /** * ASR Russian questionnaire dictionary * @deprecated Use [ASRModelList] instead */ QUESTIONNAIRE_RU = 'asr-dict-yand-questionnaire', /** * ASR Russian T-Bank dictionary * @deprecated Use [ASRModelList] instead */ TBANK = 'asr-dict-tinkoff-', } /** * Add the following line to your scenario code to use the events: * ``` * require(Modules.ASR); * ``` * @event */ declare enum ASREvents { /** * Triggers in case of errors during the recognition process. * @typedef _ASRErrorEvent */ ASRError = 'ASR.Error', /** * Triggers after ASR instance is created. * @typedef _ASRStartedEvent */ Started = 'ASR.Started', /** * Triggers after ASR detected voice input and started collecting audio data for ASR. * @typedef _ASRCaptureStartedEvent */ CaptureStarted = 'ASR.CaptureStarted', /** * Triggers after ASR captured audio data, before recognition process. * @typedef _ASRSpeechCapturedEvent */ SpeechCaptured = 'ASR.SpeechCaptured', /** * Triggered when a speech recognition result has been received from ASR. * * We strongly recommend to create recognition timeout manually to prevent unexpectedly long recognition time. * Note: We recommend to take a decision about continuing speech recognition in this event's handler. Otherwise, speech recognition continues automatically. * @typedef _ASRResultEvent */ Result = 'ASR.Result', /** * Triggered when interim recognition result received from ASR. Note that event could be triggered only if the [ASRParameters.interimResults] option is set to **true**. * @typedef _ASRInterimResultEvent */ InterimResult = 'ASR.InterimResult', /** * Triggers as a result of the [ASR.stop] method call. * @typedef _ASRStoppedEvent */ Stopped = 'ASR.Stopped', } /** * @private */ declare interface _ASREvents { [ASREvents.ASRError]: _ASRErrorEvent; [ASREvents.Started]: _ASRStartedEvent; [ASREvents.CaptureStarted]: _ASRCaptureStartedEvent; [ASREvents.SpeechCaptured]: _ASRSpeechCapturedEvent; [ASREvents.Result]: _ASRResultEvent; [ASREvents.InterimResult]: _ASRInterimResultEvent; [ASREvents.Stopped]: _ASRStoppedEvent; } /** * @private */ declare interface _ASREvent { /** * ASR instance that generated the event */ asr: ASR; } /** * @private */ declare interface _ASRErrorEvent extends _ASREvent { /** * Error message */ error: string; } /** * @private */ declare interface _ASRStartedEvent extends _ASREvent {} /** * @private */ declare interface _ASRCaptureStartedEvent extends _ASREvent {} /** * @private */ declare interface _ASRSpeechCapturedEvent extends _ASREvent {} /** * @private */ declare interface _ASRResultEvent extends _ASREvent { /** * Recognition result. Depending on the ASR provider, this parameter is called text or transcript (in rare cases). */ text: string; /** * Recognition confidence. Depending on the ASR provider, can be in 0..100 or 0..1 range (100 or 1 means full confidence, 0 - not confident at all) */ confidence: number; /** * Optional. Time offset of the end of this result relative to the beginning of the audio. */ resultEndTime?: string | number; /** * Optional. For multichannel audio, this is the channel number corresponding to the recognized result for the audio from that channel. */ channelTag?: number; /** * Optional. Output only. The BCP-47 language tag of the language in this result. This language code is detected to have the most likelihood of being spoken in the audio. */ languageCode?: string; } /** * @private */ declare interface _ASRInterimResultEvent extends _ASREvent { /** * Recognition result */ text: string; } /** * @private */ declare interface _ASRStoppedEvent extends _ASREvent { /** * Record cost (in the account's currency: USD, EUR or RUB) */ cost: string; /** * Record duration (sec) */ duration: number; } /** * List of available languages for ASR. * <br> * Note that the T-Bank VoiceKit and Yandex Speechkit supports only 'ASRLanguage.RUSSIAN_RU' language. * <br> * Add the following