使用botframework在聊天机器人中发送图片

时间:2016-06-30 12:56:26

标签: azure botframework

我有一个使用微软botframework的聊天机器人,我的webapp在Azure上运行聊天机器人。如何将图片作为消息的答案返回。我们的客户使用Skype,Messenger和KiK

1 个答案:

答案 0 :(得分:1)

查看image and file attachments

上的文档部分
    replyMessage.Attachments.Add(new Attachment()
{
    ContentUrl = "https://upload.wikimedia.org/wikipedia/en/a/a6/Bender_Rodriguez.png",
    ContentType = "image/png"
});

或者作为JSON:

{
    "attachments": [
        {
            "contentType": "image/png",
            "contentUrl": "https://upload.wikimedia.org/wikipedia/en/a/a6/Bender_Rodriguez.png"
        }
    ]
}

您还可以发送Rich Cards:

 replyMessage.Attachments = new List<Attachment>();

replyMessage.Attachments.Add(new Attachment()
{
    Title = "Bender",
    TitleLink = "https://en.wikipedia.org/wiki/Bender_(Futurama)",
    ThumbnailUrl  = "http://www.theoldrobots.com/images62/Bender-18.JPG",
    Text = "Bender Bending Rodríguez, commonly known as Bender, is a main character in the animated television series Futurama.",
    FallbackText = "Bender: http://www.theoldrobots.com/images62/Bender-18.JPG"
});