从Json调用child Dialog

时间:2017-08-22 12:16:07

标签: c# json botframework

我想从JSON架构对话框中调用子对话框:

对话1

{

  "References": [ "my .dll", "Newtonsoft.Json.dll" ],  
  "Imports": [ "my class", "Newtonsoft.Json.Linq" ],
  "type": "object",
  "required": [
   "Question 1"

   ],
"Templates": {
"NotUnderstood": {
  "Patterns": [ "I do not understand \"{0}\".", "Try again, I don't get \"{0}\"." ]
},
"EnumSelectOne": {
  "Patterns": [ "Please let me know the {&}: {||}" ],
  "ChoiceStyle": "PerLine"
}
},
 "properties": {
 "Question 1": {
  "Prompt": {
    "Patterns": [ "my Question 1 ? {||}" ]
  },
  "type": [
    "string",
    "null"
  ],
  "enum": [
    "Info",
    "Submit an Issue",
    "Track Cases",
    "Finish"
  ]

},
 "OnCompletion": "context.Call(FormDialog.FromForm<JObject>(()=>BuildJsonForm(\"another.json\"),FormOptions.PromptInStart), (con, res) =>CompletedQ1AndQ2(con, res));"

}

对话2

{

  "References": [ "my .dll", "Newtonsoft.Json.dll" ],  
  "Imports": [ "my class2", "Newtonsoft.Json.Linq" ],
  "type": "object",
  "required": [
   "Question 1"

   ],
"Templates": {
"NotUnderstood": {
  "Patterns": [ "I do not understand \"{0}\".", "Try again, I don't get \"{0}\"." ]
},
"EnumSelectOne": {
  "Patterns": [ "Please let me know the {&}: {||}" ],
  "ChoiceStyle": "PerLine"
}
},
 "properties": {
 "Question 2": {
  "Prompt": {
    "Patterns": [ "my Question 2 ? {||}" ]
  },
  "type": [
    "string",
    "null"
  ],
  "enum": [
    "support ",
    "sales ",
    "marketing"
  ]

},
 "OnCompletion": "context.Done<bool>(true);"

}

c#c​​ode:

public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
{
       context.Call(
           FormDialog.FromForm<JObject>(() => BuildJsonForm("Q1.json"),
               FormOptions.PromptInStart), (con, res) => CompletedCaseSubmission(con, res));
}

在填充Q1但Q2对话框后,CompletedCaseSubmission调用的问题根本没有执行。我可以从CompletedCaseSubmission调用Dialog 2,但我想从JSON中调用它。 第二个问题是如何在c#中获取对话框Q1和Q2 的详细信息

1 个答案:

答案 0 :(得分:0)

目前无法中断表单对话框以调用另一个对话框。但是,您可以将表单分成更小的部分,并在各部分之间调用其他对话框。请参阅以下链接以获取更多信息:

https://github.com/Microsoft/BotBuilder/issues/3293
How to hook Luis into a Bot Framework FormDialog