Created
          August 13, 2016 09:09 
        
      - 
      
- 
        Save jfversluis/9cef638839b29b09838abd7d10c73950 to your computer and use it in GitHub Desktop. 
    Detecting and receiving attachments with your Bot
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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