private IContainer BuildContainer(IntentFactory intentFactory, IntentParameters parameters) { var builder = new ContainerBuilder(); builder.Register(a => parameters); builder.Register(a => intentFactory).SingleInstance(); builder.Register(a => IntentNames() ?? new IntentNames()).SingleInstance(); intentFactory.RegisterIntents(builder); RegisterDependencies(builder, parameters); return(builder.Build()); }
public SkillResponse Run(SkillRequest input, IntentParameters parameters) { AlexaIntent intentToRun = null; Dictionary<string, Slot> slots = null; string intentName = ""; if (input.GetRequestType() == typeof(LaunchRequest)) { intentToRun = _intentFactory.LaunchIntent(); slots = new Dictionary<string, Slot>(); } else if (input.GetRequestType() == typeof(IntentRequest)) { var intentRequest = (IntentRequest)input.Request; var intents = _intentFactory.Intents(); slots = intentRequest.Intent.Slots; intentName = intentRequest.Intent.Name; if (intents.ContainsKey(intentRequest.Intent.Name)) { intentToRun = intents[intentRequest.Intent.Name]; } else { intentToRun = _intentFactory.HelpIntent(); } } if (intentToRun == null) { return ResponseBuilder.Tell(new PlainTextOutputSpeech { Text = String.Format(_noIntentMatchedText, intentName) }); } var skillResponse = intentToRun.GetResponse(slots); skillResponse.Response.ShouldEndSession = intentToRun.ShouldEndSession; parameters.CommandQueue.Enqueue(intentToRun.CommandDefinition()); return skillResponse; }
protected virtual void RegisterDependencies(ContainerBuilder builder, IntentParameters parameters) { }
protected virtual SkillResponse FunctionInit(IntentParameters parameters) { return(null); }