Reputation: 25
I've problems sending attachments through a Skype channel using the bot framework REST API.
I'm able to correctly send images using a json message like this:
{
"type":"message",
"timestamp":"2017-05-22T11:31:36.2281894Z",
"from":{
"name":"MyBot"
},
"recipient":{
"id":"29:1-Dl1xMx6G2qGya5O5BgTZJhc0fUKOiQLctt74CmwJ3PVJNgkocpf3LY626py9UIO"
},
"text":"It works!",
"attachments": [
{
"contentType": "image/jpg",
"contentUrl": "https://g87a2173.ngrok.io/content/attachments/65f2be10-e61e-424e-9ea1-e05f1002fd19",
"name": "image.jpg"
}
]
}
But if I send files with any content type other than image I have an error.
For example, if I send
{
"type":"message",
"timestamp":"2017-05-22T11:31:36.2281894Z",
"from":{
"name":"MyBot"
},
"recipient":{
"id":"29:1-Dl1xMx6G2qGya5O5BgTZJhc0fUKOiQLctt74CmwJ3PVJNgkocpf3LY626py9UIO"
},
"text":"Not working!",
"attachments": [
{
"contentType": "audio/wav",
"contentUrl": "https://g87a2173.ngrok.io/content/attachments/e58bcefa-7060-464f-96ee-78d2795ec80f",
"name": "audio.wav"
}
]
}
I get a 400 error
{
"error": {
"code": "BadArgument",
"message": "Unknown attachment type"
}
}
The rest endpoint used for these tests is https://smba.trafficmanager.net/apis/v3/conversations/29%3A1-Dl1xMx6G2qGya5O5BgTZJhc0fUKOiQLctt74CmwJ3PVJNgkocpf3LY626py9UIO/activities
The API reference documentation states that
An attachment may be a media file (e.g., audio, video, image, file) or a rich card
so where am I wrong?
Thank you
Upvotes: 2
Views: 921
Reputation: 474
The best general solution I've found is to send an Adaptive card with an AdaptiveOpenUrlAction pointing at the URI of the file, like so:
var card = new AdaptiveCard("1.0");
card.Actions.Add(new AdaptiveOpenUrlAction{
Title = "myDocument.docx",
Url = "https://example.com/documents/myDocument.docx"
});
var attachment = new Attachment(AdaptiveCard.ContentType, content:card);
Upvotes: 0
Reputation: 14619
I tried the same with C# code and got the same conclusion: on Skype Channel, we got an Unknown attachment type
exception for this.
Working on emulator and Slack (got a link to download the wav file)
There must be a channel limitation yes, or a bug.
Anyway you may try to use AudioCard
: I tested it (in C# code) and it's working on Skype:
Sample code here: https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/cards-RichCards
Upvotes: 1