//Methods for Image Upload public static async Task <List <string> > GetCaptionAsync(Activity activity, ConnectorClient connector, string subscriptionKey, string uriEndPoint) { var imageAttachment = activity.Attachments?.FirstOrDefault(a => a.ContentType.Contains("image")); if (imageAttachment != null) { //if serviceUrl doesn't show in filename var localFileName = imageAttachment.ContentUrl.Replace("[object Promise]", activity.ServiceUrl); using (var stream = await GetImageStream(connector, localFileName)) { return(await OCRService.MakeAnalysisWithImage(stream, subscriptionKey, uriEndPoint)); } } // If we reach here then the activity is neither an image attachment nor an image URL. throw new ArgumentException("The activity doesn't contain a valid image attachment or an image URL."); }