是否可以通过 Microsoft Bot Framework 自定义 Teams 中接收到的图像和 GIF 的大小
Is it possible to customize the size of received images and GIFs in Teams via Microsoft Bot Framework
我正在尝试让我的机器人通过团队向用户发送图像。我可以使用自适应卡和 activity + 附件来做到这一点。它运行良好,但我希望能够更改返回的图像框的大小。我看到自适应卡片中的图像功能上有一个 "size" 属性,但这只会改变图像的大小,而不是发送回团队的框。一个例子可以在这里看到:
这是我添加图片的方式:
var happyBot = "https://i.imgur.com/W7tHV41.gif";
var botActivity = stepContext.Context.Activity.CreateReply();
botActivity.AddHappyBotAttachment(happyBot);
await stepContext.Context.SendActivityAsync(botActivity, cancellationToken);
public static void AddHappyBotAttachment(this Activity activity, string videoUrl)
{
activity.Attachments = new List<Attachment>() { CreateHappyBotAttachment(videoUrl) };
}
private static Attachment CreateHappyBotAttachment(string videoUrl)
{
var adaptiveCard = File.ReadAllText($@"{System.Environment.CurrentDirectory}\Dialogs\HappyBot.json");
adaptiveCard = adaptiveCard.Replace("URL", videoUrl);
return new Attachment
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveCard),
};
}
HappyBot.json:
{
"type": "AdaptiveCard",
"body": [
{
"type": "Container",
"items": [
{
"type": "Image",
"horizontalAlignment": "Center",
"spacing": "Large",
"url": "URL",
"size":"small"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
有没有更好的方法让我的机器人向用户发送图像?或者是否可以调整返回的自适应卡盒的大小?感谢任何帮助。
我正在尝试让我的机器人通过团队向用户发送图像。我可以使用自适应卡和 activity + 附件来做到这一点。它运行良好,但我希望能够更改返回的图像框的大小。我看到自适应卡片中的图像功能上有一个 "size" 属性,但这只会改变图像的大小,而不是发送回团队的框。一个例子可以在这里看到:
这是我添加图片的方式:
var happyBot = "https://i.imgur.com/W7tHV41.gif";
var botActivity = stepContext.Context.Activity.CreateReply();
botActivity.AddHappyBotAttachment(happyBot);
await stepContext.Context.SendActivityAsync(botActivity, cancellationToken);
public static void AddHappyBotAttachment(this Activity activity, string videoUrl)
{
activity.Attachments = new List<Attachment>() { CreateHappyBotAttachment(videoUrl) };
}
private static Attachment CreateHappyBotAttachment(string videoUrl)
{
var adaptiveCard = File.ReadAllText($@"{System.Environment.CurrentDirectory}\Dialogs\HappyBot.json");
adaptiveCard = adaptiveCard.Replace("URL", videoUrl);
return new Attachment
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveCard),
};
}
HappyBot.json:
{
"type": "AdaptiveCard",
"body": [
{
"type": "Container",
"items": [
{
"type": "Image",
"horizontalAlignment": "Center",
"spacing": "Large",
"url": "URL",
"size":"small"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}
有没有更好的方法让我的机器人向用户发送图像?或者是否可以调整返回的自适应卡盒的大小?感谢任何帮助。