public static ILocaleSpeech CreateLocale(this SkillRequest skillRequest, DictionaryLocaleSpeechStore store)
        {
            var localeSpeechFactory = new LocaleSpeechFactory(store);
            var locale = localeSpeechFactory.Create(skillRequest);

            return(locale);
        }
示例#2
0
        internal DictionaryLocaleSpeechStore SetupLanguageResources()
        {
            // Creates the locale speech store for each supported languages.
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]           = "Welcome to the skill!",
                [LanguageKeys.WelcomeReprompt]   = "You can ask help if you need instructions on how to interact with the skill",
                [LanguageKeys.Response]          = "This is just a sample answer",
                [LanguageKeys.Cancel]            = "Canceling...",
                [LanguageKeys.Help]              = "Help...",
                [LanguageKeys.Stop]              = "Bye bye!",
                [LanguageKeys.Error]             = "I'm sorry, there was an unexpected error. Please, try again later.",
                [LanguageKeys.Translate]         = "Some tweets are written in other languages, ¿do you want me to translate them?",
                [LanguageKeys.TranslateReprompt] = "¿do you want me to translate them?"
            });

            store.AddLanguage("es", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]           = "Bienvenido a la Skill de Power Twitter!",
                [LanguageKeys.WelcomeReprompt]   = "Si tiene alguna duda, por favor, diga ayuda",
                [LanguageKeys.Cancel]            = "Vale, cancelo",
                [LanguageKeys.Help]              = "Puedo decirte los tweets que marcaste como favorito en twitter, di: lee mis favoritos en inglés",
                [LanguageKeys.Stop]              = "Adiós!",
                [LanguageKeys.Error]             = "Mis disculpas, ha habido un error inesperado. Por favor, prueba de nuevo más tarde.",
                [LanguageKeys.Translate]         = "Algunos de los tweets están en otros idiomas, ¿quieres que los traduzca?",
                [LanguageKeys.TranslateReprompt] = "¿quieres que los traduzca?"
            });

            return(store);
        }
示例#3
0
        public static ILocaleSpeech SetupLanguages(SkillRequest skillRequest)
        {
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                { "WELCOME", "Welcome to the my demo skill" },
                { "THANK_YOU_INTENT", "You are welcome!" },
                { "GENERATE_NUMBER", "The next random number is {0}" },
                { "AMAZON.HelpIntent", "Ask me to generate a random number" },
                { "AMAZON.CancelIntent", "I'm stopping the request" },
                { "AMAZON.StopIntent", "Bye bye" }
            });


            store.AddLanguage("it", new Dictionary <string, object>
            {
                { "WELCOME", "Benvenuto nello skill di prova" },
                { "THANK_YOU_INTENT", "Prego" },
                { "GENERATE_NUMBER", "Il prossimo numero random è {0}" },
                { "AMAZON.HelpIntent", "Puoi chiedermi di generarti un numero random" },
                { "AMAZON.CancelIntent", "Sto interrompendo la richiesta" },
                { "AMAZON.StopIntent", "Ciao e grazie" }
            });

            var localeSpeechFactory = new LocaleSpeechFactory(store);
            var locale = localeSpeechFactory.Create(skillRequest);

            return(locale);
        }
示例#4
0
        private static DictionaryLocaleSpeechStore SetupLanguageResources()
        {
            // Creates the locale speech store for each supported languages.
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]         = "Welcome to the skill {0}!",
                [LanguageKeys.WelcomeReprompt] = "You can ask help if you need instructions on how to interact with the skill",
                [LanguageKeys.Response]        = "This is just a sample answer",
                [LanguageKeys.Cancel]          = "Canceling...",
                [LanguageKeys.Help]            = "Help...",
                [LanguageKeys.Stop]            = "Bye bye!",
                [LanguageKeys.Error]           = "I'm sorry, there was an unexpected error. Please, try again later.",
                [LanguageKeys.Quota]           = "You have {0} GB left."
            });

            store.AddLanguage("it", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]         = "Benvenuto nella skill {0}!",
                [LanguageKeys.WelcomeReprompt] = "Se vuoi informazioni sulle mie funzionalità, prova a chiedermi aiuto",
                [LanguageKeys.Response]        = "Questa è solo una risposta di prova",
                [LanguageKeys.Cancel]          = "Sto annullando...",
                [LanguageKeys.Help]            = "Aiuto...",
                [LanguageKeys.Stop]            = "A presto!",
                [LanguageKeys.Error]           = "Mi dispiace, si è verificato un errore imprevisto. Per favore, riprova di nuovo in seguito.",
                [LanguageKeys.Quota]           = "Hai a disposizione ancora {0} GB."
            });

            return(store);
        }
示例#5
0
        private static DictionaryLocaleSpeechStore SetupLanguageResources()
        {
            // Creates the locale speech store for each supported languages.
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]         = "Hello {0}, welcome to roll the solid!",
                [LanguageKeys.WelcomeReprompt] = "You can ask help if you need instructions on how to interact with the skill",
                [LanguageKeys.Response]        = "I rolled a {0} faces dice: {1}",
                [LanguageKeys.Cancel]          = "Canceling...",
                [LanguageKeys.Help]            = "You can ask to me to roll a dice with a given number of faces",
                [LanguageKeys.Stop]            = "Bye bye!",
                [LanguageKeys.Error]           = "I'm sorry, there was an unexpected error. Please, try again later."
            });

            store.AddLanguage("it", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]         = "Ciao {0}, benvenuto in tira il solido!",
                [LanguageKeys.WelcomeReprompt] = "Se vuoi informazioni sulle mie funzionalità, prova a chiedermi aiuto",
                [LanguageKeys.Response]        = "Ho lanciato un dado con {0} facce: {1}",
                [LanguageKeys.Cancel]          = "Sto annullando...",
                [LanguageKeys.Help]            = "Mi puoi chiedere di tirare un dado con un numero qualsiasi di facce",
                [LanguageKeys.Stop]            = "A presto!",
                [LanguageKeys.Error]           = "Mi dispiace, si è verificato un errore imprevisto. Per favore, riprova di nuovo in seguito."
            });

            return(store);
        }
示例#6
0
        public static ILocaleSpeech SetupLanguages(SkillRequest skillRequest)
        {
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                { "Welcome", "Welcome to the AppConsult skill!" },
                { "LastPosts", "The title of the last article is {0}" },
                { "Cancel", "I'm cancelling the request..." },
                { "Help", "You can ask me, for example, which is the last article." },
                { "Stop", "Goodbye!" }
            });

            store.AddLanguage("it", new Dictionary <string, object>
            {
                { "Welcome", "Benvenuti in Windows AppConsult!" },
                { "LastPosts", "Il titolo dell'ultimo articolo è {0}" },
                { "Cancel", "Sto annullando la richiesta..." },
                { "Help", "Puoi chiedermi, ad esempio, qual è l'ultimo articolo. " },
                { "Stop", "Alla prossima!" }
            });


            var localeSpeechFactory = new LocaleSpeechFactory(store);
            var locale = localeSpeechFactory.Create(skillRequest);

            return(locale);
        }
示例#7
0
        private static DictionaryLocaleSpeechStore SetupLanguageResources()
        {
            // Creates the locale speech store for each supported languages.
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]  = "Your welcome message",
                [LanguageKeys.Response] = "Your custom response",
                [LanguageKeys.Cancel]   = "Canceling...",
                [LanguageKeys.Help]     = "Help...",
                [LanguageKeys.Stop]     = "Bye bye...",
                [LanguageKeys.Error]    = "I'm sorry, there was an unexpected error. Please, try again later."
            });

            store.AddLanguage("it", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]  = "Il tuo messaggio di benvenuto",
                [LanguageKeys.Response] = "La tua risposta",
                [LanguageKeys.Cancel]   = "Sto annullando...",
                [LanguageKeys.Help]     = "Aiuto...",
                [LanguageKeys.Stop]     = "A presto...",
                [LanguageKeys.Error]    = "Mi dispiace, si è verificato un errore imprevisto. Per favore, riprova di nuovo in seguito."
            });

            return(store);
        }
示例#8
0
        public async Task MissingKeyThrowsException()
        {
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("fr", new Dictionary <string, object> {
            });
            await Assert.ThrowsAsync <KeyNotFoundException>(() => store.Get("fr", "test", null));
        }
示例#9
0
        public static DictionaryLocaleSpeechStore SetupLanguageResources()
        {
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage(EN_US.Language, EN_US.GetLanguage());
            store.AddLanguage(PT_BR.Language, PT_BR.GetLanguage());
            return(store);
        }
示例#10
0
        public async Task KeyWithParamsGeneratesSpeech()
        {
            var testText = "yes - a {0} test";
            var store    = new DictionaryLocaleSpeechStore();

            store.AddLanguage("fr", new Dictionary <string, object>
            {
                { "test", testText }
            });

            var result = await store.Get("fr", "test", new object[] { "simple" });

            Assert.IsType <PlainTextOutputSpeech>(result);
            Assert.Equal("yes - a simple test", ((PlainTextOutputSpeech)result).Text);
        }
示例#11
0
        public static ILocaleSpeech SetupLanguages(SkillRequest skillRequest)
        {
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                { "Welcome", "Welcome to the Sample skill!" },
                { "Stop", "Goodbye!" }
            });


            var localeSpeechFactory = new LocaleSpeechFactory(store);
            var locale = localeSpeechFactory.Create(skillRequest);

            return(locale);
        }
示例#12
0
        public static ILocaleSpeech SetupLanguages(SkillRequest skillRequest)
        {
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                { "Welcome", "Welcome to the NetCoreConf skill! I'm sorry to inform you that Carlos does not speak catalan" },
                { "event", "OK I'm sending the event to Event Grid" },
                { "Cancel", "I'm cancelling the request..." },
                { "Help", "Sorry you are on your own." },
                { "Stop", "Bye!" }
            });

            var localeSpeechFactory = new LocaleSpeechFactory(store);
            var locale = localeSpeechFactory.Create(skillRequest);

            return(locale);
        }
示例#13
0
        public static ILocaleSpeech SetupLanguages(SkillRequest skillRequest)
        {
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                { "Welcome", "Welcome to the Alimentatech skill! I'm sorry to inform you that I will not be paying for the beers after the event" },
                { "carlos", "Wait. I'm getting his bitcoin balance.... Hmmmmmm Carlos you should pay at least for your beers!!!" },
                { "event", "OK I'm sending the event to Event Grid" },
                { "Cancel", "I'm cancelling the request..." },
                { "Help", "Sorry you are on your own." },
                { "Stop", "Bye!" }
            });

            var localeSpeechFactory = new LocaleSpeechFactory(store);
            var locale = localeSpeechFactory.Create(skillRequest);

            return(locale);
        }
示例#14
0
        private static DictionaryLocaleSpeechStore SetupLanguageResources()
        {
            // Creates the locale speech store for each supported languages.
            var store = new DictionaryLocaleSpeechStore();

            store.AddLanguage("en", new Dictionary <string, object>
            {
                [LanguageKeys.Welcome]         = "Welcome to the skill!",
                [LanguageKeys.WelcomeReprompt] = "You can ask help if you need instructions on how to interact with the skill",
                [LanguageKeys.Response]        = "This is just a sample answer",
                [LanguageKeys.Cancel]          = "Canceling...",
                [LanguageKeys.Help]            = "Help...",
                [LanguageKeys.Stop]            = "Bye bye!",
                [LanguageKeys.Error]           = "I'm sorry, there was an unexpected error. Please, try again later.",
                [LanguageKeys.StartGame]       = "Lets play the game! Join everyone into the game and say lets play the game!",
                [LanguageKeys.AddPlayer]       = "New player added. Add another?"
            });

            return(store);
        }
示例#15
0
        public override async Task <ActionResult <IActionResult> > HandleAsync(SkillRequest input)
        {
            /// <summary>
            /// Bloco de segurança para verificando e validar o request enviado pela Alexa,
            /// identificando possiveis fraudes.
            /// </summary>
            var req     = HttpContext.Request;
            var isValid = await input.ValidateRequestAsync(req, _logger);

            if (!isValid)
            {
                return(new BadRequestResult());
            }


            var           request  = input.Request;
            SkillResponse response = new SkillResponse {
                Response = new ResponseBody()
            };

            DictionaryLocaleSpeechStore store = LanguagesResource.SetupLanguageResources();
            ILocaleSpeech locale = input.CreateLocale(store);

            try
            {
                if (input.Session.Attributes == null)
                {
                    input.Session.Attributes = new Dictionary <string, object>();
                }

                if (!(request is IntentRequest intentRequest))
                {
                    return(new BadRequestResult());
                }

                string IntentName = intentRequest.Intent.Name;

                if (string.IsNullOrEmpty((String)input.Session.Attributes["Auth"]))
                {
                    //Autenticação
                    string token = await HttpSenderApi.Call();

                    input.Session.Attributes["Auth"] = token;
                }

                if (intentRequest.Intent.Name == "PinUsuarioIntent")
                {
                    Account user = await new LogInPinAlexa(_repository).LogInAlexaAsync(intentRequest.Intent.Slots["pin"].Value);
                    if (user != null)
                    {
                        input.Session.Attributes.Add("pin", user.AccountId);
                        IOutputSpeech message = await locale.Get(LanguageKeys.Pinvalido, null);

                        response = ResponseBuilder.Ask(message, null, input.Session);
                        return(new OkObjectResult(response));
                    }
                    else
                    {
                        IOutputSpeech message = await locale.Get(LanguageKeys.PinInvalido, null);

                        response = ResponseBuilder.Ask(message, null, input.Session);
                        return(new OkObjectResult(response));
                    }
                }

                if (intentRequest.Intent.Name != "PinUsuarioIntent")
                {
                    response = await ExecuteIntentAlexaAsync(IntentName, input, locale);
                }
            }
            catch (Exception ex)
            {
                var message = await locale.Get(LanguageKeys.Error, null);

                response = ResponseBuilder.Tell(message);
                _logger.LogError(ex.Message + " : ", message);
            }

            return(new OkObjectResult(response));
        }