![](/img/trans.png)
[英]ContinueDialogAsync does not work when I use the input form of adaptive-cards in the waterfall dialog
[英]How to customize Adaptive-Cards in WebChat?
这个问题是我之前问题的延伸。 ( 如何将“AdaptiveActionSet”放入“AdaptiveColumn”? )
当时我对自适应卡片和WebChat.html文件的定制了解不多。
上图是我想要的自适应卡的布局。 右侧的 Reserve 按钮是 Action.OpenUrl 按钮。
要放置这样的按钮,我需要在列中放置一个 ActionSet。 但是,典型的自适应卡片不会像上图那样在列中显示 ActionSet。 内容类型如下所示。 ContentType = "application/vnd.microsoft.card.adaptive"
(在网络聊天中)
为了解决这个问题,我必须自定义自适应卡片,但我不确定如何。
(惭愧,我参考了下面的链接,但仍然无法自定义卡片。
Bot Connector 服务未使用最新的自适应卡 #87
你能告诉我解决这个问题的方法或展示一个简单的自定义卡片示例吗? 请。
下面是我写的代码。
我的自适应卡片代码:
card.Body.Add(new AdaptiveColumnSet()
{
Columns = new List<AdaptiveColumn>()
{
new AdaptiveColumn()
{
//(~Date, No problem)
},
new AdaptiveColumn()
{
//(~Price, No problem)
},
new AdaptiveColumn()
{
Items =
{
new AdaptiveActionSet()
{
Actions =
{
new AdaptiveOpenUrlAction()
{
Url = new Uri("https://www.SomeUrl.com"),
Title = "Reserve",
Style = "positive",
}
}
}
},
Width = "auto",
}
},
});
var reply = turnContext.Activity.CreateReply();
reply.Attachments = new List<Attachment>
{
new Attachment()
{
ContentType = "application/vnd.microsoft.card.custom",
Content = card
}
};
我的 webChat.html :
const attachmentMiddleware = () => next => card => {
if (card.attachment.contentype === 'application/vnd.microsoft.card.custom'){
card.attachment.contentType = 'application/vnd.microsoft.card.adaptive'
}
return next(card)
};
window.WebChat.renderWebChat({
directLine: botConnection,
styleOptions,
adaptiveCardHostConfig,
attachmentMiddleware
}, document.getElementById('webchat'));
document.querySelector('#webchat > *').focus();
如上, ContentType = "application/vnd.microsoft.card.custom"
如果我将自定义分配给 contentType,
我收到一个名为 No renderer 的错误。
使用 AdaptiveColumn 的 SelectAction 解决了这个问题。 它通过一起使用 AdaptiveTextBlock 和 SelectAction 并指定宽度。
前任)
Items =
{
new AdaptiveTextBlock()
{
HorizontalAlignment = AdaptiveHorizontalAlignment.Center,
Color = AdaptiveTextColor.Light,
Text = "Reserve",
Weight = AdaptiveTextWeight.Bolder,
}
},
SelectAction = new AdaptiveOpenUrlAction()
{
Url = new Uri($"{someurl}"),
Title = "rsv",
Id = "bb" + cnt,
},
Width = "50px"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.