Reputation: 1202
I am using the Microsoft Bot Framework to create a really simple bot using a LuisDialog. However I keep getting a System.Collections.Generic.KeyNotFoundException.
Here's my controller:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new QuotesDialog());
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
Here's my dialog:
[Serializable]
[LuisModel("MyModelIdGoesHere", "MySubscriptionKeyGoesHere")]
public class QuotesDialog : LuisDialog<object>
{
[LuisIntent("CheckQuote")]
public async Task CheckQuote(IDialogContext context, LuisResult result)
{
await context.PostAsync("Hello you!");
context.Wait(MessageReceived);
}
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
await context.PostAsync("I'm sorry. I didn't get that.");
context.Wait(MessageReceived);
}
}
If I use an older version of the Bot Framework, like 3.0.0, I get the following error: 500 InternalServerError { "message": "An error has occurred." }
However if I update to the latest stable version (3.2.1) then I get the following error of the type "System.Collections.Generic.KeyNotFoundException":
"Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Microsoft.Bot.Builder.Dialogs.LuisDialog "
The full stack trace is here:
I tried create a new project on another solution, but I get the same error. I tried install different versions of the Bot Framework via nuget but like I said previously, one way or another I still get an error. I have really little experience with the Bot Framework so far, so I don't really know what else to try.
Upvotes: 1
Views: 1958
Reputation: 14787
Can you try again adding the following on top of the None method?
[LuisIntent("")]
The error that you are seeing is usually happening when the LuisDialog cannot resolve the method (intent) to execute based on the message received.
I suspect the issue is being raised here, when the LuisDialog looks for the empty intent.
handler = this.handlerByIntent[string.Empty];
Upvotes: 4