Example #1
0
        public override async Task OnSessionEndedAsync(SessionEndedRequest request, Session session)
        {
            Task t = AskTeenageQueue.AddAsync(JsonConvert.SerializeObject(request));

            Logger.Info($"OnSessionStarted requestId={request.RequestId}, sessionId={session.SessionId}");
            await t;
        }
Example #2
0
 public override async Task <SpeechletResponse> OnLaunchAsync(LaunchRequest request, Session session)
 {
     try
     {
         await AskTeenageQueue.AddAsync(JsonConvert.SerializeObject(request));
     }
     catch (Exception ex)
     {
         Logger.Error($"Exception: {ex.ToString()}");
     }
     Logger.Info($"OnSessionStarted requestId={request.RequestId}, sessionId={session.SessionId}");
     return(await GetWelcomeResponseAsync());
 }
Example #3
0
        public override async Task <SpeechletResponse> OnIntentAsync(IntentRequest request, Session session)
        {
            // Get intent from the request object.
            Intent intent     = request.Intent;
            string intentName = (intent != null) ? intent.Name : null;

            Logger.Info($"OnIntent intentName={intentName} requestId={request.RequestId}, sessionId={session.SessionId}");
            var tasks = new List <Task>();

            tasks.Add(AskTeenageQueue.AddAsync(JsonConvert.SerializeObject(request)));
            tasks.Add(AskTeenageQueue.AddAsync(JsonConvert.SerializeObject(session)));


            // Note: If the session is started with an intent, no welcome message will be rendered;
            // but, the intent specific response will be returned and the session terminated.

            switch (intentName)
            {
            case "AMAZON.CancelIntent":
                return(await BuildAskTeenagerExitResponseAsync(intent, session));

            case "AMAZON.StopIntent":
                return(await BuildAskTeenagerExitResponseAsync(intent, session));

            case "AMAZON.HelpIntent":
                return(await BuildAskTeenagerHelpResponseAsync(intent, session));

            case "AskTeenagerOpinion":
                return(await BuildAskTeenagerOpinionResponseAsync(intent, session));

            case "AskTeenagerStatus":
                return(await BuildAskTeenagerStatusResponseAsync(intent, session));

            default:
                throw new SpeechletException("Invalid Intent");
            }
        }