private SpeechletResponse ModelInfo(Intent intent, Session session) { // Get the slots from the intent. Dictionary <string, Slot> slots = intent.Slots; // Get the model slot from the list slots. Slot modelSlot = slots[MODEL_SLOT]; string speechOutput = ""; // Check for name and create output to user. if (modelSlot != null) { // Store the user's name in the Session and create response. string modelname = modelSlot.Value; session.Attributes[MODEL_KEY] = modelname; //retrieve model dialogue from the database using (var sc = new StarCitizenDBEntities10()) { var query = from i in sc.ModelSCs where i.ModelName.Equals(modelname) select i; if (query.Count() != 0) { var model = query.First(); //set the dialogue to the speechOutput. speechOutput = model.ModelDialogue.ToString(); string reprompt = "Would you like to hear about another ship? Say tell me about a mustang beta or any other ship."; return(BuildSpeechletResponse("Model Information", speechOutput, reprompt, false)); } else { return(BuildSpeechletResponse("Model Information", "I am sorry I couldn't find any information on that model", "Please try again.", false)); } } } else { // Render an error since we don't know what the model name is. speechOutput = "I'm not sure which model you wanted information for, please try again"; return(BuildSpeechletResponse("Model Information", speechOutput, "please try again", false)); } }
/** * Creates and returns a {@code SpeechletResponse} with a status message. * * @return SpeechletResponse spoken and visual status message */ private SpeechletResponse StatusUpdate(Intent intent, Session session) { // Create a random numnber. Right now I am hard coding.. eventually we will pull this from the configuration database. using (var sc1 = new StarCitizenDBEntities10()) { var query1 = from i in sc1.Configs where i.Name.Equals("NumberOfStatusMessages") select i; var config = query1.First(); //set the dialogue to the speechOutput. int range = Convert.ToInt16(config.Value); Random rnd = new Random(); int x = rnd.Next(1, range); //pull the dialogue from the database using (var sc = new StarCitizenDBEntities10()) { var query = from i in sc.StatusSCs where i.Id.Equals(x) select i; var status = query.First(); //set the dialogue to the speechOutput. string speechOutput = status.Dialogue.ToString(); string reprompt = "Going off line in 8 seconds"; return(BuildSpeechletResponse("Status Update", speechOutput, reprompt, false)); } } }