Passing Dynamic Formflow values back to Luis
I have created a dynamic form flow (which is coming up fine). Further i need to get the value as selected by the user and return the answer from LUIS.
My Dynamic form flow is as:
[Serializable]
public class Troubleshooting
{
public List<TroubleShootingQuestion> questions
{
get;
set;
}
public static IForm<Troubleshooting> BuildForm()
{
var menuItems = DynamicGenericQuestions.GetAllGenericOptions();
var builder = new FormBuilder<Troubleshooting>();
//object MenuItems = null;
builder.Field(new FieldReflector<Troubleshooting>(nameof(questions)).SetType(null).SetDefine((state, field) =>
{
foreach (var item in menuItems)
{
field.AddDescription(item, new DescribeAttribute()
{
Title = item.GenericQuestion,
Description = item.GenericQuestion
//Image = item.ItemImage
}).AddTerms(item, item.GenericQuestion);
}
return Task.FromResult(true);
}).SetPrompt(new PromptAttribute("Please choose your query. n {||} n")
{
ChoiceStyle = ChoiceStyleOptions.Auto
}).SetAllowsMultiple(false)).AddRemainingFields();
return builder.Build();
}
}
[Serializable]
public class TroubleShootingQuestion
{
public string GenericQuestion
{
get;
set;
}
}
public class DynamicGenericQuestions
{
public static List<TroubleShootingQuestion> GetAllGenericOptions()
{
return new List<TroubleShootingQuestion>() {
new TroubleShootingQuestion() {
GenericQuestion = "How to migrate the site?"
},
new TroubleShootingQuestion() {
GenericQuestion = "My site is not opening."
},
new TroubleShootingQuestion() {
GenericQuestion = "Home page is not loading"
},
new TroubleShootingQuestion() {
GenericQuestion = "No Preference"
},
};
}
}
In LUIS i have done the following :
[LuisIntent("Troubleshooting")]
public async Task TroubleshootingIntent(IDialogContext context, LuisResult result)
{
var TroubleshootingForm = new FormDialog<Troubleshooting>(new Troubleshooting(), Troubleshooting.BuildForm, FormOptions.PromptInStart, null);
context.Call<Troubleshooting>(TroubleshootingForm, TroubleshootingFormCompleteAsync);
//await this.ShowLuisResult(context, result);
}
private async Task TroubleshootingFormCompleteAsync(IDialogContext context, IAwaitable<Troubleshooting> result)
{
try
{
var TroubleshootingFormData = await result;
await context.PostAsync(TroubleshootingFormData.ToString());
await context.PostAsync(result.ToString());
context.Wait(MessageReceived);
}
catch (FormCanceledException<Troubleshooting> e)
{
string reply;
if (e.InnerException == null)
{
reply = $"You quit the request. Maybe you can finish next time!";
}
else
{
reply = "Sorry, the request could not be processed. Please try again.";
}
await context.PostAsync(reply);
}
catch (Exception)
{
await context.PostAsync("Sorry, the request could not be processed. Please try again.");
}
}
It goes in Exception. Can anybody tell where I'm going wrong.
c#
add a comment |
I have created a dynamic form flow (which is coming up fine). Further i need to get the value as selected by the user and return the answer from LUIS.
My Dynamic form flow is as:
[Serializable]
public class Troubleshooting
{
public List<TroubleShootingQuestion> questions
{
get;
set;
}
public static IForm<Troubleshooting> BuildForm()
{
var menuItems = DynamicGenericQuestions.GetAllGenericOptions();
var builder = new FormBuilder<Troubleshooting>();
//object MenuItems = null;
builder.Field(new FieldReflector<Troubleshooting>(nameof(questions)).SetType(null).SetDefine((state, field) =>
{
foreach (var item in menuItems)
{
field.AddDescription(item, new DescribeAttribute()
{
Title = item.GenericQuestion,
Description = item.GenericQuestion
//Image = item.ItemImage
}).AddTerms(item, item.GenericQuestion);
}
return Task.FromResult(true);
}).SetPrompt(new PromptAttribute("Please choose your query. n {||} n")
{
ChoiceStyle = ChoiceStyleOptions.Auto
}).SetAllowsMultiple(false)).AddRemainingFields();
return builder.Build();
}
}
[Serializable]
public class TroubleShootingQuestion
{
public string GenericQuestion
{
get;
set;
}
}
public class DynamicGenericQuestions
{
public static List<TroubleShootingQuestion> GetAllGenericOptions()
{
return new List<TroubleShootingQuestion>() {
new TroubleShootingQuestion() {
GenericQuestion = "How to migrate the site?"
},
new TroubleShootingQuestion() {
GenericQuestion = "My site is not opening."
},
new TroubleShootingQuestion() {
GenericQuestion = "Home page is not loading"
},
new TroubleShootingQuestion() {
GenericQuestion = "No Preference"
},
};
}
}
In LUIS i have done the following :
[LuisIntent("Troubleshooting")]
public async Task TroubleshootingIntent(IDialogContext context, LuisResult result)
{
var TroubleshootingForm = new FormDialog<Troubleshooting>(new Troubleshooting(), Troubleshooting.BuildForm, FormOptions.PromptInStart, null);
context.Call<Troubleshooting>(TroubleshootingForm, TroubleshootingFormCompleteAsync);
//await this.ShowLuisResult(context, result);
}
private async Task TroubleshootingFormCompleteAsync(IDialogContext context, IAwaitable<Troubleshooting> result)
{
try
{
var TroubleshootingFormData = await result;
await context.PostAsync(TroubleshootingFormData.ToString());
await context.PostAsync(result.ToString());
context.Wait(MessageReceived);
}
catch (FormCanceledException<Troubleshooting> e)
{
string reply;
if (e.InnerException == null)
{
reply = $"You quit the request. Maybe you can finish next time!";
}
else
{
reply = "Sorry, the request could not be processed. Please try again.";
}
await context.PostAsync(reply);
}
catch (Exception)
{
await context.PostAsync("Sorry, the request could not be processed. Please try again.");
}
}
It goes in Exception. Can anybody tell where I'm going wrong.
c#
Thank you for posting your code. Can you go ahead and give theExceptionan identifier (catch (Exception ex))? Also, can you try setting breakpoints and debugging the code and stepping through it so you can see what the actual exception is?
– Kyle Delaney
Dec 27 at 21:18
Thank u Kyle will try that.
– user64870
2 days ago
add a comment |
I have created a dynamic form flow (which is coming up fine). Further i need to get the value as selected by the user and return the answer from LUIS.
My Dynamic form flow is as:
[Serializable]
public class Troubleshooting
{
public List<TroubleShootingQuestion> questions
{
get;
set;
}
public static IForm<Troubleshooting> BuildForm()
{
var menuItems = DynamicGenericQuestions.GetAllGenericOptions();
var builder = new FormBuilder<Troubleshooting>();
//object MenuItems = null;
builder.Field(new FieldReflector<Troubleshooting>(nameof(questions)).SetType(null).SetDefine((state, field) =>
{
foreach (var item in menuItems)
{
field.AddDescription(item, new DescribeAttribute()
{
Title = item.GenericQuestion,
Description = item.GenericQuestion
//Image = item.ItemImage
}).AddTerms(item, item.GenericQuestion);
}
return Task.FromResult(true);
}).SetPrompt(new PromptAttribute("Please choose your query. n {||} n")
{
ChoiceStyle = ChoiceStyleOptions.Auto
}).SetAllowsMultiple(false)).AddRemainingFields();
return builder.Build();
}
}
[Serializable]
public class TroubleShootingQuestion
{
public string GenericQuestion
{
get;
set;
}
}
public class DynamicGenericQuestions
{
public static List<TroubleShootingQuestion> GetAllGenericOptions()
{
return new List<TroubleShootingQuestion>() {
new TroubleShootingQuestion() {
GenericQuestion = "How to migrate the site?"
},
new TroubleShootingQuestion() {
GenericQuestion = "My site is not opening."
},
new TroubleShootingQuestion() {
GenericQuestion = "Home page is not loading"
},
new TroubleShootingQuestion() {
GenericQuestion = "No Preference"
},
};
}
}
In LUIS i have done the following :
[LuisIntent("Troubleshooting")]
public async Task TroubleshootingIntent(IDialogContext context, LuisResult result)
{
var TroubleshootingForm = new FormDialog<Troubleshooting>(new Troubleshooting(), Troubleshooting.BuildForm, FormOptions.PromptInStart, null);
context.Call<Troubleshooting>(TroubleshootingForm, TroubleshootingFormCompleteAsync);
//await this.ShowLuisResult(context, result);
}
private async Task TroubleshootingFormCompleteAsync(IDialogContext context, IAwaitable<Troubleshooting> result)
{
try
{
var TroubleshootingFormData = await result;
await context.PostAsync(TroubleshootingFormData.ToString());
await context.PostAsync(result.ToString());
context.Wait(MessageReceived);
}
catch (FormCanceledException<Troubleshooting> e)
{
string reply;
if (e.InnerException == null)
{
reply = $"You quit the request. Maybe you can finish next time!";
}
else
{
reply = "Sorry, the request could not be processed. Please try again.";
}
await context.PostAsync(reply);
}
catch (Exception)
{
await context.PostAsync("Sorry, the request could not be processed. Please try again.");
}
}
It goes in Exception. Can anybody tell where I'm going wrong.
c#
I have created a dynamic form flow (which is coming up fine). Further i need to get the value as selected by the user and return the answer from LUIS.
My Dynamic form flow is as:
[Serializable]
public class Troubleshooting
{
public List<TroubleShootingQuestion> questions
{
get;
set;
}
public static IForm<Troubleshooting> BuildForm()
{
var menuItems = DynamicGenericQuestions.GetAllGenericOptions();
var builder = new FormBuilder<Troubleshooting>();
//object MenuItems = null;
builder.Field(new FieldReflector<Troubleshooting>(nameof(questions)).SetType(null).SetDefine((state, field) =>
{
foreach (var item in menuItems)
{
field.AddDescription(item, new DescribeAttribute()
{
Title = item.GenericQuestion,
Description = item.GenericQuestion
//Image = item.ItemImage
}).AddTerms(item, item.GenericQuestion);
}
return Task.FromResult(true);
}).SetPrompt(new PromptAttribute("Please choose your query. n {||} n")
{
ChoiceStyle = ChoiceStyleOptions.Auto
}).SetAllowsMultiple(false)).AddRemainingFields();
return builder.Build();
}
}
[Serializable]
public class TroubleShootingQuestion
{
public string GenericQuestion
{
get;
set;
}
}
public class DynamicGenericQuestions
{
public static List<TroubleShootingQuestion> GetAllGenericOptions()
{
return new List<TroubleShootingQuestion>() {
new TroubleShootingQuestion() {
GenericQuestion = "How to migrate the site?"
},
new TroubleShootingQuestion() {
GenericQuestion = "My site is not opening."
},
new TroubleShootingQuestion() {
GenericQuestion = "Home page is not loading"
},
new TroubleShootingQuestion() {
GenericQuestion = "No Preference"
},
};
}
}
In LUIS i have done the following :
[LuisIntent("Troubleshooting")]
public async Task TroubleshootingIntent(IDialogContext context, LuisResult result)
{
var TroubleshootingForm = new FormDialog<Troubleshooting>(new Troubleshooting(), Troubleshooting.BuildForm, FormOptions.PromptInStart, null);
context.Call<Troubleshooting>(TroubleshootingForm, TroubleshootingFormCompleteAsync);
//await this.ShowLuisResult(context, result);
}
private async Task TroubleshootingFormCompleteAsync(IDialogContext context, IAwaitable<Troubleshooting> result)
{
try
{
var TroubleshootingFormData = await result;
await context.PostAsync(TroubleshootingFormData.ToString());
await context.PostAsync(result.ToString());
context.Wait(MessageReceived);
}
catch (FormCanceledException<Troubleshooting> e)
{
string reply;
if (e.InnerException == null)
{
reply = $"You quit the request. Maybe you can finish next time!";
}
else
{
reply = "Sorry, the request could not be processed. Please try again.";
}
await context.PostAsync(reply);
}
catch (Exception)
{
await context.PostAsync("Sorry, the request could not be processed. Please try again.");
}
}
It goes in Exception. Can anybody tell where I'm going wrong.
c#
c#
edited 2 days ago
Dale Burrell
2,78512147
2,78512147
asked Dec 27 at 13:20
user64870
113
113
Thank you for posting your code. Can you go ahead and give theExceptionan identifier (catch (Exception ex))? Also, can you try setting breakpoints and debugging the code and stepping through it so you can see what the actual exception is?
– Kyle Delaney
Dec 27 at 21:18
Thank u Kyle will try that.
– user64870
2 days ago
add a comment |
Thank you for posting your code. Can you go ahead and give theExceptionan identifier (catch (Exception ex))? Also, can you try setting breakpoints and debugging the code and stepping through it so you can see what the actual exception is?
– Kyle Delaney
Dec 27 at 21:18
Thank u Kyle will try that.
– user64870
2 days ago
Thank you for posting your code. Can you go ahead and give the
Exception an identifier (catch (Exception ex))? Also, can you try setting breakpoints and debugging the code and stepping through it so you can see what the actual exception is?– Kyle Delaney
Dec 27 at 21:18
Thank you for posting your code. Can you go ahead and give the
Exception an identifier (catch (Exception ex))? Also, can you try setting breakpoints and debugging the code and stepping through it so you can see what the actual exception is?– Kyle Delaney
Dec 27 at 21:18
Thank u Kyle will try that.
– user64870
2 days ago
Thank u Kyle will try that.
– user64870
2 days ago
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53945781%2fpassing-dynamic-formflow-values-back-to-luis%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53945781%2fpassing-dynamic-formflow-values-back-to-luis%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Thank you for posting your code. Can you go ahead and give the
Exceptionan identifier (catch (Exception ex))? Also, can you try setting breakpoints and debugging the code and stepping through it so you can see what the actual exception is?– Kyle Delaney
Dec 27 at 21:18
Thank u Kyle will try that.
– user64870
2 days ago