コード例 #1
0
ファイル: Skill.cs プロジェクト: thewindev/AlexaSkillsDemo
        private static async Task <IOutputSpeech> GetUserListMessage()
        {
            var names = await TypeformAPI.GetNames();

            var ssmlSpeech  = new SsmlOutputSpeech();
            var listOfNames = string.Join(',', names);

            if (names == null || names.Count == 0)
            {
                listOfNames = "there are no names";
            }
            ssmlSpeech.Ssml = $@"<speak> Here is the list of participants: <break time=""1s""/> 
                                                {listOfNames},
                                            </speak>";
            return(ssmlSpeech);
        }
コード例 #2
0
ファイル: Skill.cs プロジェクト: thewindev/AlexaSkillsDemo
        private static async Task <(bool IsHandled, SkillResponse Response)> HandleSystemIntentsAsync(IntentRequest request, ILocaleSpeech locale)
        {
            SkillResponse response = null;

            if (request.Intent.Name == IntentNames.Cancel)
            {
                var message = await locale.Get(LanguageKeys.Cancel, null);

                response = ResponseBuilder.Tell(message);
            }
            else if (request.Intent.Name == IntentNames.Help)
            {
                var message = await locale.Get(LanguageKeys.Help, null);

                response = ResponseBuilder.Ask(message, RepromptBuilder.Create(message));
            }
            else if (request.Intent.Name == IntentNames.Stop)
            {
                var message = await locale.Get(LanguageKeys.Stop, null);

                response = ResponseBuilder.Tell(message);
            }
            else if (request.Intent.Name == IntentNames.ReadList)
            {
                var message = await GetUserListMessage();

                var reprompt = new Reprompt("Do you want to hear the winner?");
                response = ResponseBuilder.Ask(message, reprompt);
            }
            else if (request.Intent.Name == IntentNames.PickWinner)
            {
                var names = await TypeformAPI.GetNames();

                var winner = names.Shuffle().FirstOrDefault();
                response = ResponseBuilder.Tell($"The winner is {winner}");
            }
            return(response != null, response);
        }