繁体   English   中英

聊天机器人-我可以在Microsoft机器人框架和机器人构建器中使用node.js显示html内容

[英]Chat bot-Can I display html content using node.js in Microsoft bot framework & bot builder

我正在使用node.js在azure上开发一个聊天机器人。 这是一个数据可视化机器人,它使用d3库以html格式生成图表并显示给用户。 看来Microsoft Bot Builder不支持html格式。 但是我已经浏览了以下链接: https : //blog.botframework.com/2017/09/07/html-not-supported-web-chat/它说有一种方法可以启用html内容:“如果HTML呈现“ Web聊天”中的“ Web聊天”是您应用程序的一项重要功能,您可以从GitHub克隆或派生Web聊天源代码的副本,并在您自己的自定义Web聊天客户端上启用它。” 我试图克隆该文件,并将'html:false'更改为'html:true'。 但这不起作用。

谁能告诉我该怎么办? 真的很感激!!!

根据您尝试可视化的数据,您可能可以使用Google图片图表之类的服务: https : //developers.google.com/chart/image/docs/chart_playground

使用此服务,并使用以下代码:

// attach the card to the reply message
var msg = new builder.Message(session).addAttachment(createHeroCard(session));
session.send(msg);


function createHeroCard(session) {
            return new builder.HeroCard(session)
                .title('Months with Numbers Bar Chart')
                .subtitle('Using a Chart as Image service...')
                .text('Build and connect intelligent bots that have charts rendered as images.')
                .images([
                    builder.CardImage.create(session, 'http://chart.googleapis.com/chart?cht=bvg&chs=250x150&chd=s:Monkeys&chxt=x,y&chxl=0:|Jan|Feb|Mar|Apr|May|Jun|Jul')
                ])
                .buttons([
                    builder.CardAction.openUrl(session, 'https://docs.microsoft.com/bot-framework/', 'Get Started')
                ]);
        }

产生此英雄卡:

英雄卡与图表图像

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM