IntentRecognizer class

Base class for all core recognizers. Allows conditional execution of a recognizer and post filtering of recognized intents. Derived class should override the abstract onRecognize() method.

Methods

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.

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.

onRecognize(IRecognizeContext, (err: Error, result: IIntentRecognizerResult) => void)

Overriden by derived class to implement the actual recognition logic.

recognize(IRecognizeContext, (err: Error, result: IIntentRecognizerResult) => void)

Attempts to match a users text utterance to an intent.

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)

Overriden by derived class to implement the actual recognition logic.

function onRecognize(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(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.