Typing indicator middleware might show after sending message(s)
See original GitHub issueVersion
4.6.2
Describe the bug
Typing indicator is showing after a message has been sent by the bot and typing indicator will timeout depending on the front-end channel that is used. This only happens if you do more work in the Turn then just sending out a single message like in the examples. In our current implementations we also save data to the database, execute some external processes and they all need to finish before the Cancellation is actually called on the ShowTypingMiddleware.
To Reproduce
Repro repo: https://github.com/jvanderbiest/echo-bot-typing-indicator
Steps to reproduce the behavior:
- Switch between
ShowTypingMiddleware
andCustomShowTypingMiddleware
https://github.com/jvanderbiest/echo-bot-typing-indicator/blob/master/AdapterWithErrorHandler.cs#L18
The EchoBot simulates some extra work after sending the initial message
Code snippet:
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
var activity = await CreateActivityWithTextAndSpeak($"Echo: {turnContext.Activity.Text}");
await RunSomething();
await turnContext.SendActivityAsync(activity, cancellationToken);
await RunSomething();
}
private async Task RunSomething()
{
await Task.Delay(5000);
}
As a temporary fix, I check if the bot has already responded: https://github.com/jvanderbiest/echo-bot-typing-indicator/blob/master/CustomShowTypingMiddleware.cs#L90
Expected behavior
Sending a bot message should stop the typing indicator and it should not send out any typing indicator activities
Screenshots
How it currently works
How it should work
Additional info
Any workaround or suggestion is appreciated
[bug]
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:13 (2 by maintainers)
Top GitHub Comments
I am able to reproduce this now (not sure what I was doing before 😐). I can repro on both 4.6.2 and 4.6.3.
I could even reproduce the issue with v4.7.0-preview-191203-1 from myget. So it’s still there…
@dmvtech my repo reproduced the issue, just use the normal ShowTypingMiddleware by commenting out the CustomShowTypingMiddleware as I described in the repro steps. It happens at least on these channels: emulator, webchat, facebook. Did not try other channels but I guess it has the same issue as it sends out the TypingActivity afterwards.
https://github.com/jvanderbiest/echo-bot-typing-indicator/blob/master/AdapterWithErrorHandler.cs#L18