예제 #1
0
        public async Task StartAsync()
        {
            var estadoPregunta2 = "False";
            var estadoRespuesta2 = "False";
            context.PrivateConversationData.SetValue<string>("EstadoPregunta", estadoPregunta2);
            context.PrivateConversationData.SetValue<string>("EstadoRespuesta", estadoRespuesta2);

            Random rnd = new Random();
            // Dudas que puede generar el bot
            string[] none = {
                "Perdón, no entiendo lo que estas diciendo \U0001F615",
                "Perdón, no entendí lo que necesitas \U0001F615",
                "Perdón, no entendí lo que quieres decir \U0001F615",
                "Perdón, no entendí lo que necesitas \U0001F615",
            };

            // Generate random indexes for none
            int mIndex = rnd.Next(0, none.Length);

            var reply = context.MakeMessage();
            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            reply.Attachments = Respuestas.GetConsulta();

            // Display the result.
            await context.PostAsync(none[mIndex]);
            await context.PostAsync(reply);
            return;
        }
예제 #2
0
        private static async Task Respond(IDialogContext context)
        {
            var estadoRespuesta2 = "False";

            context.PrivateConversationData.SetValue <string>("EstadoRespuesta", estadoRespuesta2);

            Random rnd = new Random();

            // Saludos que puede generar el bot
            string[] saludos =
            {
                "¡Hola! {0}, ¿en qué te puedo ayudar? \U0001F601",
                "¡Bienvenido! {0} \U0001F601 ¿en qué te puedo ayudar?",
                "Qué tal {0} \U0001F601, ¿cómo puedo ayudarte?",
                "Buen día {0} \U0001F601, cuéntame, ¿en que puedo ayudarte?"
            };

            // Generate random indexes for saludos
            int mIndex = rnd.Next(0, saludos.Length);

            var userName = String.Empty;

            context.UserData.TryGetValue <string>("Name", out userName);
            if (string.IsNullOrEmpty(userName))
            {
                await context.PostAsync("¿Cual es tu nombre?");

                context.UserData.SetValue <bool>("GetName", true);
            }
            else
            {
                var reply = context.MakeMessage();
                reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;

                // Display the result.
                await context.PostAsync(String.Format(saludos[mIndex], userName));

                reply.Attachments = Respuestas.GetConsulta();
                await context.PostAsync(reply);
            }
        }