Intent Class
  • Updated on 19 Aug 2019
  • 2 minutes to read
  • Contributors
  • Print
  • Share
  • Dark
    Light

Intent Class

  • Print
  • Share
  • Dark
    Light

Usage

//Intent Chitchat
let chitchat = new Intent('1_chitchat');
chitchat.nlpId = 'FMApp';
chitchat.runOnCloud();
chitchat.setEnglishSmartSuggestions(['Hello'])

The above example is an NLP-based Intent that presents Smart Suggestions for the user at the bottom of the conversation.

Class properties

intentId

A read-only string property that represents the intent’s unique id. It is set in the class constructor and can only be queried.

nlpId

A string property that contains a valid nlpId set in the backend to perform the intent matching during the Intent Matching Process.

Class methods

EDGE()

This returns a string constant "Edge".

CLOUD()

This returns a string constant "Cloud".

NO_INTENT()

This returns a string constant "input.unknown".

SPEECH()

This returns a string constant "Speech".

LOCATION()

This returns a string constant "_location".

CONTACT()

This returns a string constant "_contact".

IMAGE()

This returns a string constant "_image".

VIDEO()

This returns a string constant "_video".

FILE()

This returns a string constant "_file".

runOnCloud()

When called, it forces Intent events to run on the Cloud.

runOnEdge()

When called, it forces Intent events to run on the Edge.

disableHistoryLogging()

When an intent is matched, it is added to the history of the conversation by default. If an intent is not required to be recorded in such a way, therefore, developers must call this method when the intent is defined.

silenceIntent()

When an intent is marked as silent, it won't require resolution and will not display any messages to the user.

setEnglishSmartSuggestions(suggestionsArray)

This method adds an array of smart suggestions (in the English language) to resolve the intent.

setEnglishSmartSuggestionWithCondition(defaultSuggestionsArray, conditionalSuggestionsArray, conditionFunction)

This method adds the conditionalSuggestionsArray to the intent if the condition function (embedded in the method?) returns ‘true’. In case the function returns ‘false’, or if it (‘it’ being the conditionalSuggestionsArray?) is not present, it adds the defaultSuggestionsArray.

setSmartSuggestions(lang, suggestionsArray)

This method adds the suggestionsArray in the specified language.

matchSuggestions(message)

This method returns ‘true’ if the message matches to one of the smart suggestions added to the intent or ‘false’ if there is no match.

Events

onMatching

This property is null until it is implemented by a developer. It is the closure called during the Intent Matching Process.

onValidation

This property is null until it is implemented by a developer. It is the closure called during the Intent Validation Process.

onResolution

This property is null until it is implemented by a developer. It is the closure called during the Intent Resolution Process.

onPrediction

This property is null until it is implemented by a developer. It is the closure called during the Intent Prediction Process.

onError

This property is null until it is implemented by a developer. It is the closure called during the Intent Error Handling Process.

Was this article helpful?