Example #1
0
        /// <summary>
        /// This method will handle the different intents
        /// </summary>
        /// <param name="input"></param>
        /// <returns>Ready-to-send SkillResponse</returns>
        private async Task <SkillResponse> HandleIntents(SkillRequest input)
        {
            var intentRequest = input.Request as IntentRequest;
            var speech        = new SsmlOutputSpeech();

            // check the name to determine what you should do
            if (intentRequest.Intent.Name.Equals("CatchAllIntent"))
            {
                var    phrase = intentRequest.Intent.Slots["phrase"].Value;
                string answer = string.Empty;

                // get an answer from QnA Maker
                using (var client = new QnaMakerClient(_config.GetValue <string>("QnAMakerSubscriptionKey")))
                {
                    var result = await client.GenerateAnswer(new Guid(_config.GetValue <string>("QnAMakerKnowledgeBaseId")), phrase);

                    answer = result.Answers[0].Answer;
                }

                speech.Ssml = $"<speak>{answer}</speak>";
                var response = ResponseBuilder.Tell(speech);
                return(response);
            }
            else
            {
                return(ErrorResponse());
            }
        }
Example #2
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            if (activity.Text.Trim() == "그만")
            {
                context.Done("주문완료");
            }
            else
            {
                string message = "";
                using (var client = new QnaMakerClient("633be6fd99a64f87b5cfd7d8486b568c"))
                {
                    var answer = await client.GenerateAnswer(new Guid("5b4c08ae-5535-4757-88a1-99014d48b483"), activity.Text);

                    message = answer.Answers[0].Answer;
                }

                await context.PostAsync(message);

                context.Wait(MessageReceivedAsync);
            }
        }