【问题标题】:Is there any flag in Webchat that indicate the bot has finished voicing out the message?网络聊天中是否有任何标志表明机器人已经完成了消息的表达?
【发布时间】:2020-06-23 06:59:20
【问题描述】:

我正在尝试在发出欢迎信息后立即启用麦克风。我想知道是否有任何标志表明该消息已由机器人发出。现在,我通过点击方法启用麦克风,超时时间为 4 秒。在某些情况下,当机器人需要时间来初始化和发出消息时,它会失败。因此,在这些情况下,当麦克风打开时,消息会突然停止发出声音。

【问题讨论】:

  • 接受/投票支持更大的 Stack Overflow 社区和任何有类似问题的人。如果您觉得我的回答足够,请“接受”并点赞。如果没有,请告诉我我还能提供哪些帮助!

标签: angular botframework web-chat


【解决方案1】:

如果您使用的是renderWebChat() 风格的网络聊天,那么您仍然可以通过activityMiddleware 等中间件之一使用channelData.speak 属性捕获活动。

useActivities 钩子是一个很好的功能,因为它提供了一个很好的已处理活动包。但是,如果您不能使用该钩子,请按照我上面提到的方法访问它们。请注意,您需要引入自己的处理逻辑来根据需要过滤和缩小范围。

我在上面提到“有可能”这样做,因为我只在标准 html 页面中进行了测试。我还没有在 Angular 项目中测试过这个。

const activityMiddleware = () => next => ( { activity, ...otherArgs } ) => {
  const { channelData } = activity;

  if (channelData && channelData.speak === true || channelData && channelData.speak === false) {
    console.log('MIDDLEWARE ACTIVITY ', activity)
  }

  return next( { activity, ...otherArgs });
}

[ ... ]

window.WebChat.renderWebChat(
  {
    directLine: window.WebChat.createDirectLine( {
      token: token
    } ),
    webSpeechPonyfillFactory: webSpeechPonyfillFactory,
    activityMiddleware: activityMiddleware
  },
  document.getElementById( 'webchat' )
);

【讨论】:

  • 也在 BotFramework-WebChat GitHub repo here 中回答。
猜你喜欢
  • 1970-01-01
  • 2023-03-06
  • 1970-01-01
  • 1970-01-01
  • 2022-01-28
  • 1970-01-01
  • 1970-01-01
  • 2022-01-12
  • 1970-01-01
相关资源
最近更新 更多