Open alexrecuenco opened 3 years ago
Hi @alexrecuenco
Thank you for opening this issue. Does this also occur during runtime of the bot, or only with the TestAdapter?
Good morning/afternoon,
Yes, it occurs with any adapter. I just provided a simplified example. I was hoping it could be used to make it a test case when reviewing the issue
It is related to this line, I am not sure what was the intention for it, maybe to prevent the prompt prompting twice on the same turn when the dialog is resumed twice? https://github.com/microsoft/botbuilder-js/blob/cb0718c02239655b69d2e7681c8e2e8704c0df29/libraries/botbuilder-dialogs/src/prompts/prompt.ts#L260
It seems the sentNonTraceActivity flag should also be excluding activity types of Typing:
if (result.type !== ActivityTypes.Trace) {
sentNonTraceActivity = true;
}
@EricDahlvang , that is one issue, the "delay" type might also need to be included in that list of excluded activities, but I would say that is independent to this issue we are discussing.
Overall, I am not sure when you would want to prompt the user, but not show the prompt to the user.
In my opinion, If the goal is to prevent the bot saying twice the same prompt in a turn, a better way to achieve that would be to use a private symbol within the turnState, exclusive to the prompt itself.
I can try to propose a PR. But I am not sure that is the current intent
@EricDahlvang any update on this?
I've looked into this a bit more, and our historical guidance is to use middleware and response event handlers: https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-middleware?view=azure-bot-service-4.0#response-event-handlers Perhaps middleware could reset the responded flag to false under your specific business conditions?
This old comment thread provides a bit more context: https://github.com/microsoft/botbuilder-dotnet/pull/822#issuecomment-411479904
Since this is taking a while, I tried to write down my suggestion for one possible solution for this issue on https://github.com/microsoft/botbuilder-js/pull/3981
I hope this suggestion is not considered intrusive.
@EricDahlvang any update on this?
Our fix currently is to dig into the private properties on the context on the validator function, and to set it to false over there, then execute the validator.
Something like,
wrapValidator = (validator) => (prompt) => { prompt.context._respondedRef.responded=false; return validator(prompt) }
Obviously, we would like to remove that hack
I am not sure yet why it is even checking the responded flag because:
Notice how the suggestion (#3981) breaks the retry tests.
For backwards compatibility, we can wrap the validator to set the "shouldRetry" flag based on the "responded" flag change within the validator, unless you get a value of false instead of undefined. (And wrap all of this into some simple static functions on the Prompt class)
@Stevenic do you have any feedback on this discussion regarding the context.responded flag?
Good afternoon, I modified #3981 to address the backwards compatibility issues we were discussing.
Pushing a change like that (or similar to that if that is considered too intrusive) would minimize the harm of using the "responded" flag.
In essence, it understands the intention to check only if it responded within the validator.
It's been a while, was this ever fixed?
Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.
Versions
What package version of the SDK are you using: 4.14.1 What nodejs version are you using: node14 What browser version are you using: NA What os are you using: MacOS
Describe the bug
On continueDialog a prompt checks first if the context.responded is false before showing the prompt. This behavior is incorrect in most cases. I show here an example with a typing activity (Which is very common)
Expected behavior
On continueDialog, the question should be shown, regardless of whether the application sends message before the prompt continueDialog is called
If backwards compatibility for this is necessary, I would recommend to add an option parameter that specifies whether to reply on continue or not. And if this parameter is empty, continue doing the current behavior
PS: TestAdapter is broken
Also, note that if you run the test with the assertReply, the test adapter throws a unhandledpromiserejection. I believe currently the test adapter throws unhandled exceptions whenever
That makes it really hard to use the TestAdapter on tests to test error throwing