private async Task <DialogTurnResult> confirmStep(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var _activitySessionId = stepContext.Context.Activity.From.Id; var userCaptcha = stepContext.Context.Activity.Text; object stata = stepContext.ActiveDialog.State["stepIndex"]; if (userCaptcha == captcha) { return(await stepContext.NextAsync(userCaptcha, cancellationToken)); } else { var promptOptions = new PromptOptions { Prompt = MessageFactory.Text("That's not right captcha"), }; //await stepContext.PromptAsync(nameof(TextPrompt), promptOptions, cancellationToken); await stepContext.Context.SendActivityAsync(MessageFactory.Text("That's not right captcha"), cancellationToken); CaptchaResult result = new CaptchaResult(); result = await APIRequest.GetCaptcha(); captcha = result.CaptchaCode; string card = "\\Cards\\artCaptcha.json"; var adaptiveCardJson = File.ReadAllText(Environment.CurrentDirectory + card); adaptiveCardJson = adaptiveCardJson.Replace("{str}", result.CaptchBase64Data); JObject json1 = JObject.Parse(adaptiveCardJson); var adaptiveCardAttachment = new Attachment() { ContentType = "application/vnd.microsoft.card.adaptive", Content = JsonConvert.DeserializeObject(json1.ToString()), }; var cardResponse = MessageFactory.Attachment(adaptiveCardAttachment); await stepContext.Context.SendActivityAsync(cardResponse, cancellationToken); object stata1 = stepContext.ActiveDialog.State["stepIndex"]; return(await stepContext.NextAsync(null, cancellationToken)); //string card = "\\Cards\\artCaptcha.json"; //var adaptiveCardJson = File.ReadAllText(Environment.CurrentDirectory + card); //adaptiveCardJson = adaptiveCardJson.Replace("{str}", result.CaptchBase64Data); //var adaptiveCardAttachment = new Attachment() //{ // ContentType = "application/vnd.microsoft.card.adaptive", // Content = JsonConvert.DeserializeObject(adaptiveCardJson.ToString()), //}; //if (!string.IsNullOrWhiteSpace(card)) //{ // return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)MessageFactory.Attachment(adaptiveCardAttachment) }, cancellationToken); //} //return await stepContext.NextAsync(captcha, cancellationToken); } }
private async Task <DialogTurnResult> apiCallStep2(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var sessionModelsAccessors = UserState1.CreateProperty <SessionModel>(nameof(SessionModel)); var sessionModels = await sessionModelsAccessors.GetAsync(stepContext.Parent.Context, () => new SessionModel()); //CaptchaResult result = new CaptchaResult(); //result = await APIRequest.GetCaptcha(); //string card = "\\Cards\\artCaptcha.json"; //var adaptiveCardJson = File.ReadAllText(Environment.CurrentDirectory + card); //adaptiveCardJson = adaptiveCardJson.Replace("{str}", result.CaptchBase64Data); //JObject json = JObject.Parse(adaptiveCardJson); //var adaptiveCardAttachment = new Attachment() //{ // ContentType = "application/vnd.microsoft.card.adaptive", // Content = JsonConvert.DeserializeObject(json.ToString()), //}; //var cardResponse = MessageFactory.Attachment(adaptiveCardAttachment); //await stepContext.Context.SendActivityAsync(cardResponse, cancellationToken); //return await stepContext.EndDialogAsync(); if ((string)stepContext.Result == "true") { var _activitySessionId = stepContext.Context.Activity.From.Id; var textReq = stepContext.Context.Activity.Text; object stata = stepContext.ActiveDialog.State["stepIndex"]; CaptchaResult result = new CaptchaResult(); result = await APIRequest.GetCaptcha(); captcha = result.CaptchaCode; string card = "\\Cards\\artCaptcha.json"; var adaptiveCardJson = File.ReadAllText(Environment.CurrentDirectory + card); adaptiveCardJson = adaptiveCardJson.Replace("{str}", result.CaptchBase64Data); JObject json = JObject.Parse(adaptiveCardJson); var adaptiveCardAttachment = new Attachment() { ContentType = "application/vnd.microsoft.card.adaptive", Content = JsonConvert.DeserializeObject(json.ToString()), }; var cardResponse = MessageFactory.Attachment(adaptiveCardAttachment); await stepContext.Context.SendActivityAsync(cardResponse, cancellationToken); object stata1 = stepContext.ActiveDialog.State["stepIndex"]; return(await stepContext.NextAsync(captcha, cancellationToken)); } else { var _activitySessionId = stepContext.Context.Activity.From.Id; var textReq = stepContext.Context.Activity.Text; //var sessionModelsAccessors = UserState1.CreateProperty<SessionModel>(nameof(SessionModel)); //var sessionModels = await sessionModelsAccessors.GetAsync(stepContext.Parent.Context, () => new SessionModel()); string EmailId = sessionModels.EmailId; LoginUserID = sessionModels.UserID; var otpDetails = (ArtOTP)stepContext.Options; string response = string.Empty; string json = "{\"UserID\":\"{UserID}\",\"Password\":\"null\",\"Activity\":\"AccountUnlock\",\"sessionId\":\"{sessionId}\",\"sourceorigin\":\"1\",\"MobileNumber\":\"null\",\"QuestionAnswerModelList\":\"null\"}"; json = json.Replace("{UserID}", LoginUserID).Replace("{sessionId}", stepContext.Context.Activity.From.Id); response = await APIRequest.ValidateUserID(json); object stata = stepContext.ActiveDialog.State["stepIndex"]; if (response == "true") { CaptchaResult result = new CaptchaResult(); result = await APIRequest.GetCaptcha(); captcha = result.CaptchaCode; string card = "\\Cards\\artCaptcha.json"; var adaptiveCardJson = File.ReadAllText(Environment.CurrentDirectory + card); adaptiveCardJson = adaptiveCardJson.Replace("{str}", result.CaptchBase64Data); JObject json1 = JObject.Parse(adaptiveCardJson); var adaptiveCardAttachment = new Attachment() { ContentType = "application/vnd.microsoft.card.adaptive", Content = JsonConvert.DeserializeObject(json1.ToString()), }; var cardResponse = MessageFactory.Attachment(adaptiveCardAttachment); await stepContext.Context.SendActivityAsync(cardResponse, cancellationToken); return(await stepContext.NextAsync(captcha, cancellationToken)); } else if (response.Replace("\"", "") == "Invalid Userid. Please try with correct userid.") { var promptOptions = new PromptOptions { Prompt = MessageFactory.Text("Hmm… I didn't find an account with the email address: ${EmailId}. Try again or ask to speak to a live agent") }; return(await stepContext.PromptAsync(nameof(TextPrompt), promptOptions, cancellationToken)); } else if (response.Replace("\"", "") == "User not enrolled in ART. Please do enroll before proceeding to Unlock/Reset.") { var artUserNotEnrolled = CreateAdaptiveCardAttachment("CoreBot.Cards.artUserNotEnrolled.json"); var cardResponse = MessageFactory.Attachment(artUserNotEnrolled); await stepContext.Context.SendActivityAsync(cardResponse, cancellationToken); return(await stepContext.EndDialogAsync(response, cancellationToken)); } else if (response.Replace("\"", "") == "User account is not locked.") { //artAccountNotLock var artAccountNotLock = CreateAdaptiveCardAttachment("CoreBot.Cards.artAccountNotLock.json"); var cardResponse = MessageFactory.Attachment(artAccountNotLock); await stepContext.Context.SendActivityAsync(cardResponse, cancellationToken); return(await stepContext.EndDialogAsync(response, cancellationToken)); } else { await stepContext.Context.SendActivityAsync(troubleText); var artAccountNotLock = CreateAdaptiveCardAttachment("CoreBot.Cards.artTroubleAccount.json"); var cardResponse = MessageFactory.Attachment(artAccountNotLock); await stepContext.Context.SendActivityAsync(cardResponse, cancellationToken); return(await stepContext.EndDialogAsync("false", cancellationToken)); } } }