public async Task <Speaker> GetSpeaker(int speakerId, bool?includeDetails = null)
        {
            try
            {
                var speaker =
                    await _codeCampService.GetSpeaker(speakerId, includeDetails);

                return(speaker);
            }
            catch (Exception exception)
            {
                SendErrorMessage(exception);

                return(null);
            }
        }
示例#2
0
        public async Task <SkillResponse> FunctionHandler(SkillRequest input, ILambdaContext context)
        {
            var requestType   = input.GetRequestType();
            var intentRequest = input.Request as IntentRequest;

            if (requestType == typeof(Alexa.NET.Request.Type.LaunchRequest))
            {
                return(ResponseBuilder.Tell(Prompts.Greetings.PickRandom()));
            }
            else if (intentRequest?.Intent.Name == "SpeakerInfo")
            {
                try
                {
                    var speakerName = intentRequest.Intent.Slots["SpeakerName"].Value;

                    var codeCampApi = new CodeCampApi();
                    var speaker     = await codeCampApi.GetSpeaker(speakerName);

                    if (speaker != null)
                    {
                        var info = speaker.ToString();
                        return(ResponseBuilder.TellWithCard(info, speaker.FullName, info));
                    }
                }
                catch
                {
                    // ignore, fall back to "sorry"
                }
            }
            else if (intentRequest?.Intent.Name == "AMAZON.HelpIntent")
            {
                var help = Prompts.Help.PickRandom();
                return(ResponseBuilder.TellWithCard(help, "Help", help));
            }

            return(ResponseBuilder.Tell(Prompts.Sorry.PickRandom()));
        }