AI

The AI module provides additional methods that use Artificial Intelligence.
View as Markdown

The AI module provides additional methods that use Artificial Intelligence. These methods allow solving business tasks in a more productive way. Add the following line to your scenario code to use the namespace:

require(Modules.AI);

Classes

  • DialogflowInstance — Represents a Dialogflow instance. Add the following line to your scenario code to use the class: require(Modules.AI);

Enums

  • Events — Add the following line to your scenario code to use the events: require(Modules.AI);

Functions

createDialogflow

Creates a new AI.DialogflowInstance which provides resources for exchanging data with the Dialogflow API, handling specified events, etc. You can attach media streams later via the AI.DialogflowInstance.sendMediaTo or VoxEngine.sendMediaBetween methods. Add the following line to your scenario code to use the function:

require(Modules.AI);
1createDialogflow(parameters: DialogflowSettings): DialogflowInstance

Parameters

parameters
DialogflowSettingsRequired

detectVoicemail

Deprecated

Use AMD instead

Start a voicemail recognition session. You can check how many times voicemail was detected in the call history. Add the following line to your scenario code to use the function:

require(Modules.AI);
1detectVoicemail(call: Call, parameters: DetectVoicemailParameters): Promise<AI.Events>

Parameters

call
CallRequired
parameters
DetectVoicemailParametersRequired

Types

DetectVoicemailParameters

Represents a parameters of the voicemail recognition session. Add the following line to your scenario code to use the interface:

require(Modules.AI);
model
string

optional

Optional. Recognition model. The possible values are ru, colombia. The default value is ru.

threshold
number

optional

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.

DialogflowEventInput

Dialogflow events allow matching intents by event name instead of the natural language input. Add the following line to your scenario code to use the interface:

require(Modules.AI);
languageCode
DialogflowLanguage

The language ot this conversation query

name
string

The unique identifier of the event.

parameters
{ [key: string]: any }

The collection of parameters associated with the event

DialogflowOutputAudioConfig

Instructs the speech synthesizer on how to generate the output audio content. Add the following line to your scenario code to use the interface:

require(Modules.AI);
synthesizeSpeechConfig
DialogflowSynthesizeSpeechConfig

optional

Optional. Configuration of how speech should be synthesized.

DialogflowQueryInput

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 Add the following line to your scenario code to use the interface:
require(Modules.AI);
event
DialogflowEventInput

The event to be processed.

text
DialogflowTextInput

The natural language text to be processed.

DialogflowQueryParameters

Represents a parameters of the conversational query. Add the following line to your scenario code to use the interface:

require(Modules.AI);
contexts
any[]

optional

Optional. The collection of contexts to be activated before the query execution.

geoLocation
{ [key: string]: any }

optional

Optional. The geolocation of the conversational query.

payload
{ [key: string]: any }

optional

Optional. Use this field to pass custom data into the webhook associated with the agent. Arbitrary JSON objects are supported.

resetContexts
boolean

optional

Optional. Whether to delete all contexts in the current session before activation of a new one.

sessionEntityTypes
any[]

optional

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.

timeZone
string

optional

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.

DialogflowResponse

Represents a Dialogflow intent response. Add the following line to your scenario code to use the interface:

require(Modules.AI);
queryResult
DialogflowResult

optional

Optional. The result of the conversational query or event processing.

recognitionResult
DialogflowStreamingRecognitionResult

optional

Optional. The result of speech recognition.

responseId
string

The unique identifier of the response. Use it to locate a response in the training example set or for reporting issues.

webhookStatus
{ [id: string]: any }

Status of the webhook request.

DialogflowResult

Represents a result of an intent response. Add the following line to your scenario code to use the interface:

require(Modules.AI);
action
string

The action name from the matched intent.

allRequiredParamsPresent
boolean

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.

diagnosticInfo
{ [id: string]: any }

The free-form diagnostic info. For example, this field could contain webhook call latency.

fulfillmentMessages
any[]

The collection of rich messages to present to the user.

fulfillmentText
string

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.

intent
{ [id: string]: 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.

intentDetectionConfidence
number

The intent detection confidence. Values range from 0.0 (completely uncertain) to 1.0 (completely certain).

languageCode
string

The language that was triggered during intent detection. See Language support for a list of the currently supported language codes.

parameters
{ [id: string]: any }

The collection of extracted parameters.

queryText
string

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.

DialogflowSettings

Settings for setting up a new Dialogflow instance Add the following line to your scenario code to use the interface:

require(Modules.AI);
agentId
number

optional

Optional. ID of the Dialogflow agent certificate to use. It can be any of the certificates previously added in the control panel, 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.

beta
boolean

optional

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.

environmentId
string

optional

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.

lang
DialogflowLanguage

Language for the Dialogflow instance.

model
DialogflowModel

optional

Optional. Machine learning model to transcribe your audio file.

modelVariant
DialogflowModelVariant

optional

Optional. Variant of the specified Speech model to use.

outputAudioConfig
DialogflowOutputAudioConfig

Instructs the speech synthesizer how to generate the output audio content.

phraseHints
any[]

optional

Optional. The collection of phrase hints to boost accuracy of speech recognition.

queryParameters
DialogflowQueryParameters

Initial query parameters.

region
string

optional

Optional. The agent’s location.

sessionId
string

optional

Optional. Dialogflow session id. Use it for connection to the existing Dialogflow session or to specify your own id for a new session.

singleUtterance
boolean

Whether to enable single utterance.

userId
string

optional

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 “-”.

DialogflowStreamingRecognitionResult

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. Add the following line to your scenario code to use the interface:

require(Modules.AI);
confidence
number

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.

isFinal
boolean

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.

messageType
string

Type of the result message.

transcript
string

Optional. Transcript text representing the words that the user spoke.

DialogflowSynthesizeSpeechConfig

Configuration of how speech should be synthesized. Add the following line to your scenario code to use the interface:

require(Modules.AI);
effectsProfileId
string[]

optional

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.

pitch
number

optional

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.

speakingRate
number

optional

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.

voice
DialogflowVoiceSelectionParameters

optional

Optional. The desired voice of the synthesized audio.

volumeGainDb
number

optional

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.

DialogflowTextInput

Represents a natural language text to be processed. Add the following line to your scenario code to use the interface:

require(Modules.AI);
languageCode
DialogflowLanguage

The language ot the conversation query

text
string

The UTF-8 encoded natural language text to be processed. Text length must not exceed 256 bytes

DialogflowVoiceSelectionParameters

Description of which voice to use for speech synthesis. Add the following line to your scenario code to use the interface:

require(Modules.AI);
name
string

optional

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.

ssmlGender
DialogflowSsmlVoiceGender

optional

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.