示例#1
0
        public static void Register(HttpConfiguration config)
        {
            IntentHandlers = new IntentsList
            {
                { "ProviderIntent", (cm) => Handlers.ProviderIntent.Process(cm) },
                { "AMAZON.YesIntent", (cm) => Handlers.YesIntent.Process(cm) },
                { "AMAZON.NoIntent", (cm) => Handlers.NoIntent.Process(cm) },
                { "AMAZON.CancelIntent", (cm) => Handlers.CancelIntent.Process(cm) },
                { "AMAZON.StopIntent", (cm) => Handlers.CancelIntent.Process(cm) },
                { "AMAZON.HelpIntent", (cm) => Handlers.HelpIntent.Process(cm) },
                { "DefaultWelcomeIntent", (cm) => Handlers.WelcomeIntent.Process(cm) }
            };
            // Json settings
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.Formatting        = Formatting.Indented;
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                Formatting        = Newtonsoft.Json.Formatting.Indented,
                NullValueHandling = NullValueHandling.Ignore,
            };

            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
        public static void Register(HttpConfiguration config)
        {
            string credential_path = HostingEnvironment.MapPath(@"~/App_Data/ServiceKey.json");

            System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credential_path);

            //Register Intents
            IntentHandlers = new IntentsList
            {
                { "AMAZON.StopIntent", (cm) => Handlers.CancelIntent.Process(cm) },
                { "AMAZON.CancelIntent", (cm) => Handlers.CancelIntent.Process(cm) },
                { "AMAZON.HelpIntent", (cm) => Handlers.HelpIntent.Process(cm) },
                { "YesIntent", (cm) => Handlers.YesIntent.Process(cm) },
                { "ReservationsIntent", (cm) => Handlers.ReservationsIntent.Process(cm) },
                { "DefaultWelcomeIntent", (cm) => Handlers.WelcomeIntent.Process(cm) }
            };

            // Json settings
            config.Formatters.JsonFormatter.SerializerSettings.DateParseHandling = DateParseHandling.DateTimeOffset;
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.Formatting        = Formatting.Indented;
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                DateParseHandling = DateParseHandling.DateTimeOffset,
                ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                Formatting        = Newtonsoft.Json.Formatting.Indented,
                NullValueHandling = NullValueHandling.Ignore,
            };

            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
示例#3
0
        public static void Register(HttpConfiguration config)
        {
            IntentHandlers = new IntentsList
            {
                //Register intents here
                { "Question4Intent", (cm) => Handlers.Question4Intent.Process(cm) },
                { "Question2NoIntent", (cm) => Handlers.Question2NoIntent.Process(cm) },
                { "Question2YesIntent", (cm) => Handlers.Question2YesIntent.Process(cm) },
                { "Question3Intent", (cm) => Handlers.Question3Intent.Process(cm) },
                { "Question2IntentFallback", (cm) => Handlers.Question2IntentFallback.Process(cm) },
                { "Question2Intent", (cm) => Handlers.Question2Intent.Process(cm) },
                { "StartConversationIntentFallbackTo2", (cm) => Handlers.StartConversationIntentFallbackTo2.Process(cm) },
                { "StartConversationIntentFallback", (cm) => Handlers.StartConversationIntentFallback.Process(cm) },
                { "YesIntentDefaultWelcome", (cm) => Handlers.YesIntent.Process(cm) },
                { "StartConversationIntent", (cm) => Handlers.SecretIntent.Process(cm) },
                { "DefaultWelcomeIntent", (cm) => Handlers.WelcomeIntent.Process(cm) }
            };

            // Json settings
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.Formatting        = Formatting.Indented;
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                Formatting        = Newtonsoft.Json.Formatting.Indented,
                NullValueHandling = NullValueHandling.Ignore,
            };

            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
        public static void Register(HttpConfiguration config)
        {
            IntentHandlers = new IntentsList
            {
                {
                    "BookATableIntent", (mo) => Handlers.BookATableIntent.Process(mo)
                },
                {
                    "WelcomeIntent", (mo) => Handlers.WelcomeIntent.Process(mo)
                }
            };
            // Json settings
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.Formatting        = Formatting.Indented;
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                Formatting        = Newtonsoft.Json.Formatting.Indented,
                NullValueHandling = NullValueHandling.Ignore,
            };

            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");

            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
        }
示例#5
0
 /// <summary>
 /// Use this method to process a list of all custom intent handler. This will remove all previous built-in and custom intents.
 /// </summary>
 /// <param name="intentHandlers">List of new intent handlers.</param>
 /// <returns>Alexa.Models.Response object.</returns>
 public dynamic Process(IntentsList intentsList)
 {
     IntentsList = intentsList;
     return(Process());
 }