I\'m using PromptDialog.Choice()
to present different options to my users. The number of attempts is set to 0, so if they type in anything that is not a valid optio
Adding some more context to Ezequiel Jadib answer. I ran into a requirement similar to question mentioned in link below. Also, used one of the answer provided to the same question.
Calling back Luis from a forward dialog
Though the above question is marked as duplicate to current, I feel the Luis context is missing from this question.
If the Activity
is created without Channel
, From
and Recipient
information, you may end up with some exception while creating a reply. So, below code will help you create the right activity and set the correct message before handing it over to Luis
Luis Intent Method
[LuisIntent("PerformSearch")]
public async Task Search(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
var msg = await activity;
msg.Value = result;
await context.Forward(new SearchDialog(), ResumeAfterSearchPerformed, msg, CancellationToken.None);
}
Resume After method for Forwarded Dialog
private async Task ResumeAfterSearchPerformed(IDialogContext context, IAwaitable<object> result)
{
var msg = await result;
var userSearchString = msg.ToString();
if (userSearchString.Equals("searchCompleted", StringComparison.InvariantCultureIgnoreCase))
{
context.Wait(MessageReceived);
}
else
{
// At this point send the message back to LUIS MessageReceived
// method to re-identify the intent and trigger the method
Activity myActivity = (Activity)context.Activity;
myActivity.Text = userSearchString;
await MessageReceived(context, Awaitable.FromItem(myActivity));
}
}
By doing above, you can easily create a reply from properly hydrated Activity
Activity reply = ((Activity)message).CreateReply();
reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
I think that calling MessageReceivedAsync
will be the way to go here. The key is to pass an IAwaitable
from the activity you are creating.
The code should be like:
await MessageReceivedAsync(context, Awaitable.FromItem(yourActivity));