【发布时间】:2016-09-26 14:52:15
【问题描述】:
我使用 Microsoft BotFramework 创建简单的机器人,并使用FormFlow。
所以:
[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));
}
还有:
public async Task<Message> Post([FromBody]Message message)
{
if (message.Type == "Message")
{
return await Conversation.SendAsync(message, MakeRootDialog);
}
else
{
return HandleSystemMessage(message);
}
}
所以,Micrisoft BotEmulator 运行良好(和机器人)并询问我姓名和年龄。 但是,如何得到这个选择的结果来使用它呢?
又如何知道是什么用户输入的呢?我应该使用 ConversationId 吗?
附:我的意思是如何从用户名和用户年龄中获得结果? 我尝试使用:
var name= result.GetBotPerUserInConversationData<Test>("Name");
但它返回 null;
P.P.S:我使用 Bot Emulator:并像这样获得 json 响应:
GetBotPerUserInConversationData:DialogState { some binary data }
所以,我用
var name= result.GetBotPerUserInConversationData<Test>("DialogState");
但是得到一个错误:
"exceptionMessage": "Error converting value System.Byte[] to type 'Test'. Path ''.",
"exceptionType": "Newtonsoft.Json.JsonSerializationException"
【问题讨论】:
标签: c# telegram telegram-bot botframework