예제 #1
0
        public async Task ConsultaServicio(IDialogContext context, LuisResult result)
        {
            var reply = context.MakeMessage();

            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;

            var estadoRespuesta2 = "False";

            context.PrivateConversationData.SetValue <string>("EstadoRespuesta", estadoRespuesta2);
            var estadoPregunta2 = "False";

            context.PrivateConversationData.SetValue <string>("EstadoPregunta", estadoPregunta2);

            // Se detectó el Servicio de la consulta
            foreach (var serv in result.Entities.Where(Entity => Entity.Type == "Servicio"))
            {
                var servicio = serv.Entity.ToLower().Replace(" ", "");

                if (servicio == "word")
                {
                    reply.Attachments = Respuestas.GetDestacadosWord();
                    await context.PostAsync($"Entonces, ¿En qué te puedo ayudar respecto a {servicio}?");

                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", "Word");
                    context.Wait(MessageReceived);
                    return;
                }
                else if (servicio == "excel")
                {
                    reply.Attachments = Respuestas.GetDestacadosExcel();
                    await context.PostAsync($"Entonces, ¿En qué te puedo ayudar respecto a {servicio}?");

                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", "Excel");
                    context.Wait(MessageReceived);
                    return;
                }
                else if (servicio == "powerpoint")
                {
                    reply.Attachments = Respuestas.GetDestacadosPowerPoint();
                    await context.PostAsync($"Entonces, ¿En qué te puedo ayudar respecto a {servicio}?");

                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", "PowerPoint");
                    context.Wait(MessageReceived);
                    return;
                }
                else if (servicio == "outlook")
                {
                    reply.Attachments = Respuestas.GetDestacadosOutlook();
                    await context.PostAsync($"Entonces, ¿En qué te puedo ayudar respecto a {servicio}?");

                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", "Outlook");
                    context.Wait(MessageReceived);
                    return;
                }
                else if (servicio == "onedrive")
                {
                    reply.Attachments = Respuestas.GetDestacadosOneDrive();
                    await context.PostAsync($"Entonces, ¿En qué te puedo ayudar respecto a {servicio}?");

                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", "OneDrive");
                    context.Wait(MessageReceived);
                    return;
                }
                else if (servicio == "onenote")
                {
                    reply.Attachments = Respuestas.GetDestacadosOneNote();
                    await context.PostAsync($"Entonces, ¿En qué te puedo ayudar respecto a {servicio}?");

                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", "OneNote");
                    context.Wait(MessageReceived);
                    return;
                }
                else
                {
                    var formularioRegistro1 = new FormDialog <ConsultaServicio>(new ConsultaServicio(), this.consultaServicio, FormOptions.PromptInStart);
                    context.Call <ConsultaServicio>(formularioRegistro1, Callback);
                }
            }
            var formularioRegistro = new FormDialog <ConsultaServicio>(new ConsultaServicio(), this.consultaServicio, FormOptions.PromptInStart);

            context.Call <ConsultaServicio>(formularioRegistro, Callback);
        }
예제 #2
0
        public static IForm <ConsultaServicio> BuildForm()
        {
            OnCompletionAsyncDelegate <ConsultaServicio> processOrder = async(context, order) =>
            {
                var reply = context.MakeMessage();
                reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                var estadoRespuesta2 = "False";
                context.PrivateConversationData.SetValue <string>("EstadoRespuesta", estadoRespuesta2);
                var estadoPregunta2 = "False";
                context.PrivateConversationData.SetValue <string>("EstadoPregunta", estadoPregunta2);

                var name     = "Usuario";
                var servicio = "Servicio";
                context.UserData.TryGetValue <string>("Name", out name);
                context.PrivateConversationData.SetValue <string>("tipoDeServicio", order.TipoDeServicio.ToString());
                context.PrivateConversationData.TryGetValue <string>("tipoDeServicio", out servicio);

                await context.PostAsync($"Entonces estimado {name}, ¿En qué te puedo ayudar respecto a {servicio}? ");

                if (servicio == "Word")
                {
                    reply.Attachments = Respuestas.GetDestacadosWord();
                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", "Servicio");
                    return;
                }
                else if (servicio == "Excel")
                {
                    reply.Attachments = Respuestas.GetDestacadosExcel();
                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", servicio);
                    return;
                }
                else if (servicio == "PowerPoint")
                {
                    reply.Attachments = Respuestas.GetDestacadosPowerPoint();
                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", servicio);
                    return;
                }
                else if (servicio == "Outlook")
                {
                    reply.Attachments = Respuestas.GetDestacadosOutlook();
                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", servicio);
                    return;
                }
                else if (servicio == "OneDrive")
                {
                    reply.Attachments = Respuestas.GetDestacadosOneDrive();
                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", servicio);
                    return;
                }
                else if (servicio == "OneNote")
                {
                    reply.Attachments = Respuestas.GetDestacadosOneNote();
                    await context.PostAsync($"Estos son algunos temas destacados de {servicio}");

                    await context.PostAsync(reply);

                    context.PrivateConversationData.SetValue <string>("tipoServicio", servicio);
                    return;
                }
                else
                {
                    // Error: No se guardo el servicio del usuario
                    await context.PostAsync("Usted no debería estar aquí");

                    return;
                }
            };

            return(new FormBuilder <ConsultaServicio>()
                   .Message("Soy el bot de soporte para Office")
                   .Field(nameof(TipoDeServicio))
                   .Confirm("El servicio que has seleccionado es {TipoDeServicio}? (Si/No)")
                   .OnCompletion(processOrder)
                   .Build());
        }