Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messages without text cause errors in several situations #1211

Closed
v-kydela opened this issue Dec 4, 2018 · 3 comments · Fixed by #1333
Closed

Messages without text cause errors in several situations #1211

v-kydela opened this issue Dec 4, 2018 · 3 comments · Fixed by #1333
Assignees
Labels
4.3 February 14, 2019 Release bug Indicates an unexpected problem or an unintended behavior.

Comments

@v-kydela
Copy link
Contributor

v-kydela commented Dec 4, 2018

Version

4.1.5

Describe the bug

There are certain situations involving recognizers (such as when using a choice prompt) where the SDK is unable to respond gracefully to a message with a null or empty Text property. Such a message can be generated by a card action or by the user uploading an attachment for example. In these situations, the SDK will throw an error like this (I've abbreviated the stack trace):

System.ArgumentNullException: Value cannot be null.
Parameter name: utterance
   at Microsoft.Bot.Builder.Dialogs.Choices.Find.FindChoices(String utterance, IList`1 choices, FindChoicesOptions options) in D:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\Choices\Find.cs:line 31
   at Microsoft.Bot.Builder.Dialogs.Choices.ChoiceRecognizers.RecognizeChoices(String utterance, IList`1 list, FindChoicesOptions options) in D:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\Choices\ChoiceRecognizers.cs:line 25
   at Microsoft.Bot.Builder.Dialogs.ChoicePrompt.OnRecognizeAsync(ITurnContext turnContext, IDictionary`2 state, PromptOptions options, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\Prompts\ChoicePrompt.cs:line 97
   at Microsoft.Bot.Builder.Dialogs.Prompt`1.<ContinueDialogAsync>d__5.MoveNext() in D:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\Prompts\Prompt.cs:line 82

To Reproduce

Steps to reproduce the behavior:

  1. Test a bot that uses both adaptive submit actions and choice prompts (the submit action should not have a string for its Data property which would simulate imBack behavior instead of postBack)
  2. When prompted to make a choice, click on an adaptive card's submit button
  3. See error

Expected behavior

The SDK should be able to handle textless messages gracefully. A null or empty Text property should be treated the same as white space. In the case of a choice prompt, the SDK should respond the same way to a textless message as it would if any other message was received that didn't contain a recognizable choice. In the case of LUIS recognizers, a textless message should probably be recognized as a None intent.

While it may seem acceptable for a textless message to throw an error in these situations because it means the user is doing something they shouldn't, consider that some developers are trying to incorporate cards into prompts, like in this case: #1202

Screenshots

null utterance

Additional context

This is related to this issue which was considered fixed: #572

Because the error seems to be showing up in multiple places, I don't want to limit the scope to just one spot in the code. I'm hoping some developers who are more familiar with the code base can implement a solution that applies to every instance of this pattern. The places I've found it are in Find.cs and LuisRecognizer.cs.

[bug]

@hansmbakker
Copy link

hansmbakker commented May 11, 2020

@stevengum @v-kydela can you please reopen this?

This is not fixed by only fixing choicerecognizer in #1333: if you click a button in an Adaptive Card that does a postBack then it sends a message activity with a value property and without text. This causes errors in Virtual Assistant at the moment.

@EricDahlvang
Copy link
Member

Hi @hansmbakker

The community libraries provide an AdaptiveCardPrompt which works with Adaptive Cards:

https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/blob/develop/libraries/Bot.Builder.Community.Dialogs.Prompts/AdaptiveCardPrompt.cs

nuget:
https://www.nuget.org/packages/Bot.Builder.Community.Dialogs.Prompts/

If you find this does not meet your needs, please open a new issue.

@hansmbakker
Copy link

hansmbakker commented May 12, 2020

Hi @EricDahlvang,
thank you for the suggestion!

Does that cover the use case where the button in the card can trigger an optional action, that the user can also decide to trigger a few turns later?

When handling it as a prompt, I suppose that the prompt listens for it only once (as a response to the Adaptive Card message from the bot to the user)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.3 February 14, 2019 Release bug Indicates an unexpected problem or an unintended behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants