Reputation: 2492
I create simple bot with Microsoft BotFramework and i use FormFlow
.
So:
[Serializable]
public class Test
{
public String Name {get;set;}
public uint Age {get;set; }
}
internal static IDialog<Test> MakeRootDialog()
{
return Chain.From(() => FormDialog.FromForm(Test.BuildForm));
}
And:
public async Task<Message> Post([FromBody]Message message)
{
if (message.Type == "Message")
{
return await Conversation.SendAsync(message, MakeRootDialog);
}
else
{
return HandleSystemMessage(message);
}
}
So, Micrisoft BotEmulator works well (and bot) and ask me Name and Age of Person. But, how to get result of this choise to use it?
And how to know what user type it? Should i use ConversationId?
P.S. i mean how can i get result from user name and user age? I try to use:
var name= result.GetBotPerUserInConversationData<Test>("Name");
But it return null;
P.P.S: i use Bot Emulator: and get json responce like this:
GetBotPerUserInConversationData:DialogState { some binary data }
So, i use
var name= result.GetBotPerUserInConversationData<Test>("DialogState");
But get an error:
"exceptionMessage": "Error converting value System.Byte[] to type 'Test'. Path ''.",
"exceptionType": "Newtonsoft.Json.JsonSerializationException"
Upvotes: 2
Views: 1010
Reputation: 902
Hi since you are building the form, you can get the result in FormFlowComplete callback method as below
private async Task yourFormFlowComplete(IDialogContext context, IAwaitable<yourclass> result)
{
var res = await result;//res will contain the result set, if you build the form with a class
}
Upvotes: 2
Reputation: 14787
You can just 'chain' a Do call to the Chain.From
internal static IDialog<Test> MakeRootDialog()
{
return Chain.From(() => FormDialog.FromForm(Test.BuildForm))
.Do(async (context, formResult) =>
{
var completed = await formResult;
//your logic
}
}
'completed' will have the result of the form with the entries from the user.
You can refer to the AnnotatedSandwichBot where they are doing exactly what you need here.
Upvotes: 1