0
我在Luis的幫助下有一個簡單的機器人。這是非常基本的代碼,我不知道爲什麼我在向Luis意圖傳遞消息之後得到了412錯誤。我的代碼如下所示:Bot框架412當連接Luis時「數據發生變化」
MessageController:
if (activity.Type == ActivityTypes.Message)
{
// Get any saved values
StateClient sc = activity.GetStateClient();
await sc.BotState.GetUserDataAsync(activity.ChannelId,activity.From.Id);
var haveGreeting = userData.GetProperty<bool>("HaveGreeting");
// Create text for a reply message
StringBuilder strReplyMessage = new StringBuilder();
if (haveGreeting == false)
{
strReplyMessage.Append($"Hi, how are you today?");
userData.SetProperty("HaveGreeting", true);
}
else
{
await Conversation.SendAsync(activity,() => new MeBotLuisDialog());
}
// Save BotUserData
var botaData = await sc.BotState.SetUserDataAsync(activity.ChannelId,
activity.From.Id, userData);
// Create a reply message
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity replyMessage = activity.CreateReply(strReplyMessage.ToString());
await connector.Conversations.ReplyToActivityAsync(replyMessage);
}
路易斯意圖:
[LuisIntent("HowAreYou")]
public async Task HowAreYou(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
await context.PostAsync("Great! Thank for asking");
context.Wait(MessageReceived);
}
請幫幫忙!
這是否在模擬器失敗? –
不,我已經發布此測試機器人,但仍然得到此問題 –
請參閱http://stackoverflow.com/questions/42860020/microsoft-bot-framework-exception-the-data-is-changed/42913460#42913460 – Artem