BotFramework-Emulator
BotFramework-Emulator copied to clipboard
Typing indicator not rendering while waiting on a delayed activity
Version
4.14.1 & 4.14.1-371583 (nightly)
Describe the bug
Whether using a JS or a .NET bot, when the ShowTypingMiddleware
is utilized, if the message
activity to be sent by the bot is delayed, the typing indicator fails to render. However, the activity is still logged in the network activity window and the activity can be selected in the transcript window.
Similarly, with_out_ using ShowTypingMiddleware
, when sending a typing
activity, followed by a delay
activity, and finally a message
activity the typing
activity will fail to render.
To Reproduce
(In a JS-based bot)
Option 1 steps to reproduce the behavior:
- Open the 02.echo-bot sample
- In the index.js file, add
.use(new ShowTypingMiddleware(500, 1000))
to the adapter - In the bot.js file, change the
this.onMessage
handler to the following:
this.onMessage(async (context, next) => {
const replyText = `Echo: ${ context.activity.text }`;
await asyncTimeout(
async () =>
await context.sendActivity(MessageFactory.text(replyText, replyText)),
4000
);
await next();
}
- In the bot.js file, add this function at the end:
const asyncTimeout = async (callback, ms) =>
new Promise((resolve, reject) => {
const timeout = setTimeout(async () => {
if (await callback()) {
resolve(null);
clearTimeout(timeout);
} else {
reject();
clearTimeout(timeout);
}
}, ms);
});
- Run the bot and test in Emulator
Option 2 steps to reproduce the behavior:
- Open the 02.echo-bot sample
- In the bot.js file, change the
this.onMessage
handler to the following:
await context.sendActivity({ type: 'typing' });
await context.sendActivity({ type: 'delay', value: 4000 });
await context.sendActivity({ type: 'message', text: 'Some message' });
- Run the bot and test in Emulator
Expected behavior
The typing indicator should render whenever a delay prevents the next activity from immediately being sent.
Additional context
Presently, Emulator uses an older version of Web Chat which may be a factor. When using an updated instance of Web Chat this behavior is not present.
Additionally, the delay
activity type isn't used or recognized by Web Chat whereas it does appear to be recognized by Emulator. Updating the Web Chat version in Emulator may affect this.
[bug]