I want to validate the data by checking if it is identified as an entity(lets say randomEntity) by Luis or not. If the data entered is recognized as randomEntity, then move ahead, otherwise use retry prompt. But this does not work using promptContext-
const luisResult = await this.luisRecognizer.recognize(promptContext.context);
This is sample code-
class MainDialog extends ComponentDialog {
constructor(userState) {
super(MAIN_DIALOG);
this.userState = userState;
this.addDialog(new TextPrompt('firstPrompt', this.firstStepValidator));
this.addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
this.firstStep.bind(this),
]));
this.initialDialogId = WATERFALL_DIALOG;
let luisConfig = {
applicationId: 'myid',
endpointKey: 'myendpointkey',
endpoint: 'myendpoint',
};
this.luisRecognizer = new LuisRecognizer(
luisConfig,
{
includeAllIntents: true,
log: true,
staging: false
},
true
);
}
/**
* The run method handles the incoming activity (in the form of a TurnContext) and passes it through the dialog system.
* If no dialog is active, it will start the default dialog.
* @param {*} turnContext
* @param {*} accessor
*/
async run(turnContext, accessor) {
const dialogSet = new DialogSet(accessor);
dialogSet.add(this);
const dialogContext = await dialogSet.createContext(turnContext);
const results = await dialogContext.continueDialog();
if (results.status === DialogTurnStatus.empty) {
await dialogContext.beginDialog(this.id);
}
}
async firstStep(stepContext) {
const promptOptions = {
prompt: 'Please enter xyz id',
retryPrompt: 'Please enter a valid xyz id' };
return await stepContext.prompt('firstPrompt', promptOptions);
}
async firstStepValidator(promptContext) {
const luisResult = await this.luisRecognizer.recognize(promptContext.context); //THROWS ERROR: TypeError: Cannot read property 'recognize' of undefined
//do something with result
}