private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var option = stepContext.Result.ToString(); var promptOption = new PromptOption(); var processDetails = (ProcessDetails)stepContext.Options; try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "mainMenu") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } option = promptOption.Value; } if (option.ToLower() == "main menu" || option.ToLower() == "m" || option.ToLower() == "menu") { return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); }
private async Task <DialogTurnResult> LastStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var processDetails = (ProcessDetails)stepContext.Options; processDetails.Action = "typed"; var result = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Confirm" && promptOption.Id != "rpaSuport") { processDetails.Action = "pastMenu"; //return await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken); } result = promptOption.Value; } if (result == "*****@*****.**" || result.ToLower() == "no" || result.ToLower() == "n") { processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } return(await stepContext.ReplaceDialogAsync(nameof(SupportDialog), processDetails, cancellationToken)); }
protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken) { var commands = new Commands(); var startCommands = commands.GetStartCommands(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(turnContext.Activity.Text); } catch (Exception) {} if (!string.IsNullOrEmpty(promptOption.Value)) { if (startCommands.Contains(promptOption.Value.ToLower())) { AddConversationReference(turnContext.Activity as Activity); } } else { if (startCommands.Contains(turnContext.Activity.Text.ToLower())) { AddConversationReference(turnContext.Activity as Activity); } } Logger.LogInformation("Running dialog with Message Activity."); // Run the Dialog with the new message Activity. await Dialog.RunAsync(turnContext, ConversationState.CreateProperty <DialogState>("DialogState"), cancellationToken); }
private async Task <DialogTurnResult> ContinueStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var rpaService = new RPAService(); var processDetails = this.processDetails; processDetails.Action = string.Empty; var option = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Confirm" && promptOption.Id != "mainMenu" && promptOption.Id != "FinalStep" && promptOption.Id != "rpaSuport") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } option = promptOption.Value; } //if (option.ToLower() == "yes" || option.ToLower() == "y") //{ //return await stepContext.ReplaceDialogAsync(InitialDialogId, processDetails, cancellationToken); /*var value = JsonConvert.SerializeObject(new PromptOption { Id = "rpaSuport", Value = "*****@*****.**" }); * var choices = new List<Choice> * { new Choice * { * Value = "rpaSupport", * Action = new CardAction(ActionTypes.PostBack, "Click Here", null, "Click Here", "openEmail", value: value, null) * } }; * choices.Add(rpaService.GetMainMenuOption()); * * return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions * { * Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, "To Contact RPA Support, click Button below") * * }, cancellationToken);*/ //} if (option.ToLower() == "main menu" || option.ToLower() == "m") { return(await stepContext.ReplaceDialogAsync(InitialDialogId, null, cancellationToken)); } else { return(await stepContext.ReplaceDialogAsync(InitialDialogId, processDetails, cancellationToken)); } }
private async Task <DialogTurnResult> SelectedBotsStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var processDetails = (ProcessDetails)stepContext.Options; var result = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Confirm") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } result = promptOption.Value; } foreach (var r in processDetails.ProcessSelected.Releases) { if (r.robots.Count > 1) { foreach (var b in r.robots) { if (b.id == processDetails.ProcessSelected.Bot.id) { b.Shown = true; if (result.ToLower() == "yes" || result.ToLower() == "y") { b.Selected = true; processDetails.ProcessSelected.Bot.Selected = true; } } } } } return(await stepContext.ReplaceDialogAsync(nameof(RobotsDialog), processDetails, cancellationToken)); }
private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var processDetails = new ProcessDetails(); if (stepContext.Result != null) { var action = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "mainIntro") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } action = promptOption.Value; } //if (stepContext.Result.GetType() == typeof(FoundChoice)) //{ //var action = (FoundChoice)stepContext.Result; if (action.ToLower() == "yes" || action.ToLower() == "y") { //set rpa for LUIS to recognize it as RAP intent, and show the list of actions again stepContext.Context.Activity.Text = "rpa"; } //} //} /*if (action == "No") * { * return await stepContext.ReplaceDialogAsync(nameof(EndConversationDialog), processDetails, cancellationToken); * }*/ } return(await RecognizeText(stepContext, cancellationToken)); }
void Update() { //handle option selection input if (Input.GetKeyDown(KeyCode.UpArrow)) { //select previous option (if possible) currentOptionIndex = Mathf.Max(currentOptionIndex - 1, 0); } else if (Input.GetKeyDown(KeyCode.DownArrow)) { //select next option (if possible) currentOptionIndex = Mathf.Min(currentOptionIndex + 1, currentPrompt.promptOptions.Length - 1); } else if (Input.GetKeyDown(KeyCode.Return)) { //change the strings to the one referred to by this option PromptOption option = currentPrompt.promptOptions[currentOptionIndex]; SetCurrentPrompt(option.optionPrompt); } //modify appearance of option text if selected (or not) for (int i = 0; i < scenePromptOptions.transform.childCount; i++) { Transform child = scenePromptOptions.transform.GetChild(i); Text childText = child.GetComponent <Text>(); if (i == currentOptionIndex) { childText.color = Color.green; } else { childText.color = Color.white; } } }
private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var processDetails = (ProcessDetails)stepContext.Options; var action = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Confirm" && promptOption.Id != "rpaSuport") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } action = promptOption.Value; } switch (action.ToLower()) { case "yes": case "y": return(await stepContext.ReplaceDialogAsync(nameof(StartProcessDialog), processDetails, cancellationToken)); case "*****@*****.**": case "no": case "n": processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); default: processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } }
private async Task <DialogTurnResult> StartAnotherProcessStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var processDetails = (ProcessDetails)stepContext.Options; var action = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Confirm") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } action = promptOption.Value; } if (action.ToLower() == "yes" || action.ToLower() == "y") { //start StartProcessDialog Dialog return(await stepContext.ReplaceDialogAsync(nameof(StartProcessDialog), processDetails, cancellationToken)); } else if (action.ToLower() == "no" || action.ToLower() == "n") //go back to main Dialog { processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } else //go back to main Dialog with null { processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } }
private async Task <DialogTurnResult> LastStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var processDetails = (ProcessDetails)stepContext.Options; processDetails.Action = "typed"; var result = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Confirm") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } result = promptOption.Value; } if (result == "button") { processDetails.Action = string.Empty; return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Welcome back!" + Environment.NewLine + "Type " + '"' + "Menu" + '"' + " for available options.") }, cancellationToken)); } else if (result.ToLower() == "no" || result.ToLower() == "n") { processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } return(await stepContext.ReplaceDialogAsync(nameof(EndConversationDialog), processDetails, cancellationToken)); }
private async Task <DialogTurnResult> ConfirmStopProcessStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var rpaService = new RPAService(); var processDetails = (ProcessDetails)stepContext.Options; var result = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "availableProcesses" && promptOption.Id != "rpaSuport") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } result = promptOption.Value; } var response = rpaService.GetUser(stepContext.Context.Activity.Conversation.Id); var user = new List <User>(); if (response.IsSuccess) { user = JsonConvert.DeserializeObject <List <User> >(response.Content); } //var _user = await _userAccessor.GetAsync(stepContext.Context, () => new User(), cancellationToken); switch (result.ToLower()) { case "load_more": processDetails.LoadMore = true; return(await stepContext.ReplaceDialogAsync(nameof(StopProcessDialog), processDetails, cancellationToken)); case "*****@*****.**": //save index user[0].u_last_index = "0"; rpaService.UpdateUser(user[0], stepContext.Context.Activity.Conversation.Id); //_user.u_last_index = 0; //await _userAccessor.SetAsync(stepContext.Context, _user, cancellationToken); processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); default: processDetails.ProcessSelected = rpaService.GetSelectedProcess(processDetails.Processes, result); if (!string.IsNullOrEmpty(processDetails.ProcessSelected.Sys_id)) { //save index user[0].u_last_index = "0"; rpaService.UpdateUser(user[0], stepContext.Context.Activity.Conversation.Id); //_user.u_last_index = 0; //await _userAccessor.SetAsync(stepContext.Context, _user, cancellationToken); var choices = rpaService.GetConfirmChoices(); return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, "You have selected " + processDetails.ProcessSelected.Name + ". Stop this process?") /*Prompt = MessageFactory.Text("You have selected " + processDetails.ProcessSelected.Name + ". Stop this process?"), * Choices = ChoiceFactory.ToChoices(new List<string> { "Yes", "No" })*/ }, cancellationToken)); } else { return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } } }
private async Task <DialogTurnResult> StartProcessStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var processDetails = (ProcessDetails)stepContext.Options; var result = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) {} if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Confirm") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } result = promptOption.Value; } if (result.ToLower() == "yes" || result.ToLower() == "y") { var rpaService = new RPAService(); //save activity id for when process finish var activityId = stepContext.Context.Activity.Id; //check if the process can start if (processDetails.ProcessSelected.LastRun.State == "Faulted" || processDetails.ProcessSelected.LastRun.State == "Successful" || processDetails.ProcessSelected.LastRun.State == "Stopped" || string.IsNullOrEmpty(processDetails.ProcessSelected.LastRun.State)) { //check if has asset var assetsWithValueFromChild = rpaService.HasAnyAsset(processDetails.ProcessSelected); if (assetsWithValueFromChild.Count > 0) { var response = rpaService.MakeAssetFromChild(assetsWithValueFromChild); if (response.Body != "Success") { var choices = new List <Choice>(); var rpaOption = rpaService.GetMainMenuOption(); if (response.MissingAsset) { //create incident var incident = rpaService.CreateRPAIncident(processDetails.ProcessSelected); var incidentValue = JsonConvert.SerializeObject(new PromptOption { Id = "incident", Value = "bam?id=rpa_request&table=u_robot_incident&sys_id=" + incident.Sys_Id }); choices = new List <Choice> { new Choice { Value = "bam?id=rpa_request&table=u_robot_incident&sys_id=" + incident.Sys_Id, Action = new CardAction(ActionTypes.PostBack, incident.Number, null, incident.Number, "openUrl", value: incidentValue, null) } }; choices.Add(rpaOption); return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, "Process " + processDetails.ProcessSelected.Name + " requires an asset associated to your user, an incident has been opened to RPA Support." + Environment.NewLine + "Click incident number below to open it") }, cancellationToken)); } else { var assetValue = JsonConvert.SerializeObject(new PromptOption { Id = "asset", Value = "bam?id=rpa_process_assets&process=" + processDetails.ProcessSelected.Sys_id }); choices = new List <Choice> { new Choice { Value = "bam?id=rpa_process_assets&process=" + processDetails.ProcessSelected.Sys_id, Action = new CardAction(ActionTypes.PostBack, "Update Asset", null, "Update Asset", "openUrl", value: assetValue, null) } }; choices.Add(rpaOption); //send the user to SN UI page return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, response.Body + Environment.NewLine + "Please enter them before running the process by pressing Update Asset button below.") }, cancellationToken)); } } } if (processDetails.ProcessSelected.Releases.Any(r => r.robots.Count > 1)) { processDetails.ProcessSelected.FirstBot = true; return(await stepContext.ReplaceDialogAsync(nameof(RobotsDialog), processDetails, cancellationToken)); } //check if process need params else if (processDetails.ProcessSelected.Releases.Any(r => r.parameters_required == true)) { //set all params for this conversation to false(maybe was interrupted by a notification) rpaService.DeactivatedConversationFlow(string.Empty, stepContext.Context.Activity.Conversation.Id); rpaService.SaveConversationFlow(processDetails.ProcessSelected, stepContext.Context.Activity.Conversation.Id); return(await stepContext.ReplaceDialogAsync(nameof(ParametersProcessDialog), processDetails, cancellationToken)); } else { return(await stepContext.ReplaceDialogAsync(nameof(StartProcessSharedDialog), processDetails, cancellationToken)); } } else { processDetails.Action = "error"; processDetails.Error = "Cannot start " + processDetails.ProcessSelected.Name + " because the process is already running."; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } } else if (result.ToLower() == "no" || result.ToLower() == "n") //when no is selected { processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } else //when something is typed { processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (pausedPrefab != null) { if (!isPaused) { isPaused = true; pausedScreen = Instantiate(pausedPrefab, new Vector3(0, 0, 100f), gameObject.transform.rotation); Time.timeScale = 0; Time.fixedDeltaTime = 0; } else { unpauseGame(); } } } else if (Input.GetKeyDown(KeyCode.R) && isPaused) { SceneManager.LoadScene("MainMenu"); } if (!isPaused) { if (activateTimer && scenePromptOptions.transform.childCount != 1) { timeLeft -= Time.deltaTime; timetbox.text = Mathf.Round(timeLeft).ToString(); if (timeLeft < 0) { if (currentPrompt.TimerForceChoice) { currentOptionIndex = currentPrompt.TimerForceOptionInt; for (int i = 0; i < 10; i++) { ownedKeys.Remove("disappearChoice" + i.ToString()); } activateTimer = false; if (timetbox != null) { timetbox.text = ""; } deactivateDecisions(currentPrompt); insecurityActivatedOnce = false; isTimerActive = false; PromptOption option = currentUiOption.option; arrStoryInt = option.nextLinesInt; currentStoryIndex = option.startingInt; promptTimer = option.startingInt; currentPrompt = option.optionPrompt; if (option.picture != null) { background.GetComponent <Image> ().sprite = option.picture; } if (option.sound != null) { AudioSource.PlayClipAtPoint(option.sound, new Vector3(0, 0, 0)); } foreach (string grantedKey in option.grantedKeys) { ownedKeys.Add(grantedKey); } nextStoryLine(currentStoryIndex); } else { timetbox.text = ""; deleteChoice(); } } } if (DinerRound1NextPlayerCheck.timeDelay == true || ElectronicsCheckers.timeDelay == true || GiftShopCheckers.timeDelay == true || MechanicCheckers.timeDelay == true) { nextStoryLine(currentStoryIndex); DinerRound1NextPlayerCheck.timeDelay = false; ElectronicsCheckers.timeDelay = false; GiftShopCheckers.timeDelay = false; MechanicCheckers.timeDelay = false; } if (Input.GetKeyDown(KeyCode.UpArrow)) { //select previous option (if possible) if (optionsActive) { insecurityActivatedOnce = false; deactivateDecisions(currentPrompt); if (currentOptionIndex == 0) { currentOptionIndex = scenePromptOptions.transform.childCount - 1; } else { currentOptionIndex = Mathf.Max(currentOptionIndex - 1, 0); } activateDecisions(currentPrompt, currentOptionIndex); } } else if (Input.GetKeyDown(KeyCode.DownArrow)) { //select next option (if possible) if (optionsActive) { insecurityActivatedOnce = false; deactivateDecisions(currentPrompt); if (currentOptionIndex == scenePromptOptions.transform.childCount - 1) { currentOptionIndex = 0; } else { currentOptionIndex = Mathf.Min(currentOptionIndex + 1, scenePromptOptions.transform.childCount - 1); } activateDecisions(currentPrompt, currentOptionIndex); } } else if (Input.GetKeyDown(KeyCode.Return) && PlayerPrefs.GetInt("PreventReturn") != 1) { if (promptTimer == StoryStrings.StoryLines [arrStoryInt].StoryText.Length + 1) { for (int i = 0; i < 10; i++) { ownedKeys.Remove("disappearChoice" + i.ToString()); } activateTimer = false; if (timetbox != null) { timetbox.text = ""; } deactivateDecisions(currentPrompt); insecurityActivatedOnce = false; isTimerActive = false; PromptOption option = currentUiOption.option; arrStoryInt = option.nextLinesInt; currentStoryIndex = option.startingInt; promptTimer = option.startingInt; currentPrompt = option.optionPrompt; if (option.picture != null) { background.GetComponent <Image> ().sprite = option.picture; } if (option.sound != null) { AudioSource.PlayClipAtPoint(option.sound, new Vector3(0, 0, -10)); } foreach (string grantedKey in option.grantedKeys) { ownedKeys.Add(grantedKey); } } nextStoryLine(currentStoryIndex); } else if (Input.GetKeyDown(KeyCode.Backspace)) { if (optionsActive == false && PlayerPrefs.GetInt("Debugging") == 1) { if (currentStoryIndex != 1) { previousStoryLine(currentStoryIndex); } } } else if (Input.GetKeyDown(KeyCode.Escape)) { if (PlayerPrefs.GetInt("Debugging") == 1) { SceneManager.LoadScene("DebuggerSelection"); } } if (promptTimer == StoryStrings.StoryLines [arrStoryInt].StoryText.Length + 1) { movePointer(); Transform t = scenePromptOptions.transform.GetChild(currentOptionIndex); //get the child of the the "UiOptions" object corresponding to the current option index currentUiOption = t.GetComponent <UiOption> (); //store a reference to the UiOption component of this child } if (Input.GetKeyDown(KeyCode.C)) { print("currentStoryIndex: " + currentStoryIndex); print("arrStoryInt: " + arrStoryInt); print("currentTurn " + PlayerPrefs.GetInt("currentTurn").ToString()); } if (promptTimer == StoryStrings.StoryLines [arrStoryInt].StoryText.Length) { activateDecisions(currentPrompt, 0); currentStoryIndex = 0; promptTimer += 1; } for (int i = 0; i < scenePromptOptions.transform.childCount; i++) { Transform child = scenePromptOptions.transform.GetChild(i); Text childText = child.GetComponent <Text> (); childText.fontSize = 15; if (i == currentOptionIndex) { if (playernum == 1) { childText.color = newBluePointer; } else if (playernum == 2) { childText.color = newGreenPointer; } else if (playernum == 3) { childText.color = newRedPointer; } else if (playernum == 4) { childText.color = newYellowPointer; } } else { childText.color = Color.white; } } } }
private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var user = new List <User>(); var rpaService = new RPAService(); var option = string.Empty; try { this.processDetails = (ProcessDetails)stepContext.Result; } catch (Exception) { option = stepContext.Result.ToString(); } var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); processDetails.PromptOption = promptOption; } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "rpaSuport" && promptOption.Id != "RPAOptions") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } option = promptOption.Value; } var result = rpaService.GetUser(stepContext.Context.Activity.Conversation.Id); if (result.IsSuccess) { user = JsonConvert.DeserializeObject <List <User> >(result.Content); } //var _user = await _userAccessor.GetAsync(stepContext.Context, () => new User(), cancellationToken); if (this.processDetails.User != null) { this.processDetails.User.UserId = user[0].u_user; } else { this.processDetails.User = new User { UserId = user[0].u_user }; } if (!string.IsNullOrEmpty(option)) { switch (option.ToLower()) { case "start process": case "start": case "restart bot": case "start bot": processDetails.Action = "start"; return(await stepContext.BeginDialogAsync(nameof(StartProcessDialog), processDetails, cancellationToken)); case "process status": case "status": case "metrics": processDetails.Action = "check status"; return(await stepContext.BeginDialogAsync(nameof(StatusDialog), processDetails, cancellationToken)); case "stop a process": case "stop": case "stop process": case "stop bot": processDetails.Action = "stop"; return(await stepContext.BeginDialogAsync(nameof(StopProcessDialog), processDetails, cancellationToken)); case "report an issue": case "issue": case "report": case "report issue": case "bot failed": case "bot not working": case "bam?id=rpa_new_request&type=incident": processDetails.Action = string.IsNullOrEmpty(promptOption.Id)? "typed" : string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(OpenURLDialog), processDetails, cancellationToken)); /*var value = JsonConvert.SerializeObject(new PromptOption { Id = "FinalStep", Value = "bam?id=rpa_new_request&type=incident" }); * var choices = new List<Choice> { new Choice * { * Value = "bam?id=rpa_new_request&type=incident", * Action = new CardAction(ActionTypes.PostBack, "Click Here", null, "Click Here", "openUrl", value: value, null) * } * }; * choices.Add(rpaService.GetMainMenuOption()); * return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions * { * Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, "To Report an Issue, click Button below") * }, cancellationToken);*/ case "**contact rpa support**": case "contact rpa support": case "rpa support": case "support": case "contact support": case "help": case "need help": case "help needed": return(await stepContext.BeginDialogAsync(nameof(SupportDialog), processDetails, cancellationToken)); case "request an enhancement": case "enhancement": case "request": case "new request": case "bam?id=rpa_new_request&type=enhancement": processDetails.Action = string.IsNullOrEmpty(promptOption.Id) ? "typed" : string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(OpenURLDialog), processDetails, cancellationToken)); /*var enhancementValue = JsonConvert.SerializeObject(new PromptOption { Id = "FinalStep", Value = "bam?id=rpa_new_request&type=enhancement" }); * var options = new List<Choice> { new Choice * { * Value = "bam?id=rpa_new_request&type=enhancement", * Action = new CardAction(ActionTypes.PostBack, "Click Here", null, "Click Here", "openUrl", value: enhancementValue, null) * } }; * options.Add(rpaService.GetMainMenuOption()); * return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions * { * Prompt = (Activity)ChoiceFactory.SuggestedAction(options, "To Request an Enhancement, click Button below") * }, cancellationToken);*/ case "submit a new idea": case "new idea": case "idea": case "new project": case "new process": case "project request": case "bam?id=sc_cat_item&sys_id=a41ac289db7c6f0004b27709af9619a3": processDetails.Action = string.IsNullOrEmpty(promptOption.Id) ? "typed" : string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(OpenURLDialog), processDetails, cancellationToken)); /*var ideaValue = JsonConvert.SerializeObject(new PromptOption { Id = "FinalStep", Value = "bam?id=sc_cat_item&sys_id=a41ac289db7c6f0004b27709af9619a3" }); * return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions * { * Prompt = (Activity)ChoiceFactory.SuggestedAction(new List<Choice> { new Choice * { * Value = "bam?id=sc_cat_item&sys_id=a41ac289db7c6f0004b27709af9619a3", * Action = new CardAction(ActionTypes.PostBack, "Click Here", null, "Click Here", "openUrl", value: ideaValue, null) * } ,rpaService.GetMainMenuOption()}, "To Submit an Idea, click Button below") * * }, cancellationToken);*/ case "Bot Portal": case "bot portal": case "bam?id=rpa_processes": processDetails.Action = string.IsNullOrEmpty(promptOption.Id) ? "typed" : string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(OpenURLDialog), processDetails, cancellationToken)); /*var rpaProcessValue = JsonConvert.SerializeObject(new PromptOption { Id = "FinalStep", Value = "bam?id=rpa_processes" }); * options = new List<Choice> { new Choice * { * Value = "bam?id=rpa_processes", * Action = new CardAction(ActionTypes.PostBack, "Click Here", null, "Click Here", "openUrl", value: rpaProcessValue, null) * } }; * options.Add(rpaService.GetMainMenuOption()); * return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions * { * Prompt = (Activity)ChoiceFactory.SuggestedAction(options, "To go to Bot Portal, click Button below") * }, cancellationToken);*/ case "RPA Process Schedules": case "rpa process schedules": case "bam?id=rpa_process_scheduler": processDetails.Action = string.IsNullOrEmpty(promptOption.Id) ? "typed" : string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(OpenURLDialog), processDetails, cancellationToken)); /*var rpaProcessSchValue = JsonConvert.SerializeObject(new PromptOption { Id = "FinalStep", Value = "bam?id=rpa_process_scheduler" }); * options = new List<Choice> { new Choice * { * Value = "bam?id=rpa_processes", * Action = new CardAction(ActionTypes.PostBack, "Click Here", null, "Click Here", "openUrl", value: rpaProcessSchValue, null) * } }; * options.Add(rpaService.GetMainMenuOption()); * return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions * { * Prompt = (Activity)ChoiceFactory.SuggestedAction(options, "To go to RPA Process Schedules, click Button below") * }, cancellationToken);*/ case "end chat": case "exit": case "exit chat": case "close": case "close chat": case "end": //processDetails.Action = "done"; return(await stepContext.ReplaceDialogAsync(nameof(EndConversationDialog), processDetails, cancellationToken)); //this happen if an exception case "*****@*****.**": processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); //if type something instead of clicking an option default: return(await stepContext.ReplaceDialogAsync(InitialDialogId, null, cancellationToken)); } } else { //if luis not recognize what the user enter return(await stepContext.ReplaceDialogAsync(InitialDialogId, processDetails, cancellationToken)); } }
private async Task <DialogTurnResult> RecognizeText(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var user = new User(); var processDetails = new ProcessDetails(); try { var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Context.Activity.Text); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Value)) { stepContext.Context.Activity.Text = promptOption.Value; } var luisResult = await _luisRecognizer.RecognizeAsync <Process>(stepContext.Context, cancellationToken); switch (luisResult.TopIntent().intent) { case Process.Intent.RPA: var choices = new List <Choice>(); var rpaOptions = new RPAOptions(); foreach (var option in rpaOptions.Options) { var value = JsonConvert.SerializeObject(option); choices.Add(new Choice { Value = option.Value, Action = new CardAction(ActionTypes.PostBack, option.Text, null, option.Text, option.DisplayText, value: value, null) //ActionTypes.PostBack, "Click Here", null, "Click Here", "openUrl", value: value, null }); } return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)ChoiceFactory.HeroCard(choices, "Below is a list of available commands:"), //.ForChannel(stepContext.Context.Activity.ChannelId, choices, "Here is a list of your available commands.", null, ChoiceFactoryOptions.), }, cancellationToken)); /*return await stepContext.PromptAsync(nameof(ChoicePrompt), new PromptOptions * { * Prompt = MessageFactory.Text("Here is a list of your available commands."), * Choices = choices, * Style = ListStyle.HeroCard * }, cancellationToken);*/ default: processDetails.Action = "default"; // Catch all for unhandled intents var didntUnderstandMessageText = "I am sorry, I do not understand your request. Please try asking a different way or type " + '"' + "Menu" + '"' + " for available options."; var didntUnderstandMessage = MessageFactory.Text(didntUnderstandMessageText, didntUnderstandMessageText, InputHints.IgnoringInput); //start this dialog again return(await stepContext.NextAsync(processDetails, cancellationToken)); //.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = didntUnderstandMessage }, cancellationToken); } // return await stepContext.BeginDialogAsync(nameof(ProcessDialog), processDetails, cancellationToken); } catch (Exception ex) { var rpaService = new RPAService(); var rpaSupport = rpaService.GetRPASupportOption(); var choices = new List <Choice> { rpaSupport }; processDetails.Action = "error"; return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, "To continue to run this bot, please contact RPA Support.") /*Prompt = MessageFactory.Text("To continue to run this bot, please contact RPA Support."), * Choices = choices*/ }, cancellationToken)); } }
private async Task <DialogTurnResult> SelectStrategyStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var msg = string.Empty; var result = stepContext.Result.ToString(); var processDetails = (ProcessDetails)stepContext.Options; processDetails.Action = string.Empty; var rpaService = new RPAService(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Confirm") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } result = promptOption.Value; } if (result.ToLower() == "yes" || result.ToLower() == "y") { //check if process is queued if (!string.IsNullOrEmpty(processDetails.ProcessSelected.queuedId)) { var cancel = JsonConvert.SerializeObject(new PromptOption { Id = "Stop", Value = "3" }); var choices = new List <Choice> { new Choice { Value = "3", Action = new CardAction(ActionTypes.PostBack, "Cancel Queued Process", null, "Cancel Queued Process", "Cancel Queued Process", value: cancel, null) } }; choices.Add(rpaService.GetMainMenuOption()); return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, "Process " + processDetails.ProcessSelected.Name + " will be deleted from the queue and will not run." + Environment.NewLine + "Please click on below button to Cancel Queued Process") }, cancellationToken)); } else { var stop = JsonConvert.SerializeObject(new PromptOption { Id = "Stop", Value = "1" }); var terminate = JsonConvert.SerializeObject(new PromptOption { Id = "Stop", Value = "2" }); var choices = new List <Choice> { new Choice { Value = "1", Action = new CardAction(ActionTypes.PostBack, "Safely Stop Run", null, "Safely Stop Run", "Safely Stop Run", value: stop, null) }, new Choice { Value = "2", Action = new CardAction(ActionTypes.PostBack, "Terminate Process", null, "Terminate Process", "Terminate Process", value: terminate, null) } }; return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, "Please select one of the buttons below to Stop the Process:") }, cancellationToken)); } } else if (result.ToLower() == "no" || result.ToLower() == "n") { return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } else { return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } }
private async Task <DialogTurnResult> ShowParametersStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var processDetails = (ProcessDetails)stepContext.Options; var value = string.Empty; try { processDetails = (ProcessDetails)stepContext.Result; } catch (Exception) { value = stepContext.Result.ToString(); } var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "boolParam") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } value = promptOption.Value; } var rpaService = new RPAService(); //have entered all params if (string.IsNullOrEmpty(processDetails.CurrentQuestion.sys_id)) { var inputs = new List <ConversationFlowInput>(); //all parameters are entered foreach (var r in processDetails.ProcessSelected.Releases) { if (r.parameters_required) { //get params var response = rpaService.GetConversationFlowInputs(stepContext.Context.Activity.Conversation.Id, r.sys_id); var result = new List <ConversationFlowInput>(); if (response.IsSuccess) { result = JsonConvert.DeserializeObject <List <ConversationFlowInput> >(response.Content); } inputs.AddRange(result); var processParametersList = new List <ProcessParameters>(); foreach (var p in result) { if (p.u_is_object) { foreach (var o in r.parameters) { var objectParam = o.obj.Find(obj => obj.parmName == p.paramName); if (objectParam != null) { objectParam.value = p.u_value; break; } else { foreach (var a in o.obj) { objectParam = a.array.Find(arr => arr.parmName == p.paramName && string.IsNullOrEmpty(arr.value)); if (objectParam != null) { objectParam.value = p.u_value; break; } else { objectParam = a.array.Find(arr => a.parmName + '[' + arr.parmName + ']' == p.paramName && string.IsNullOrEmpty(arr.value)); if (objectParam != null) { objectParam.value = p.u_value; break; } } } } } } else if (p.u_is_array) { foreach (var a in r.parameters) { var arrParam = a.array.Find(arr => arr.parmName == p.paramName && string.IsNullOrEmpty(arr.value)); if (arrParam != null) { arrParam.value = p.u_value; break; } else { arrParam = a.array.Find(arr => a.parmName + '[' + arr.parmName + ']' == p.paramName && string.IsNullOrEmpty(arr.value)); if (arrParam != null) { arrParam.value = p.u_value; break; } } } } else { var _param = r.parameters.Find(pp => pp.parmName == p.paramName); if (_param != null) { _param.value = p.u_value; } } } } } /*var message = string.Empty; * foreach (var i in inputs) * { * message += i.paramName + ": " + i.u_value + Environment.NewLine; * } * * return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions * { * Prompt = (Activity)ChoiceFactory.SuggestedAction(ChoiceFactory.ToChoices(new List<string> { "Yes", "No" }), "You have entered " +Environment.NewLine+ message + "Is that correct?") * * }, cancellationToken);*/ //clear data in SN table rpaService.DeleteConversationFlowInputs(stepContext.Context.Activity.Conversation.Id); return(await stepContext.ReplaceDialogAsync(nameof(StartProcessSharedDialog), processDetails, cancellationToken)); } else { var conversationFlowInput = new ConversationFlowInput { u_chatbot_conversation_flow = processDetails.CurrentQuestion.sys_id, u_value = value.ToString(), u_conversation_id = stepContext.Context.Activity.Conversation.Id }; rpaService.SaveConversationFlowInput(conversationFlowInput); return(await stepContext.ReplaceDialogAsync(nameof(ParametersProcessDialog), processDetails, cancellationToken)); } }
/// <summary> /// Get QnAAnswer from the query result. /// </summary> /// <param name="response">query result response.</param> /// <returns>QnAMaker answer.</returns> public static QnAMakerAnswer GetQnAAnswerFromResponse(Microsoft.Bot.Builder.AI.QnA.QueryResult response) { if (response == null) { return(null); } var promptOptionDictionary = new Dictionary <int, PromptOption>(); var selectedResponse = response; var qnaAnswer = new QnAMakerAnswer(); qnaAnswer.Text = selectedResponse.Answer ?? null; foreach (var metadata in selectedResponse.Metadata) { if (metadata.Name.Contains(Constants.MetadataName.OptionRequery)) { var index = metadata.Name.Substring(13); if (int.TryParse(index, out var result)) { if (promptOptionDictionary.ContainsKey(result)) { promptOptionDictionary[result].Requery = metadata.Value; } else { var optionPrompt = new PromptOption(); optionPrompt.Requery = metadata.Value; promptOptionDictionary.Add(result, optionPrompt); } } } else if (metadata.Name.Contains(Constants.MetadataName.Option)) { var index = metadata.Name.Substring(6); if (int.TryParse(index, out var result)) { if (promptOptionDictionary.ContainsKey(result)) { promptOptionDictionary[result].Option = metadata.Value; } else { var optionPrompt = new PromptOption(); optionPrompt.Option = metadata.Value; promptOptionDictionary.Add(result, optionPrompt); } } } else if (metadata.Name.Contains(Constants.MetadataName.QnAId)) { var index = metadata.Name.Substring(5); if (int.TryParse(index, out var result)) { int.TryParse(metadata.Value, out var id); if (promptOptionDictionary.ContainsKey(result)) { promptOptionDictionary[result].QnAId = id; } else { var optionPrompt = new PromptOption(); optionPrompt.QnAId = id; promptOptionDictionary.Add(result, optionPrompt); } } } else if (metadata.Name == Constants.MetadataName.Requery) { qnaAnswer.Requery = metadata.Value ?? null; } else if (metadata.Name.Contains(Constants.MetadataName.Name)) { qnaAnswer.Name = metadata.Value ?? null; } else if (metadata.Name.Contains(Constants.MetadataName.Parent)) { qnaAnswer.Parent = metadata.Value ?? null; } else if (metadata.Name.Contains(Constants.MetadataName.Isroot)) { qnaAnswer.IsRoot = metadata.Value ?? null; } else if (metadata.Name.Contains(Constants.MetadataName.Flowtype)) { qnaAnswer.Flowtype = metadata.Value ?? null; } } foreach (var promptOption in promptOptionDictionary) { qnaAnswer.Options.Add(promptOption.Value); } qnaAnswer.IsChitChat = IsResponseChitChat(response); return(qnaAnswer); }
private async Task <DialogTurnResult> ShowRunningProcessStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var rpaService = new RPAService(); var processDetails = (ProcessDetails)stepContext.Options; var result = stepContext.Result.ToString(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "availableProcesses" && promptOption.Id != "menu") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } result = promptOption.Value; } var _response = rpaService.GetUser(stepContext.Context.Activity.Conversation.Id); var user = new List <User>(); if (_response.IsSuccess) { user = JsonConvert.DeserializeObject <List <User> >(_response.Content); } if (result.ToLower() == "menu" || result.ToLower() == "m" /*"*****@*****.**"*/) { //save index user[0].u_last_index = "0"; rpaService.UpdateUser(user[0], stepContext.Context.Activity.Conversation.Id); //_user.u_last_index = 0; //await _userAccessor.SetAsync(stepContext.Context, _user, cancellationToken); processDetails.Action = string.Empty; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } else if (result.ToLower() == "load_more") { processDetails.LoadMore = true; return(await stepContext.ReplaceDialogAsync(nameof(StatusDialog), processDetails, cancellationToken)); } else { processDetails.ProcessSelected = rpaService.GetSelectedProcess(processDetails.Processes, result); //check if a process was selected, or something was written if (!string.IsNullOrEmpty(processDetails.ProcessSelected.Sys_id)) { //save index user[0].u_last_index = "0"; rpaService.UpdateUser(user[0], stepContext.Context.Activity.Conversation.Id); //_user.u_last_index = 0; //await _userAccessor.SetAsync(stepContext.Context, _user, cancellationToken); var apiRequest = new APIRequest { ProcessId = processDetails.ProcessSelected.Sys_id }; if (!string.IsNullOrEmpty(processDetails.ProcessSelected.queuedId)) { apiRequest.Queued = true; } var jobIds = new List <string>(); var releaseIds = new List <string>(); //if there was a process started if (processDetails.Jobs.Count > 0) { foreach (var job in processDetails.Jobs) { foreach (var item in job.Result.Body.Value) { jobIds.Add(item.Id); } } apiRequest.Ids = jobIds; apiRequest.IsJob = true; } else { foreach (var release in processDetails.ProcessSelected.Releases) { releaseIds.Add(release.sys_id); } apiRequest.Ids = releaseIds; apiRequest.IsJob = false; } var response = rpaService.ProcessStatus(apiRequest); var text = string.Empty; if (response.IsSuccess) { var processSatus = JsonConvert.DeserializeObject <List <ProcessStatus> >(response.Content); text = processSatus.Count > 1 ? "Here are the status for " : "Here is the latest status for "; text += processDetails.ProcessSelected.Name + " process." + Environment.NewLine; foreach (var item in processSatus) { var include = "Total Transactions Processed: " + item.TotalTransactions + Environment.NewLine; /* + * "Run Time: " + item.Runtime + Environment.NewLine;*/ if (item.ProcessType == "procedural") { include = string.Empty; } var endTime = item.End != null ? "End Time: " + item.End + Environment.NewLine : string.Empty; var startTime = item.Start != null ? "Start Time: " + item.Start + Environment.NewLine : string.Empty; text += "Status: " + item.State.label + Environment.NewLine + startTime + endTime + include + "Total Transactions Successful: " + Convert.ToInt32(item.TotalTransSuccessful) + Environment.NewLine + "Total Exceptions: " + Convert.ToInt32(item.TotalExceptions) + Environment.NewLine + "Bot Name: " + item.Robot + Environment.NewLine + "Started By: " + item.startedBy; } } else { text = response.Content; } var choices = rpaService.GetConfirmChoices(); return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = (Activity)ChoiceFactory.SuggestedAction(choices, text + Environment.NewLine + "Do you want to check the status of another process?") /*Prompt = MessageFactory.Text(text + Environment.NewLine + "Do you want to check the status of another process?"), * Choices = ChoiceFactory.ToChoices(new List<string> { "Yes", "No" })*/ }, cancellationToken)); } else { return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); } } }
private async Task <DialogTurnResult> StopProcessStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { var msg = string.Empty; var result = stepContext.Result.ToString(); var processDetails = (ProcessDetails)stepContext.Options; processDetails.Action = string.Empty; var rpaService = new RPAService(); var promptOption = new PromptOption(); try { promptOption = JsonConvert.DeserializeObject <PromptOption>(stepContext.Result.ToString()); } catch (Exception) { } if (!string.IsNullOrEmpty(promptOption.Id)) { if (promptOption.Id != "Stop" && promptOption.Id != "mainMenu") { processDetails.Action = "pastMenu"; return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } result = promptOption.Value; } if (result.ToLower() == "1" || result.ToLower() == "2" || result.ToLower() == "3") { var response = new APIResponse(); if (result.ToLower() == "3") { response = rpaService.CancelQueuedProcess(processDetails.ProcessSelected); } else { response = rpaService.StopProcess(processDetails.ProcessSelected.Sys_id, Convert.ToInt32(result)); } if (response.IsSuccess) { if (!string.IsNullOrEmpty(response.Content)) { msg = response.Content; } else { if (result.ToLower() == "3") { msg = "Process " + processDetails.ProcessSelected.Name + " has been successfully deleted from the queue."; } else { msg = "Request to Stop Process " + processDetails.ProcessSelected.Name + " Submitted. Please allow a few minutes for the status to refresh."; } } } else { if (!string.IsNullOrEmpty(response.Error)) { msg = response.Error; } else { msg = response.Message; } } await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(msg) }, cancellationToken); return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), processDetails, cancellationToken)); } return(await stepContext.ReplaceDialogAsync(nameof(MainDialog), null, cancellationToken)); }