Skip to content

Typing indicator not rendering while waiting on a delayed activity #2451

Open

Description

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:

  1. Open the 02.echo-bot sample
  2. In the index.js file, add .use(new ShowTypingMiddleware(500, 1000)) to the adapter
  3. 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();
}
  1. 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);
    });
  1. Run the bot and test in Emulator

Option 2 steps to reproduce the behavior:

  1. Open the 02.echo-bot sample
  2. 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' });
  1. 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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    BugYour classic code defect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions