【问题标题】:Bot Framework Web Chat Read More abilityBot Framework 网络聊天阅读更多功能
【发布时间】:2020-04-05 09:54:00
【问题描述】:

我在 Bot 框架 V4 中有一个网络聊天。我从 QnA 制造商那里得到的回应有时非常大。我想放置一个功能,这样当我收到回复时,我想添加一个阅读更多按钮,然后单击显示剩余的文本。有可能吗?

【问题讨论】:

  • 欢迎来到 Stack Overflow。你能告诉我们你到目前为止做了什么吗?
  • 你还在做这个吗?
  • 您好,很抱歉回复延迟。是的,我正在努力。我找到了解决方案。我将文本拆分为 300 个字符并将它们放入一个数组中。点击阅读更多。我显示了它们中的每一个,直到数组为空。猜猜它的工作原理..
  • 你想把它作为答案发布吗?
  • 等等,你还在努力还是找到了解决方案?

标签: botframework web-chat


【解决方案1】:

我做了下面的方法,它奏效了。如果不正确,请原谅我的代码格式。

我钩了直达事件,然后修改了内容

if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') 
{
    if (action.payload.activity.text != null && action.payload.activity.text != "") 
    {
                                if (action.payload.activity.text.length > showChar) {

                                    var content = action.payload.activity.text;
                                    var additionalIndex = content.substring(showChar).indexOf(".");
                                    var c = content.substring(0, (showChar + additionalIndex)).trim();
                                    var h = content.substr((showChar + additionalIndex) + 1, content.length).trim();
                                    var moretext = "Read More";
                                    var html = c + '<a class="ac-pushButton style-default" style="color:blue;text-decoration:underline;cursor:pointer;" onclick=\'showMore(' + JSON.stringify(h) + ', this) \'>' + moretext + '</a>';
                                    action.payload.activity.text = html;
                                }
                            }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多