如何在Microsoft Bot Framework中设置由表单生成的附件的ContentUrl?

时间:2016-06-27 04:48:30

标签: c# botframework facebook-messenger botbuilder

我想在Facebook Messenger上发送带有按钮的旋转木马。

如何设置Microsoft Bot Framework中表单生成的附件 ContentUrl ContentType

我可以在创建Message对象时手动执行此操作:

C# Code, JSON Response and Messenger

var reply = message.CreateReplyMessage();
reply.Attachments = new List<Attachment>();

var actions = new List<Microsoft.Bot.Connector.Action>();

actions.Add(new Microsoft.Bot.Connector.Action
{
    Title = "Small",
    Image = @"https://upload.wikimedia.org/wikipedia/en/a/a6/Bender_Rodriguez.png",
    Message = "Small"
});

actions.Add(new Microsoft.Bot.Connector.Action
{
    Title = "Large",
    Image = @"https://upload.wikimedia.org/wikipedia/en/a/a6/Bender_Rodriguez.png",
    Message = "Large"
});

reply.Attachments.Add(new Attachment
{
    Title = "Flat White",
    Actions = actions,
    ContentUrl = @"http://imgur.com/XbCCntC.png",
    ContentType = "image/png"
});

但是在使用表格时我不知道该怎么做。我可以使用 DescribeAttribute 来设置Action的Image URL,它显示在JSON响应中。

但是这不会显示/显示任何内容,我认为图像需要成为Attachment对象的一部分,而不是Action。

Partial C# Code, JSON Response and Messenger

public enum WhiteStyle
{
    Invalid = 0,
    [Describe(Image = @"http://imgur.com/XbCCntC.png")]
    FlatWhite,
    [Describe(Image = @"http://imgur.com/qbbi6yc.png")]
    Latte,
    [Describe(Image = @"http://imgur.com/sF95Vsc.png")]
    Cappuccino
}

0 个答案:

没有答案