コード例 #1
0
ファイル: EchoDialog.cs プロジェクト: nirajkmr007/AiBuddy
        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var message = await argument;

            if (message.Text == "reset")
            {
                PromptDialog.Confirm(
                    context,
                    AfterResetAsync,
                    "Are you sure you want to reset the count?",
                    "Didn't get that!",
                    promptStyle: PromptStyle.Auto);
            }
            else
            {
                string intent = await Luis.MakeRequest(message.Text);

                if (intent == "None")
                {
                    await context.PostAsync($"{this.count++}: what {message.Text} means? {Environment.NewLine} I am a Just Born not mature enough to understand that.");

                    context.Wait(MessageReceivedAsync);
                }
                else
                {
                    await context.PostAsync($"{this.count++}: {intent}");

                    context.Wait(MessageReceivedAsync);
                }
            }
        }
コード例 #2
0
        private static async Task luis(IDialogContext context, IAwaitable <object> result)
        {
            const string idLuis  = "3f85c553-3eec-4ff1-8a8d-d409800e7142";
            const string keyLuis = "bb0918a4853048fa9e03090b9649fee7";

            var    message = await result as Activity;
            string query   = message.Text;

            HttpClient client   = new HttpClient();
            string     response = await client.GetStringAsync(new Uri($"https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/{idLuis}?subscription-key={keyLuis}&verbose=true&timezoneOffset=0&q={query}"));

            Luis luis = JsonConvert.DeserializeObject <Luis>(response);

            switch (luis.intents[0].intent)
            {
            case "saludo":
                await SaludoDialog.saludo(context, result);

                break;

            case "despedida":
                await DespedidaDialog.despedida(context, result);

                break;

            case "recomendacion":
                await LuisDialog.recomendacion(context, result, luis);

                break;

            case "buscar_producto":
                await LuisDialog.buscar_producto(context, result, luis);

                break;

            case "None":
                await context.PostAsync("creo que no te he entendido");

                context.Wait(router);
                break;
            }
        }