using System; using System.Collections.Generic; using System.Text; using System.Text.Json; using Amazon.Lambda.Core; using Amazon.Lambda.LexEvents; namespace BlueprintBaseName._1 { /// /// Base class for intent processors. /// public abstract class AbstractIntentProcessor : IIntentProcessor { internal const string MESSAGE_CONTENT_TYPE = "PlainText"; /// /// Main method for proccessing the lex event for the intent. /// /// /// /// public abstract LexResponse Process(LexEvent lexEvent, ILambdaContext context); protected string SerializeReservation(FlowerOrder order) { return JsonSerializer.Serialize(order, new JsonSerializerOptions { IgnoreNullValues = true }); } protected FlowerOrder DeserializeReservation(string json) { return JsonSerializer.Deserialize(json); } protected LexResponse Close(IDictionary sessionAttributes, string fulfillmentState, LexResponse.LexMessage message) { return new LexResponse { SessionAttributes = sessionAttributes, DialogAction = new LexResponse.LexDialogAction { Type = "Close", FulfillmentState = fulfillmentState, Message = message } }; } protected LexResponse Delegate(IDictionary sessionAttributes, IDictionary slots) { return new LexResponse { SessionAttributes = sessionAttributes, DialogAction = new LexResponse.LexDialogAction { Type = "Delegate", Slots = slots } }; } protected LexResponse ElicitSlot(IDictionary sessionAttributes, string intentName, IDictionary slots, string slotToElicit, LexResponse.LexMessage message) { return new LexResponse { SessionAttributes = sessionAttributes, DialogAction = new LexResponse.LexDialogAction { Type = "ElicitSlot", IntentName = intentName, Slots = slots, SlotToElicit = slotToElicit, Message = message } }; } protected LexResponse ConfirmIntent(IDictionary sessionAttributes, string intentName, IDictionary slots, LexResponse.LexMessage message) { return new LexResponse { SessionAttributes = sessionAttributes, DialogAction = new LexResponse.LexDialogAction { Type = "ConfirmIntent", IntentName = intentName, Slots = slots, Message = message } }; } } }