Bot Builder v4:SendActivityAsync() 中的 'BadRequest'
Bot Builder v4: 'BadRequest' in SendActivityAsync()
我有一个基于 Echo 机器人(csharp_dotnetcore 示例)的机器人,运行 并且可以从 Teams 客户端访问。
我试图在 'echo' 之后发送一张简单的卡片(来自 Cards Bot),但我收到 'BadRequest' 错误...
有什么问题吗?
我的代码:
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
// OK
await turnContext.SendActivityAsync(MessageFactory.Text($"Echo1: {turnContext.Activity.Text}"), cancellationToken);
// 'BAD REQUEST'
var attachments = new List<Attachment>();
var message = MessageFactory.Attachment(attachments);
message.Attachments.Add(GetAnimationCard().ToAttachment());
await turnContext.SendActivityAsync(message, cancellationToken);
}
public static AnimationCard GetAnimationCard()
{
var animationCard = new AnimationCard
{
Title = "Microsoft Bot Framework",
Subtitle = "Animation Card",
Image = new ThumbnailUrl
{
Url = "https://docs.microsoft.com/en-us/bot-framework/media/how-it-works/architecture-resize.png",
},
Media = new List<MediaUrl>
{
new MediaUrl()
{
Url = "http://i.giphy.com/Ki55RUbOV5njy.gif",
},
},
};
return animationCard;
}
谢谢,
迭戈
Animation
card
is not supported in Teams. Please take a look at Card
Reference
for supported cards in teams.
我有一个基于 Echo 机器人(csharp_dotnetcore 示例)的机器人,运行 并且可以从 Teams 客户端访问。 我试图在 'echo' 之后发送一张简单的卡片(来自 Cards Bot),但我收到 'BadRequest' 错误... 有什么问题吗?
我的代码:
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
// OK
await turnContext.SendActivityAsync(MessageFactory.Text($"Echo1: {turnContext.Activity.Text}"), cancellationToken);
// 'BAD REQUEST'
var attachments = new List<Attachment>();
var message = MessageFactory.Attachment(attachments);
message.Attachments.Add(GetAnimationCard().ToAttachment());
await turnContext.SendActivityAsync(message, cancellationToken);
}
public static AnimationCard GetAnimationCard()
{
var animationCard = new AnimationCard
{
Title = "Microsoft Bot Framework",
Subtitle = "Animation Card",
Image = new ThumbnailUrl
{
Url = "https://docs.microsoft.com/en-us/bot-framework/media/how-it-works/architecture-resize.png",
},
Media = new List<MediaUrl>
{
new MediaUrl()
{
Url = "http://i.giphy.com/Ki55RUbOV5njy.gif",
},
},
};
return animationCard;
}
谢谢,
迭戈
Animation card is not supported in Teams. Please take a look at Card Reference for supported cards in teams.