本文介绍了如何使用 React.js 在 Botframework v4 聊天应用程序中执行发送“打字指示符"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个使用 botframework v4 的聊天应用程序,前端使用 React.js,后端使用 .net core 来生成令牌.我想使用 react 在我的聊天中实现打字……"指示器.尝试使用

I'm building a chat application using botframework v4 with React.js as front-end and .net core as back-end to generate token. I want to implement "Typing.." indicator to my chat using react. Tried using

  window.WebChat.renderWebChat({
  directLine: window.WebChat.createDirectLine({ token }),

  sendTypingIndicator: true,

  }, document.getElementById('webchat'));

https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/05.custom-components/b.send-typing-indicator但它没有用.正在为此寻找解决方案.

as mentioned in https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/05.custom-components/b.send-typing-indicator but it didn't worked. Looking for a solution for this.

推荐答案

通过启用 sendTypingIndicator,您可以将输入事件从用户发送到您的机器人.看起来你想反其道而行之.

By enabling sendTypingIndicator you are sending typing events from the user to your bot. It looks like you would like to do it the other way around.

通过发送类型为 ActivityTypes.Typing(打字)的活动,您将在网络聊天(或其他支持的渠道)中触发打字指示器.延迟活动是可选的,但可用于确保消息不会立即发送.

By sending an activity of the type ActivityTypes.Typing (typing), you will trigger a typing indicator in the WebChat (or other supported channels). The delay activity is optional, but could be used to make sure the message isn't send instantly.

await turnContext.SendActivitiesAsync(
            new Activity[] {
                new Activity { Type = ActivityTypes.Typing },
                new Activity { Type = "delay", Value= 3000 },
                MessageFactory.Text("Finished typing", "Finished typing"),
            },
            cancellationToken);

来源:发送打字指示

这篇关于如何使用 React.js 在 Botframework v4 聊天应用程序中执行发送“打字指示符"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 21:01