3

I'm using the following code to display a gif image as an attachment in my reply:

    Activity replyToConversation = (Activity)context.MakeMessage();
    replyToConversation.Attachments = new List<Attachment>();
    replyToConversation.Attachments.Add(new Attachment()
    {
       ContentUrl = "http://i.giphy.com/p3BDz27c5RlIs.gif",
       ContentType = "image/gif"
    });

    await context.PostAsync(replyToConversation);
    context.Wait(MessageReceivedAsync);

In the Web Chat channel it displays (and play) as expected, but for some reason it displays as a static image in the Microsoft Teams channel.

Please, any ideas?

MVZ
  • 111
  • 1
  • 8
  • Channels are very variable about what they support: you could use an [animated GIF card](https://docs.botframework.com/en-us/core-concepts/reference/#animationcard) though. – stuartd Dec 21 '16 at 14:13
  • @stuartd, do you have any example in how to implement an animated Card? I was trying to implement it, but couldn't find any ToAttachment method. – MVZ Dec 21 '16 at 15:56
  • I haven't used them myself, but this compiles: `reply.Attachments.Add(new AnimationCard { Title = "Title", Subtitle = "Subtitle", Text = "Text", Media = new List { new MediaUrl { Url = "Gif URL"} } }.ToAttachment());` – stuartd Dec 21 '16 at 16:02

2 Answers2

4

As a workaround you can return an HTML string nesting the image

 await context.PostAsync($"<img src=\"{imageUrl}\" />");
Michael C
  • 99
  • 1
  • 2
  • This should be the accepted answer. I inspected the HTML for a card containing a gif link, and it's currently using an svg. Replacing it with the img tag works like a charm. I can't believe this isn't supported...it works if you just let HTML5 and the browser do the work! – Aaron Mar 12 '19 at 01:07
2

Sorry, Bots in Teams currently don't support animated GIFs, inline or in cards. See the MSDN documentation for the subset of functionality currently supported

  • Still current as of today. https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/cards/cards-reference – Luis Cantero Oct 18 '18 at 12:44
  • It really is a joke, Teams is not a patch on Slack. No wonder Teams has flopped and there is talk of it getting canned by Microsoft. Just stick with Slack, it works. Even basic WebHooks from DevTestLabs does not work when sent to Teams, and Microsoft say its our problem then requested us to create a Azure service to fix it for them. https://hackernoon.com/why-microsoft-teams-flopped-and-what-it-means-for-slack-cb2bbfa53963 – Microsoft Developer Nov 30 '18 at 10:23