Cannot Read Property 'length' Of Undefined Error In Bot Framework
I am getting the data from axios get request, and moving it to an array xyz. But when I am sending xyz to step.prompt, it is throwing this error: ' [onTurnError]: TypeError: Canno
Solution 1:
For a bot framework to use prompt you could use something like below
Prompt for size validation sample
returnawait stepContext.prompt(
SIZE_RANGE_PROMPT, {
prompt: 'How many people is the reservation for?',
retryPrompt: 'How large is your party?',
validations: { min: 3, max: 8 },
});
prompt for location selection sample
asyncpromptForLocation(stepContext) {
// Record the party size information in the current dialog state.
stepContext.values.size = stepContext.result;
// Prompt for location.returnawait stepContext.prompt(LOCATION_PROMPT, {
prompt: 'Please choose a location.',
retryPrompt: 'Sorry, please choose a location from the list.',
choices: ['Redmond', 'Bellevue', 'Seattle'],
});
}
I am assuming ,your second param should be any array/list , instead you are passing string named "Choose any one" which is why it is giving " Cannot read property 'length' of undefined" as it must be trying to access first or second element of the array and passed param is a string.
The second parameter of the prompt method takes a prompt options object, which has the following properties.
For reference , you can read in details in below doc
Hope it helps.
Solution 2:
for (var i = 0; i < response.data.length; i++) {
xyz[i] = `${response.data[i].xzyElement}`;
}
Try to add any element value into array in the above format.
Then the TypeError
will not occur.
Post a Comment for "Cannot Read Property 'length' Of Undefined Error In Bot Framework"