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)); } }