public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) { if (turnContext.Activity.Type == ActivityTypes.Message) { ConnectorClient connector = new ConnectorClient(new Uri(turnContext.Activity.ServiceUrl)); var activity = turnContext.Activity; var reply = activity.CreateReply(); var imageAttachment = turnContext.Activity.Attachments?.FirstOrDefault(a => a.ContentType.Contains("image")); if (imageAttachment != null) { //Show typing activity to User await UIHelper.SendTypingMessage(turnContext); Task.Run(async() => { var ocrresult = await OCRHelper.GetCaptionAsync(turnContext.Activity, connector, _subscriptionKey, _uriEndPoint); var ocroutputtext = String.Join(" ", ocrresult.ToArray()); try { // Create Adaptive Card for confirmation view string jsonCardPath = @"Dialogs\Main\Resources\ConfirmMail.json"; var cardAttachment = await UIHelper.CreateAdaptiveCardUserInfo(jsonCardPath, turnContext, ocrresult); reply = turnContext.Activity.CreateReply(); reply.Attachments = new List <Attachment>() { cardAttachment }; await turnContext.SendActivityAsync(reply, cancellationToken).ConfigureAwait(false);; } catch { await turnContext.SendActivityAsync("An error occured during OCR parsing", null, null, cancellationToken); } }).Wait(); } else if (string.IsNullOrEmpty(turnContext.Activity.Text)) { // Check response comes from Adaptive Card Actions dynamic value = turnContext.Activity.Value; string text = value["adaptiveResponse"]; // The property will be named after your text input's ID text = string.IsNullOrEmpty(text) ? "." : text; // In case the text input is empty reply = turnContext.Activity.CreateReply(); reply.Text = text; await turnContext.SendActivityAsync(reply, cancellationToken).ConfigureAwait(false);; } } else if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate) { // Check for user first visit if (turnContext.Activity.MembersAdded != null) { foreach (var member in turnContext.Activity.MembersAdded) { if (member.Id != turnContext.Activity.Recipient.Id) { await turnContext.SendActivityAsync("Welcome to Form Extract Bot. I'm here to help you!"); await UIHelper.SendSuggestedActionsAsync(turnContext, cancellationToken); } } } } }