Reputation: 78
I have a LUIS dialog and it successfully detects the intent and call the specified child dialog.
[Serializable]
[LuisModel("xxxxxxxxxxxx", "xxxxxxxxxxxxxxxx")]
public class RootDialog : LuisDialog<object>
{
[LuisIntent("ApplyJob")]
public async Task Search(IDialogContext context, IAwaitable<IMessageActivity> activity,LuisResult result)
{
await context.PostAsync("Lets apply for a job");
context.Call(new ApplyJobDialog(result), ApplyJobComplete);
}
private async Task ApplyJobComplete(IDialogContext context, IAwaitable<object> result)
{
context.Done(await result);
}
}
I am passing the LuisResult to the child dialog. (so, i can extract some entities in the child dialog. - Not implemented in the following code)
My child Dialog looks like this
[Serializable]
public class ApplyJobDialog: IDialog<object>
{
public LuisResult LuisResult { get; set; }
internal ApplyJobDialog(LuisResult result)
{
LuisResult = result;
}
public async Task StartAsync(IDialogContext context)
{
await context.PostAsync("hello");
context.Wait(AfterComplete);
}
private async Task AfterComplete(IDialogContext context, IAwaitable<IMessageActivity> result)
{
context.Done("");
}
}
It shows "hello" to the user.But then it throws an exception. (Displayed in emulator) Even without using the passed "LuisResult"
Exception: Type ‘Microsoft.Bot.Builder.Luis.Models.LuisResult’ in Assembly ‘Microsoft.Bot.Builder,
Version=3.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ is not marked as serializable.
[File of type 'text/plain']
However if I am not calling the "AfterComplete", It does not throws an exception.
public async Task StartAsync(IDialogContext context)
{
await context.PostAsync("hello");
//context.Wait(AfterComplete);
context.Done("");
}
What am i doing wrong here. How can i call ResumeAfter methods (like AfterComplete) and continue the conversation?
Upvotes: 0
Views: 585
Reputation: 14787
The LuisResult
class is not serializable, so you cannot hold a variable in the ApplyJobDialog
, because the dialog will try to be serialized.
You will have to pass something serializable or extract the entities in the RootDialog
.
Upvotes: 1