public override SkillResponse Process(IntentRequest request) { var responseText = new StringBuilder(); //We will use SSML as reponse format //https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html responseText.Append("<speak>"); var helper = new QueueHelper <Appointment>( System.Environment.GetEnvironmentVariable("AppointmentQueueConnection", System.EnvironmentVariableTarget.Process)); var appointment = helper.Receive(); if (appointment != null) { responseText.Append("<audio src = 'https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_positive_response_01.mp3'/>"); responseText.Append(Ssml.SayAs(appointment.Subject, "interjection")); responseText.Append(Ssml.SayAs(appointment.Start, true)); responseText.Append("<break/>"); } else { responseText.Append("<audio src='soundbank://soundlibrary/cartoon/amzn_sfx_boing_long_1x_01'/>"); responseText.Append(Ssml.SayAs("You got all appointments! Get to work!", "interjection")); responseText.Append("<break/>"); } responseText.Append("</speak>"); SsmlOutputSpeech speech = new SsmlOutputSpeech(); speech.Ssml = responseText.ToString(); return(ResponseBuilder.Tell(speech)); }
public override SkillResponse Process(IntentRequest request) { var responseText = new StringBuilder(); //We will use SSML as reponse format //https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html responseText.Append("<speak>"); JokesRepository repo = new JokesRepository(); var categorySlot = request.Intent.Slots["JokeCategory"]; var category = string.Empty; string jokeCategory = categorySlot.Value; if (jokeCategory != null) { //Performing similarity search! jokeCategory = JokesRepository.SelectProperCategory(jokeCategory); } var joke = JokesRepository.NextJoke(jokeCategory); if (joke != null) { responseText.Append("<audio src = 'https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_positive_response_01.mp3'/>"); responseText.Append(joke.JokeText); responseText.Append("<break/>"); } else { responseText.Append("<audio src='soundbank://soundlibrary/cartoon/amzn_sfx_boing_long_1x_01'/>"); responseText.Append(Ssml.SayAs("Ops! No Joke found!", "interjection")); responseText.Append("<break/>"); } responseText.Append("</speak>"); SsmlOutputSpeech speech = new SsmlOutputSpeech(); speech.Ssml = responseText.ToString(); return(ResponseBuilder.Tell(speech)); }
public override SkillResponse Process(IntentRequest request) { var responseText = new StringBuilder(); //We will use SSML as reponse format //https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html responseText.Append("<speak>"); try { //let´s connect as guest on Teamcity Public instance! var client = new TeamCitySharp.TeamCityClient("teamcity.jetbrains.com", true); client.ConnectAsGuest(); //By default, when a list of entities is requested, only basic fields are included into the response. //When a single entry is requested, all the fields are returned. //The complex field values can be returned in full or basic form, depending on a specific entity. //https://confluence.jetbrains.com/display/TCD18/REST+API#RESTAPI-FullandPartialResponses string projectNameToSearch = request.Intent.Slots["ProjectName"].Value; //We will do a similarity search in order to minimize spoken differences! //Cool Project: https://github.com/tylerjensen/duovia-fuzzystrings //To do so, let´s us get all available projects from Teamcity var project = client.Projects.All().OrderByDescending(item => item.Name.FuzzyMatch(projectNameToSearch)).FirstOrDefault(); if (project != null) { responseText.Append("<audio src = 'https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_positive_response_01.mp3'/>"); responseText.AppendFormat("Here is the Status of the {0} Project:", Ssml.SayAs(project.Name, "interjection")); responseText.Append("<break/>"); #region Build Information //Last Build informarion (we get only 1) //state: <queued/running/finished> //https://confluence.jetbrains.com/display/TCD18/REST+API var lastBuilds = client.Builds.AffectedProject(project.Id, 1, new List <string>() { "state:finished" }); if (lastBuilds.Any()) { //We get by ID to load the full information! var lastBuild = client.Builds.ById(lastBuilds.First().Id); var triggeredBy = string.Empty; if (lastBuild.Triggered.Type.Equals("schedule")) { triggeredBy = "automatically"; } else if (lastBuild.Triggered.Type.Equals("vcs")) { triggeredBy = "by the " + Ssml.SayAs("Version Control System", "interjection"); } else { triggeredBy = "by " + Ssml.SayAs(lastBuild.Triggered.User.Name, "interjection"); } //let us find how long ago was the build responseText.AppendFormat("Last Build, {0}, triggered {1}, happened {2}, {3}, with {4} status", Ssml.SayAs(lastBuild.BuildType.Name, "interjection"), triggeredBy, Ssml.SayAs(lastBuild.FinishDate, true), lastBuild.FinishDate.TimeAgo(), Ssml.SayAs(lastBuild.Status, "interjection")); responseText.Append("<break/>"); //Let´s collect statistics! var buildStatistics = client.Statistics.GetByBuildId(lastBuild.Id); //Default Statistics Values Provided by TeamCity //https://confluence.jetbrains.com/display/TCD18/Custom+Chart#CustomChart-listOfDefaultStatisticValues var failedTestCount = buildStatistics.FirstOrDefault(item => item.Name.Equals("FailedTestCount")); var totalTestCount = buildStatistics.FirstOrDefault(item => item.Name.Equals("TotalTestCount")); if (totalTestCount != null) { if (failedTestCount != null) { int failed = Convert.ToInt32(failedTestCount); int total = Convert.ToInt32(totalTestCount); if (failed > 0) { responseText.AppendFormat("All {0} tests passed!", Ssml.SayAs(total)); } else { responseText.AppendFormat("{0} of {1} tests did not passed", Ssml.SayAs(Ssml.SayAs(failed), "interjection"), Ssml.SayAs(total)); } } } else { responseText.Append("No automated Tests were executed"); } } else { responseText.AppendFormat("No Build Information found for {0}", projectNameToSearch); } #endregion } else { responseText.AppendFormat("{0} not found", projectNameToSearch); } responseText.Append("<break/>"); responseText.Append("That´s all. Bye."); responseText.Append("<audio src='https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_neutral_response_03.mp3'/>"); } catch { responseText.Append("<audio src='https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_negative_response_02.mp3'/>"); responseText.Append("<break/>"); responseText.Append("ATTENTION: No connection to teamcity."); responseText.Append("<break/>"); } responseText.Append("</speak>"); SsmlOutputSpeech speech = new SsmlOutputSpeech(); speech.Ssml = responseText.ToString(); return(ResponseBuilder.Tell(speech)); }