question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ChoiceInput\ConfirmInput shows TypeError: Cannot read property 'getValue' of undefined in Telegram channel

See original GitHub issue

Versions

bot framework v 4.9.2. nodejs 12.18.0 botbuilder-dialogs-adaptive@4.9.2-preview OS - Windows Channel Telegram

Describe the bug

I have tried to build an adaptive dialog based on the sample here : https://github.com/microsoft/BotBuilder-Samples/tree/master/experimental/adaptive-dialog/javascript_nodejs/06.todo-bot

ConfirmInput code:

new ConfirmInput().configure({
    property: new StringExpression('turn.addTodo.cancelConfirmation'),
    prompt: new ActivityTemplate('${ConfirmCancellation()}'),
    // Allow interruptions is an expression. So you can write any expression to determine if an interruption should be allowed.
    // In this case, we will disallow interruptions since this is a cancellation confirmation.
    allowInterruptions: new BoolExpression(false),
    // Controls the number of times user is prompted for this input.
    maxTurnCount: new NumberExpression(1),
    // Default value to use if we have hit the MaxTurnCount
    defaultValue: new BoolExpression('=false'),
    // You can refer to properties of this input via %propertyName notation.
    // The default response is sent if we have prompted the user for MaxTurnCount number of times
    // and if a default value is assumed for the property.
    defaultValueResponse: new ActivityTemplate("Sorry, I do not recognize '${this.value}'. I'm going with '${%DefaultValue}' for now to be safe.")
}),

ChoiceInput code:

new ChoiceInput().configure({
    id: 'questionID',
    property: new StringExpression('turn.userAnswer'),
    prompt: new ActivityTemplate('${Question()}'),
    style: new EnumExpression(ListStyle.auto),
    choices: new ArrayExpression(this.getChoices(this.taskProperties.choices)),
    alwaysPrompt: new BoolExpression(true),
    unrecognizedPrompt: new ActivityTemplate('${errUseButtons()}'),
    maxTurnCount: new IntExpression(1),
    allowInterruptions: new BoolExpression(true),
    outputFormat: new EnumExpression(ChoiceOutputFormat.index)
}),

Everything is working on a WebChat and Emulator, but when I try to use Telegram channel, I get the following error : [onTurnError] unhandled error: TypeError: Cannot read property ‘getValue’ of undefined

Expected behavior

If I am correct Choices are supported in Telegram channel , so I expect see prompt with choices in Telegram.

[bug]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Hejazzcommented, Jul 3, 2020

I have investigated the issue and found possible problem in choiceInput.ts file.

protected async onRenderPrompt(dc: DialogContext, state: InputState): Promise<Partial<Activity>> {
        // Determine locale
        let locale: string = dc.context.activity.locale || this.**defaultLocale**.getValue(dc.state);
        if (!locale || !ChoiceInput.defaultChoiceOptions.hasOwnProperty(locale)) {
            locale = 'en-us';
        }

the problem appears when defaultLocale is not set in ChoiceInput configuration AND in Telegram channel the context.activity.locale is not set. So onRenderPrompt() it throws an error.

In WebChat channel the context.activity.locale has a value = en-us , that’s why there is no error there.

So, I guess, defaultLocale should be a mandatory and I think the code also should be fixed, because there is no sense to check for (!locale) on the next line if it throws an error before that.

0reactions
tdurnfordcommented, Sep 25, 2020

@carlosscastro Have you had a chance to review the PR associated with this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found