Exemplo n.º 1
0
        private async Task <DialogTurnResult> InitialStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var    query           = stepContext.Context.Activity.Text;
            string searchType      = query.Substring(0, 2);
            var    bingSearch      = new BingSearch(stepContext.Context);
            string subscriptionKey = configuration.GetValue <string>("BingSearchKey");

            switch (searchType)
            {
            case "i ":
                await bingSearch.ImageSearch(subscriptionKey, query.Substring(2));

                return(await stepContext.EndDialogAsync());

            case "v ":
                await bingSearch.VideoSearch(subscriptionKey, query.Substring(2));

                return(await stepContext.EndDialogAsync());

            case "w ":
                await bingSearch.WebSearch(subscriptionKey, query.Substring(2));

                return(await stepContext.EndDialogAsync());

            default:
                return(await stepContext.BeginDialogAsync(nameof(QnAMakerDialog), null, cancellationToken));
            }
        }