Exemple #1
0
        /*private async Task IncidentTicketGeneration(IDialogContext context, IAwaitable<DetailedFormModel> result)
        {

            var sentence = await result;

            /**
             * Connection string for SnowIncident ticket creation.
             **/

            /*string DetailDescription = sentence.Desc + " the services are running on server " + sentence.ServerName + ", using " + sentence.DatabaseName + " database and the" + sentence.MiddlewareName + " service";

            String incidentNo = string.Empty;

            incidentNo = Logger.CreateIncidentServiceNow(sentence.Desc, DetailDescription, sentence.CategoryName);

            Console.WriteLine(incidentNo);
            await context.PostAsync("Your ticket has been raised successfully, " + incidentNo + " your token id for the raised ticket");
            await context.PostAsync("Please keep the note of above token number. as it would be used for future references");
        }*/

        private async Task getQnAResponse(IDialogContext context, IAwaitable<string> result)
        {
            var response = await result;
            var subscriptionKey = ConfigurationManager.AppSettings["QnaSubscriptionkey"];
            var knowledgeBaseId = ConfigurationManager.AppSettings["QnaKnowledgebaseId"];

            var responseQuery = new QnAMakerDialog.QnAMakerDialog().GetQnAMakerResponse(response, subscriptionKey, knowledgeBaseId);

            var responseAnswers = responseQuery.answers.FirstOrDefault();
            if (responseAnswers != null && responseAnswers.score >= double.Parse(ConfigurationManager.AppSettings["QnAScore"]))
            {
                await context.PostAsync(responseAnswers.answer);
            }
            else
            {
                //await context.PostAsync($"We could not find a solution for your problem. Please raise an incident ticket for this.");
                /*await context.PostAsync("So please answer some question below to find a suitable solution for you");
                var DetailForm = new FormDialog<DetailedFormModel>(new DetailedFormModel(), DetailedFormModel.BuildForm, FormOptions.PromptInStart);
                context.Call(DetailForm, IncidentTicketGeneration);
                await context.PostAsync($"We could not find a solution for your problem. I have raised an incident ticket for this.");*/

                await context.PostAsync($"We could not find a solution for your problem.");
                context.Call(new DetailFormDialog(response), childDialog);

            }

            //context.Done(this);
            //getKeyPhrases(responseAnswers)
        }
Exemple #2
0
        private async Task getKeyPhrases(IDialogContext context, IAwaitable<TokenModel> result)
        {
            var sentence = await result;
            string phrasesString = sentence.IssueDescription;
            var phrases = await KeyPhraseAnalytics.ExtractPhraseAsync(phrasesString);
            string phraseResult = String.Join(",", phrases.ToArray());

            //await context.PostAsync($"The key phrases extracted are: {phraseResult}");
            await context.PostAsync($"Thanks for sharing the details");
            await context.PostAsync($"Let me check for a appropriate solution for your problem");

            /**
             * To call the the QnA maker knowledge base to get the appropraite response for the user queries
             * **/
            try
            {
                var subscriptionKey = ConfigurationManager.AppSettings["QnaSubscriptionkey"];
                var knowledgeBaseId = ConfigurationManager.AppSettings["QnaKnowledgebaseId"];

                var responseQuery = new QnAMakerDialog.QnAMakerDialog().GetQnAMakerResponse(phraseResult, subscriptionKey, knowledgeBaseId);

                var responseAnswers = responseQuery.answers.FirstOrDefault();

                //if-else-if condition for checking the knowledge base
                if(responseAnswers != null && responseAnswers.score >= double.Parse(ConfigurationManager.AppSettings["QnAScore"]))
                {
                    await context.PostAsync(responseAnswers.answer);
                }
                else if(responseAnswers !=null && responseAnswers.score < double.Parse(ConfigurationManager.AppSettings["QnAScore"]) &&
                    responseAnswers.score > 30.0)
                {
                    //await context.PostAsync($"Please enter a more detailed description for the problem");

                    PromptDialog.Text(
                        context: context,
                        resume: getQnAResponse,
                        prompt: "Please enter a more detailed description for the problem",
                        retry: "I didn't understand that. Please try again"
                        );
                }
                else
                {
                    await context.PostAsync($"We could not find a solution for your problem.");

                    //await context.PostAsync("So please answer some question below to find a suitable solution for you");
                    //var DetailForm = new FormDialog<DetailedFormModel>(new DetailedFormModel(), DetailedFormModel.BuildForm, FormOptions.PromptInStart);
                    context.Call(new DetailFormDialog(phrasesString),childDialog);

                }

            }
            
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
        private async Task callFaqService(IDialogContext context, IAwaitable <string> result)
        {
            var userAnswer = await result;

            //connection to the qnaMaker api which contains the Knowledge base in the form of question and answer format

            // use try and catch block

            try
            {
                //subscription key for the QnA maker kb stored in the web config file.

                var subscriptionkey = ConfigurationManager.AppSettings["QnASubscriptionKey"];

                /*
                 * knowledge base id used to connect to the kb in the qnamaker details can be found in the
                 * http call of qnamaker website
                 **/

                var knowledgeBaseId = ConfigurationManager.AppSettings["QnAKnowledgeBaseId"];

                // call the GetQnaResponse method of QnAMakerDialog

                var query = new QnAMakerDialog.QnAMakerDialog().GetQnAResponse(userAnswer, subscriptionkey, knowledgeBaseId);

                var response = query.ans.FirstOrDefault();

                if (response != null && response.score >= 50.0)
                {
                    await context.PostAsync(response.ans);
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }