Esempio n. 1
0
        public async Task None(IDialogContext context, LuisResult result)
        {
            //直接連LUIS
            var msg     = ActivityTypes.Message;
            var luisRes = await GetIntentsEntities(msg);

            // You could choose to handle the "none" intent here, or in the bot code
            //var reply = new DataAccessLayer().GetInfo(luisRes);
            Cognitive.LUIS.LuisResult Luis = luisRes;
            var reply = Luis.Intents;

            string[] intent = new string[5];
            if (Luis.Intents.Count() != 0)
            {
                for (int i = 0; i < reply.Count(); i++)
                {
                    for (int j = 0; j < reply.Count() - 1; j++)
                    {
                        if (reply[j].Score > reply[j].Score)
                        {
                            var temp = reply[j];
                            reply[j]     = reply[j + 1];
                            reply[j + 1] = temp;
                        }
                    }
                }
                for (int i = 0; i < 5; i++)
                {
                    intent[i] = SetUT(reply[i + 1].Name);
                    //intent[i] =reply[i + 1].Name;
                }
            }

            //按鍵HEROCARD
            Activity replyToConversation =
                ShowButtons(context, "請問你要問的問題是下列何者?", intent);
            await context.PostAsync(replyToConversation);

            context.Wait(MessageReceived);
            //一般HEROCARD
            //var message = context.MakeMessage();
            //var attachment = GetHeroCard();
            //message.Attachments.Add(attachment);
            //await context.PostAsync(message);
            //context.Wait(MessageReceived);
            //一般回答
            // string message = $"不好意思,我不太了解你的問題,請問你想問的是";
            //await context.PostAsync(message);
            //context.Wait(MessageReceived);
        }
Esempio n. 2
0
        public async Task <Cognitive.LUIS.LuisResult> GetIntentsEntities(string msg)
        {
            string appId           = "cfb93013-49d1-4d5e-a433-79f324633c66";
            string subscriptionKey = "579203d2883e4c909cc002dbe5fbfaba";
            bool   preview         = true;
            string textToPredict   = msg;

            try
            {
                LuisClient client             = new LuisClient(appId, subscriptionKey, preview);
                Cognitive.LUIS.LuisResult res = await client.Predict(textToPredict);

                return(res);
            }
            catch (System.Exception exception)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
        }