microsoft / botbuilder-dotnet

Welcome to the Bot Framework SDK for .NET repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using .NET.
https://github.com/Microsoft/botframework
MIT License
872 stars 482 forks source link

Microsoft.ConfirmInput confirmChoices throws exception when using ${} #6855

Closed darkcat013 closed 1 month ago

darkcat013 commented 1 month ago

Version

4.11.1

Describe the bug

In the documentation it is said that ConfirmChoices is an adaptive expression which supports the usage of ${} but when I try to use it, it throws this exception:

System.Data.SyntaxErrorException: mismatched input '{' expecting <EOF>
   at AdaptiveExpressions.ParserErrorListener.SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, Int32 line, Int32 charPositionInLine, String msg, RecognitionException e)
   at Antlr4.Runtime.ProxyErrorListener`1.SyntaxError(TextWriter output, IRecognizer recognizer, Symbol offendingSymbol, Int32 line, Int32 charPositionInLine, String msg, RecognitionException e)
   at Antlr4.Runtime.Parser.NotifyErrorListeners(IToken offendingToken, String msg, RecognitionException e)
   at Antlr4.Runtime.DefaultErrorStrategy.NotifyErrorListeners(Parser recognizer, String message, RecognitionException e)
   at Antlr4.Runtime.DefaultErrorStrategy.ReportInputMismatch(Parser recognizer, InputMismatchException e)
   at Antlr4.Runtime.DefaultErrorStrategy.ReportError(Parser recognizer, RecognitionException e)
   at ExpressionAntlrParser.file()
   at AdaptiveExpressions.ExpressionParser.AntlrParse(String expression)
   at AdaptiveExpressions.ExpressionParser.Parse(String expression)
   at AdaptiveExpressions.Expression.Parse(String expression, EvaluatorLookup lookup)
   at AdaptiveExpressions.Properties.ExpressionProperty`1.TryGetValue(Object data)
   at AdaptiveExpressions.Properties.ExpressionProperty`1.GetValue(Object data)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Input.ConfirmInput.OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Input.InputDialog.PromptUserAsync(DialogContext dc, InputState state, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Input.InputDialog.BeginDialogAsync(DialogContext dc, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogContext.BeginDialogAsync(String dialogId, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.BeginActionAsync(DialogContext dc, Int32 offset, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.BeginDialogAsync(DialogContext dc, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogContext.BeginDialogAsync(String dialogId, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.ContinueActionsAsync(DialogContext dc, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.BeginDialogAsync(DialogContext dc, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogContext.BeginDialogAsync(String dialogId, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.BeginActionAsync(DialogContext dc, Int32 offset, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.OnNextActionAsync(DialogContext dc, Object result, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.ResumeDialogAsync(DialogContext dc, DialogReason reason, Object result, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogContext.EndDialogAsync(Object result, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.SetProperty.BeginDialogAsync(DialogContext dc, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogContext.BeginDialogAsync(String dialogId, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.BeginActionAsync(DialogContext dc, Int32 offset, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.OnNextActionAsync(DialogContext dc, Object result, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Actions.ActionScope.ResumeDialogAsync(DialogContext dc, DialogReason reason, Object result, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogContext.EndDialogAsync(Object result, CancellationToken cancellationToken)

To Reproduce

Steps to reproduce the behavior:

Use the following code:

{
  "$kind": "Microsoft.AdaptiveDialog",
  "triggers": [
    {
      "$kind": "Microsoft.OnBeginDialog",
      "actions": [
        {
          "$kind": "Microsoft.ConfirmInput",
          "prompt": "Test",
          "property": "conversation.test",
          "confirmChoices": "${createArray({value: true, action: {title:'Yea', text:'Yea', displayText: 'Yeas', type: 'messageBack'}}, {value: false, action: {title: 'Nope', text:'Nope', displayText: 'Nooo', type: 'messageBack'}}, {value: true, action: {title:'Maybe', text:'Maybe', displayText: 'mby', type: 'messageBack'}})}",
          "maxTurnCount": 1
        }
      ]
    }
  ]
}

Expected behavior

The expression within ${} creates an array with the suggested actions.

dmvtech commented 1 month ago

Please try the following and see if that works for you:

=createArray({value: true, action: {title:'Yea', text:'Yea', displayText: 'Yeas', type: 'messageBack'}}, {value: false, action: {title: 'Nope', text:'Nope', displayText: 'Nooo', type: 'messageBack'}}, {value: true, action: {title:'Maybe', text:'Maybe', displayText: 'mby', type: 'messageBack'}})

I tried with yours (${}), but I did not receive an error. I am running version 4.21.2.

Is this in Bot Framework Composer or just simply using the SDK?

darkcat013 commented 1 month ago

Please try the following and see if that works for you:

=createArray({value: true, action: {title:'Yea', text:'Yea', displayText: 'Yeas', type: 'messageBack'}}, {value: false, action: {title: 'Nope', text:'Nope', displayText: 'Nooo', type: 'messageBack'}}, {value: true, action: {title:'Maybe', text:'Maybe', displayText: 'mby', type: 'messageBack'}})

I tried with yours (${}), but I did not receive an error. I am running version 4.21.2.

Is this in Bot Framework Composer or just simply using the SDK?

Hi, I'm using the SDK and I need the ${} to use a template from LG file, it works with = I've updated the library to 4.12 and it works with ${} so might be a bug in the earlier version. Thanks!