2

I am trying to show the "sendTypingIndicator" when the chatBot (Microsoft Bot Framework) is processing any requests. I added sendTypingIndicator: true and sendTyping: true but still it does not show any animation, I searched in Microsoft documentation but i didn't find any specific. This what I have:

window.WebChat.renderWebChat(
        {
          directLine: window.WebChat.createDirectLine({
            token: conversationInfo.token,
          }),
          store: store,
          styleOptions,
          sendTypingIndicator: true,
          sendTyping: true
        },
        document.getElementById("powerVAwebchat")
      );

Is there a way to automatically have the typing animation for all requests or do I have to dynamically add it for each request? Could you guide me to a solution?

thanks

mrbangybang
  • 683
  • 1
  • 9
  • 22
  • I guess you want to see the typing indicator in the web chat, right after you send a message from the web chat to the bot, right? – Miguel Veloso May 04 '21 at 21:15
  • yes, that's right. Sorry if I was not clear enough. – mrbangybang May 04 '21 at 21:32
  • So what you need is the other way around, you have to send the typing indicator FROM the bot. Than config is sending the typing indicator TO the bot. So I'll post an answer now – Miguel Veloso May 04 '21 at 21:48

1 Answers1

1

so what you need is sending a typing activity from the bot when it receives a message request.

There's the ShowTypingMiddleware middleware that does just that.

You just have to add it in the adapter like this:

public class AdapterWithErrorHandler : BotFrameworkHttpAdapter
{
    public AdapterWithErrorHandler(
        IConfiguration configuration,
        ILogger<BotFrameworkHttpAdapter> logger,
        IStorage storage,
        UserState userState,
        ConversationState conversationState)
        : base(configuration, logger)
    {
        Use(new ShowTypingMiddleware());

        //...
    }

}

Just be aware that if the bot replies "fast" you'll not see the typing indicator on the chat. You can always simulate it, for example, adding an await Task.Delay(5000) in the bot.

Miguel Veloso
  • 1,055
  • 10
  • 16
  • Do I understand that this will send the typing indicator from the bot any time there is a delay in the response? I have been manually sending a Typing indicator whenever I was expecting dialog delays. Having something to do it automatically would be great! – billoverton May 05 '21 at 20:11
  • Yes, that's right, you can configure the delay and the repetition lapse in the middleware constructor. With the default values, if the reply takes more than 500 ms it'll send the typing indicator, and then repeat every 2 secs. And then you can delete all those typing indicators elsewhere – Miguel Veloso May 05 '21 at 21:48
  • Behavior seems to be a bit buggy for me. I am seeing typing indicator while waiting for user to respond to prompts. Have you experienced the same? To me it was a bit disconcerting to see the bot "typing" when it was supposed to be waiting for me to answer the prompt. – billoverton May 06 '21 at 15:20
  • Nope , will take a look I haven't used it for a while but that's actually weird. – Miguel Veloso May 07 '21 at 08:08