我使用Microsoft Bot Framework并尝试使用作为附件发送到bot的图像来执行HTTP Post。我在Attachment对象中看到了一个ContentURL,但是无法弄清楚如何使用RestSharp将图像发布到我的API?
任何想法?
答案 0 :(得分:0)
这里有几种可能性。
首先将图像作为附件发送。请参阅this documentation您的JSON将如下所示:
{
"type": "message",
"from": {
"id": "12345678",
"name": "sender's name"
},
"conversation": {
"id": "abcd1234",
"name": "conversation's name"
},
"recipient": {
"id": "1234abcd",
"name": "recipient's name"
},
"text": "Here's a picture of the duck I was telling you about.",
"attachments": [
{
"contentType": "image/png",
"contentUrl": "http://aka.ms/Fo983c",
"name": "duck-on-a-rock.jpg"
}
],
"replyToId": "5d5cdc723
}
另一种可能性是您可以在卡片中发送图像(本身有2种可能性)。为此,您可以看到this documentation for rich cards。在这里是一个JSON的例子
{
"type": "message",
"from": {
"id": "12345678",
"name": "sender's name"
},
"conversation": {
"id": "abcd1234",
"name": "conversation's name"
},
"recipient": {
"id": "1234abcd",
"name": "recipient's name"
},
"attachments": [
{
"contentType": "application/vnd.microsoft.card.hero",
"content": {
"title": "title goes here",
"subtitle": "subtitle goes here",
"text": "descriptive text goes here",
"images": [
{
"url": "http://aka.ms/Fo983c",
"alt": "picture of a duck",
"tap": {
"type": "playAudio",
"value": "url to an audio track of a duck call goes here"
}
}
],
"buttons": [
{
"type": "playAudio",
"title": "Duck Call",
"value": "url to an audio track of a duck call goes here"
},
{
"type": "openUrl",
"title": "Watch Video",
"image": "http://aka.ms/Fo983c",
"value": "url goes here of the duck in flight"
}
]
}
}
],
"replyToId": "5d5cdc723"
}
卡的第二个选项是adaptive cards。通过使用visualizer,您可以实际操作JSON并查看它将如何在不同的通道中呈现。