LuisRecognizer class
Intent recognizer plugin that detects a users intent using Microsofts Language Understanding Intelligent Service (LUIS) The service URLs for multiple LUIS models (apps) can be passed in to support recognition across multiple languages.
- Extends
Constructors
Luis |
Constructs a new instance of the recognizer. |
Methods
on |
Registers a function to conditionally enable/disable the recognizer. Multiple handlers can be registered and the new handler will be executed before any other handlers. |
on |
Registers a function to filter the output from the recognizer. Multiple handlers can be registered and the new handler will be executed after any other handlers. |
on |
Implements the actual recognition logic. |
recognize(IRecognize |
Attempts to match a users text utterance to an intent. |
recognize(string, string, (err: Error, intents?: IIntent[], entities?: IEntity[]) => void) | Calls LUIS to recognizing intents & entities in a users utterance. |
Constructor Details
LuisRecognizer(string | ILuisModelMap)
Constructs a new instance of the recognizer.
new LuisRecognizer(models: string | ILuisModelMap)
Parameters
- models
-
string | ILuisModelMap
Either an individual LUIS model used for all utterances or a map of per/locale models conditionally used depending on the locale of the utterance.
Method Details
onEnabled((context: IRecognizeContext, callback: (err: Error, enabled: boolean) => void) => void)
Registers a function to conditionally enable/disable the recognizer. Multiple handlers can be registered and the new handler will be executed before any other handlers.
function onEnabled(handler: (context: IRecognizeContext, callback: (err: Error, enabled: boolean) => void) => void)
Parameters
- handler
-
(context: IRecognizeContext, callback: (err: Error, enabled: boolean) => void) => void
Function called for every message. You should call callback(null, true)
for every message that should be recognized.
Returns
onFilter((context: IRecognizeContext, result: IIntentRecognizerResult, callback: (err: Error, result: IIntentRecognizerResult) => void) => void)
Registers a function to filter the output from the recognizer. Multiple handlers can be registered and the new handler will be executed after any other handlers.
function onFilter(handler: (context: IRecognizeContext, result: IIntentRecognizerResult, callback: (err: Error, result: IIntentRecognizerResult) => void) => void)
Parameters
- handler
-
(context: IRecognizeContext, result: IIntentRecognizerResult, callback: (err: Error, result: IIntentRecognizerResult) => void) => void
Function called for every message that results in an intent with a score greater then 0.0. You should call callback(null, { score: 0.0, intent: null })
to block an intent from being returned.
Returns
onRecognize(IRecognizeContext, (err: Error, result: IIntentRecognizerResult) => void)
Implements the actual recognition logic.
function onRecognize(context: IRecognizeContext, callback: (err: Error, result: IIntentRecognizerResult) => void)
Parameters
- context
- IRecognizeContext
- callback
-
(err: Error, result: IIntentRecognizerResult) => void
recognize(IRecognizeContext, (err: Error, result: IIntentRecognizerResult) => void)
Attempts to match a users text utterance to an intent.
function recognize(context: IRecognizeContext, callback: (err: Error, result: IIntentRecognizerResult) => void)
Parameters
- context
- IRecognizeContext
Contextual information for a received message that's being recognized.
- callback
-
(err: Error, result: IIntentRecognizerResult) => void
Function to invoke with the results of the recognition operation.
recognize(string, string, (err: Error, intents?: IIntent[], entities?: IEntity[]) => void)
Calls LUIS to recognizing intents & entities in a users utterance.
static function recognize(utterance: string, modelUrl: string, callback: (err: Error, intents?: IIntent[], entities?: IEntity[]) => void)
Parameters
- utterance
-
string
The text to pass to LUIS for recognition.
- modelUrl
-
string
- callback
-
(err: Error, intents?: IIntent[], entities?: IEntity[]) => void
Callback to invoke with the results of the intent recognition step.