Search code examples
c#botframeworkazure-language-understanding

BOT framework - progress message


I have created BOT framework in C# and succeeded on it, I want to enable the following feature:

One of my Intent Utterance has to hit the API which takes a while to return the result set.. So i want to handle the wait time in my BOT saying that 'Please hold on a moment , I am getting the results'

How to handle this in the code? Here is my code snippet:

public async Task GetClassListIntent(IDialogContext context, LuisResult result)
{
    try
    {
        var message = context.MakeMessage();

        ClassService classService = new ClassService();
        IList< Result> Results = await classService.GetResults(criteria);

        if (Results != null && Results.Count > 0)
        {
            foreach (var classresult in Results)
            {
                var attachment = Card.GetClassSearchResult(classresult);

                message.Attachments.Add(attachment);
            }
            message.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            await context.PostAsync(message);
        }
        else
        {
            await context.PostAsync("No results found. Please provide more search details ");
            await context.PostAsync(message);
        }
    }
    ...
}

Solution

  • Add your progress message at the beginning of your processing

    await context.PostAsync("Please hold on a moment , I am getting the results");