Reputation: 1202
I have a LuisDialog with several LUIS Intents. In some of these intents I may need to ask the user for more information. In these cases I'm trying to use a PromptDialog or a PromptString.
I alredy tried this:
[LuisIntent("MyIntent")]
public async Task MyIntent(IDialogContext context, LuisResult result)
{
if (result.Entities.Count == 0)
{
PromptDialog.Text(context, AfterUserInputSymbol, "Message to the user", "Try again message", 2);
result.Entities[0].Entity = userSymbol;
}
//some other code
context.Wait(MessageReceived);
}
private async Task AfterUserInputSymbol(IDialogContext context, IAwaitable<string> result)
{
userSymbol = await result;
context.Wait(MessageReceived);
}
And this:
[LuisIntent("MyIntent")]
public async Task MyIntent(IDialogContext context, LuisResult result)
{
if (result.Entities.Count == 0)
{
PromptString dialog = new PromptString("Message to the user", "Try again message", 2);
context.Call(dialog, AfterUserInputSymbol);
result.Entities[0].Entity = userSymbol;
}
//some other code
context.Wait(MessageReceived);
}
private async Task AfterUserInputSymbol(IDialogContext context, IAwaitable<string> result)
{
userSymbol = await result;
context.Wait(MessageReceived);
}
In both cases the prompt doesn't appear to the user and the value of userSymbol
gets a null. When I'm debugging the code only enters the AfterUserInputSymbol
when It get's to this part: result.Entities[0].Entity = userSymbol;
How can I prompt for more information inside a LuisIntent?
Upvotes: 1
Views: 537
Reputation: 14787
Not sure exactly what it's happening since there isn't any error posted in your question, however something that might be happening there is that you are starting a new dialog and ALSO you have the context.Wait(MessageReceived) there. If you are launching a dialog, you don't have to wait for a message in that flow, that's why I would add an else clause there.
if (result.Entities.Count == 0)
{
PromptDialog.Text(context, AfterUserInputSymbol, "Message to the user", "Try again message", 2);
// The following line shouldn't be here
result.Entities[0].Entity = userSymbol;
}
//here you should put an else
else
{
context.Wait(MessageReceived);
}
Also, have in mind that you won't be able to assign the userSymbol to the Luis Result entity after calling the dialog as you are trying to do. That will have to be done in the ResumeAfter method "AfterUserInputSymbol".
Once you do that, you can manually call your Intent passing the context and the newer Luis Result (you might have to save the previous one depending on what you are trying to achieve)
Upvotes: 2