-
Notifications
You must be signed in to change notification settings - Fork 279
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
[botbuilder-dialogs] Dialog does not prompt on continue dialog if any activity is sent on the turn #3947
Comments
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?
|
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: |
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to prevent sending a prompt twice to the user, using a symbol may be enough for that, without relying on global status
Since this is taking a while, I tried to write down my suggestion for one possible solution for this issue on #3981 I hope this suggestion is not considered intrusive. |
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,
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) |
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to prevent sending a prompt twice to the user, using a symbol may be enough for that, without relying on global status
@Stevenic do you have any feedback on this discussion regarding the context.responded flag? |
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to prevent sending a prompt twice to the user, using a symbol may be enough for that, without relying on global status
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to prevent sending a prompt twice to the user, using a symbol may be enough for that, without relying on global status
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to *not* send a prompt if the validator has already sent a message. This is in fact not explained anywhere and it leads to confusion, and restricts the ability to write concise explanations to users along side a retry. - The default behavior is kept, *except* if a message was sent *before* the validator (Those are not considered as part of the prompt logic). This still runs into concurrency issues. For that, - A static method in Prompt has been added, setRepromptStatus. This allows the user to choose explicitly if the prompt should re-prompt or not. - Added extra tests for the new functionality *only* for the text prompt, since all other prompts reuse that same logic.
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. |
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to *not* send a prompt if the validator has already sent a message. This is in fact not explained anywhere and it leads to confusion, and restricts the ability to write concise explanations to users along side a retry. - The default behavior is kept, *except* if a message was sent *before* the validator (Those are not considered as part of the prompt logic). This still runs into concurrency issues. For that, - A static method in Prompt has been added, setRepromptStatus. This allows the user to choose explicitly if the prompt should re-prompt or not. - Added extra tests for the new functionality *only* for the text prompt, since all other prompts reuse that same logic.
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to *not* send a prompt if the validator has already sent a message. This is in fact not explained anywhere and it leads to confusion, and restricts the ability to write concise explanations to users along side a retry. - The default behavior is kept, *except* if a message was sent *before* the validator (Those are not considered as part of the prompt logic). This still runs into concurrency issues. For that, - A static method in Prompt has been added, setRepromptStatus. This allows the user to choose explicitly if the prompt should re-prompt or not. - Added extra tests for the new functionality *only* for the text prompt, since all other prompts reuse that same logic.
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to *not* send a prompt if the validator has already sent a message. This is in fact not explained anywhere and it leads to confusion, and restricts the ability to write concise explanations to users along side a retry. - The default behavior is kept, *except* if a message was sent *before* the validator (Those are not considered as part of the prompt logic). This still runs into concurrency issues. For that, - A static method in Prompt has been added, setRepromptStatus. This allows the user to choose explicitly if the prompt should re-prompt or not. - Added extra tests for the new functionality *only* for the text prompt, since all other prompts reuse that same logic.
On issue microsoft#3947, relying on the responded flag todecide whether to show the prompt interferes with logic that could be happening either a. Concurrently b. On some middleware c. As part of how we reached the prompt I believe the *intention* is to *not* send a prompt if the validator has already sent a message. This is in fact not explained anywhere and it leads to confusion, and restricts the ability to write concise explanations to users along side a retry. - The default behavior is kept, *except* if a message was sent *before* the validator (Those are not considered as part of the prompt logic). This still runs into concurrency issues. For that, - A static method in Prompt has been added, setRepromptStatus. This allows the user to choose explicitly if the prompt should re-prompt or not. - Added extra tests for the new functionality *only* for the text prompt, since all other prompts reuse that same logic.
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
The text was updated successfully, but these errors were encountered: