コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static SpeechletRequestEnvelope FromJson(JObject json) {
            if (json["version"] == null || json["session"] == null || json["request"] == null) {
                throw new SpeechletException("Request does not conform to schema");
            }

            if (json.Value<string>("version") != Sdk.VERSION) {
                // will still attempt to parse request content but might be useful to log a warning
            }

            SpeechletRequest request;
            JObject requestJson = json.Value<JObject>("request");
            string requestType = requestJson.Value<string>("type");
            string requestId = requestJson.Value<string>("requestId");
            DateTime timestamp = requestJson.Value<DateTime>("timestamp");
            switch (requestType) {
                case "LaunchRequest":
                    request = new LaunchRequest(requestId, timestamp);
                    break;
                case "IntentRequest":
                    request = new IntentRequest(requestId, timestamp, 
                        Intent.FromJson(requestJson.Value<JObject>("intent")));
                    break;
                case "SessionStartedRequest":
                    request = new SessionStartedRequest(requestId, timestamp);
                    break;
                case "SessionEndedRequest":
                    SessionEndedRequest.ReasonEnum reason;
                    Enum.TryParse<SessionEndedRequest.ReasonEnum>(requestJson.Value<string>("reason"), out reason);
                    request = new SessionEndedRequest(requestId, timestamp, reason);
                    break;
                default:
                    throw new ArgumentException("json");
            }

            return new SpeechletRequestEnvelope {
                Request = request,
                Session = Session.FromJson(json.Value<JObject>("session")),
                Version = json.Value<string>("version")
            };
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static SpeechletRequestEnvelope FromJson(JObject json) {
            if (json["version"] != null && json.Value<string>("version") != Sdk.VERSION) {
                throw new SpeechletException("Request must conform to 1.0 schema.");
            }

            SpeechletRequest request;
            JObject requestJson = json.Value<JObject>("request");
            string requestType = requestJson.Value<string>("type");
            string requestId = requestJson.Value<string>("requestId");
            DateTime timestamp = requestJson.Value<DateTime>("timestamp");
            switch (requestType) {
                case "LaunchRequest":
                    request = new LaunchRequest(requestId, timestamp);
                    break;
                case "IntentRequest":
                    request = new IntentRequest(requestId, timestamp, 
                        Intent.FromJson(requestJson.Value<JObject>("intent")));
                    break;
                case "SessionStartedRequest":
                    request = new SessionStartedRequest(requestId, timestamp);
                    break;
                case "SessionEndedRequest":
                    SessionEndedRequest.ReasonEnum reason;
                    Enum.TryParse<SessionEndedRequest.ReasonEnum>(requestJson.Value<string>("reason"), out reason);
                    request = new SessionEndedRequest(requestId, timestamp, reason);
                    break;
                default:
                    throw new SpeechletException("Unable to determine Request Type.");
            }

            return new SpeechletRequestEnvelope {
                Request = request,
                Session = Session.FromJson(json.Value<JObject>("session")),
                Version = json.Value<string>("version")
            };
        }
コード例 #3
0
 public abstract SpeechletResponse OnLaunch(LaunchRequest launchRequest, Session session);
コード例 #4
0
 public async Task <SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session, Context context)
 {
     return(speechlet.OnLaunch(launchRequest, session, context));
 }
コード例 #5
0
 public abstract Task <SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session);
コード例 #6
0
 public abstract Task<SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session);
コード例 #7
0
 public abstract SpeechletResponse OnLaunch(LaunchRequest launchRequest, Session session);
コード例 #8
0
 public override SpeechletResponse OnLaunch(LaunchRequest request, Session session) {
     Log.Info("OnLaunch requestId={0}, sessionId={1}", request.RequestId, session.SessionId);
     return GetWelcomeResponse();
 }
コード例 #9
0
        public override SpeechletResponse OnLaunch(LaunchRequest request, Session session)
        {
            var response = new SpeechletResponse();

            return response;
        }
コード例 #10
0
 public override SpeechletResponse OnLaunch(LaunchRequest request, Session session)
 {
     return GetWelcomeResponse();
 }