Skip to content

Instantly share code, notes, and snippets.

@jfversluis
Created August 13, 2016 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfversluis/9cef638839b29b09838abd7d10c73950 to your computer and use it in GitHub Desktop.
Save jfversluis/9cef638839b29b09838abd7d10c73950 to your computer and use it in GitHub Desktop.
Detecting and receiving attachments with your Bot
if (activity.Attachments?.Count() > 0)
{
var imageCount = activity.Attachments.Count(a => a.ContentType.Contains("image"));
if (imageCount > 0)
{
// Notify user that we got something
var message = imageCount == 1 ? $"You've sent 1 image" : $"You've sent {imageCount} images";
var imageReply = activity.CreateReply(message);
await connector.Conversations.ReplyToActivityAsync(imageReply);
}
foreach (var attachment in activity.Attachments.Where(a => a.ContentType.Contains("image")))
{
// ... Handle your attachment here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment