Bot框架网络聊天 阅读更多能力

问题描述 投票:1回答:1

我在Bot框架V4中有一个网络聊天。我从QnA maker得到的回复有时非常大。我想添加一个功能,当我得到一个响应时,我想添加一个阅读更多按钮,并在点击时显示剩余的文本。这可能吗?

botframework web-chat
1个回答
0
投票

我做了下面的方法,它的工作。如果我的代码格式不合适,请原谅。

我钩住了directline事件,然后修改了内容。

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;
                                }
                            }
}
© www.soinside.com 2019 - 2024. All rights reserved.