コード例 #1
0
        public async Task InitialUserQuery(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var response = await argument;
            await context.SendTypingAcitivity();

            context.PrivateConversationData.SetValue(StateConstants.Topic, response.Text);
            var rk = LuisFetcher.GetAnswers(response.Text.ToString()).Result;
            await context.SendTypingAcitivity();

            var selectedIntent = topOnCallTopics.FirstOrDefault(cc => cc.Equals(rk.TopScoringIntent.IntentIntent) && rk.TopScoringIntent.Score > Constants.MaxLUIScore);

            context.PrivateConversationData.SetValue(StateConstants.IntentQuery, response.Text);

            if (selectedIntent != null)
            {
                context.PrivateConversationData.SetValue(StateConstants.Intent, selectedIntent);
                var re = context.MakeMessage();
                re.Text = "BElow are some of the related topics";
                var qnAResults = QnAMaker.QnAFetchter.GetAnswers("#System get #" + selectedIntent + " bot synonyms").Result;
                await context.SendTypingAcitivity();

                ResultCard resultCard = new ResultCard();
                resultCard.CustomQnACard(re, qnAResults);
                await context.PostAsync(re);

                context.Wait(HandleBotSynonyms);
            }
            else if (selectedIntent == null && rk.TopScoringIntent.IntentIntent.Equals("greeting") && rk.TopScoringIntent.Score > Constants.MaxLUIScore)
            {
                PersonalityChatOptions personalityChatOptions = new PersonalityChatOptions(string.Empty, PersonalityChatPersona.Professional);
                PersonalityChatService personalityChatService = new PersonalityChatService(personalityChatOptions);

                var    PersonalityChatResults = Task.FromResult <PersonalityChatResults>(await personalityChatService.QueryServiceAsync(rk.Query));
                string botOutput = PersonalityChatResults?.Result.ScenarioList?.FirstOrDefault()?.Responses?.FirstOrDefault() ?? "";

                if (!string.IsNullOrEmpty(botOutput))
                {
                    await context.PostAsync(botOutput);

                    var reply = context.MakeMessage();
                    reply.Attachments = new List <Attachment>();
                    reply.Attachments.Add(ResultCard.ShowGreetingCard());
                    var k = QnAMaker.QnAFetchter.GetAnswers("Get Bot Options").Result;
                    await context.PostAsync(reply);
                }
                else
                {
                    await context.SendTypingAcitivity();

                    await this.HandleBotSynonyms(context, argument);
                }
            }
            else
            {
                response.Text = others;
                await this.HandleBotSynonyms(context, argument);
            }
        }
コード例 #2
0
        public async Task InitializeFord(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var response = await argument;
            var rk       = LuisFetcher.GetAnswers(response.Text.ToString()).Result;
            await context.SendTypingAcitivity();

            switch (rk.TopScoringIntent.IntentIntent)
            {
            case "FordSiteInfo":
                var answer = QnAMaker.QnAFetchter.GetAnswers("whats this site?").
                             Result.Answers[0].AnswerAnswer;
                MediaUrl mediaUrl = new MediaUrl("https://marczak.io/images/botseries-rich-cards/CreatingBot.mp4");
                await context.PostAsync(answer);

                //var k = ResultCard.GetVideoCard("Welcome to Leadership Learning Site", "", "Ford HR ", mediaUrl);
                //var reply = context.MakeMessage();
                //reply.Attachments = new List<Attachment>();
                //reply.Attachments.Add(k);
                //await context.PostAsync(reply);
                context.Done("competed");
                break;

            case "FordCurrentAffair":
                answer = QnAMaker.QnAFetchter.GetAnswers("Whats cooking?").
                         Result.Answers[0].AnswerAnswer;
                await context.PostAsync(answer);

                ResultCard result = new ResultCard();
                var        reply  = context.MakeMessage();
                reply.Text             = "Would you like to learn more?";
                reply.SuggestedActions = ResultCard.GetSuggestedQnAActions(new[] { "yes", "no" });
                await context.PostAsync(reply);

                context.Wait(handleSiteInfo);
                break;

            case "FordModels":
                ResultCard resultCard = new ResultCard();
                reply = context.MakeMessage();
                resultCard.ConvertToOptionsCard(reply, new[] { "Critical Thinking", "Design Thinking", "System Thinking" }, new[] { "http://syedamrullahravepoc.azurewebsites.net/content/criticalthinking.png", "http://syedamrullahravepoc.azurewebsites.net/content/designthinking.png", "http://syedamrullahravepoc.azurewebsites.net/content/systemthinking.png" });
                await context.PostAsync(reply);

                context.Wait(FordModelSelection);
                break;

            case "FordTraining":
                result                 = new ResultCard();
                reply                  = context.MakeMessage();
                reply.Text             = "If training was to be made available what would be your preference be:";
                reply.SuggestedActions = ResultCard.GetSuggestedQnAActions(new[] { "Webex Training", "Class Room" });
                await context.PostAsync(reply);

                context.Wait(handleLocationTraining);
                break;

            default: break;
            }
        }