Exemplo n.º 1
0
        /// <summary>
        /// Load the fact data into the list for processing/use
        /// </summary>
        /// <returns></returns>
        public static List <FactData> LoadFacts()
        {
            List <FactData> factList = new List <FactData>();
            FactData        facts    = new FactData();

            //prompt messages necessary for voice interaction
            facts.SkillName             = "Women in tech";
            facts.GetFactMessage        = "Here's an interesting one: ";
            facts.HelpMessage           = "You can say tell me a women in tech fact and I will give you a random one...What can I help you with?";
            facts.HelpReprompt          = "What can I help you with?";
            facts.StopMessage           = "Goodbye!";
            facts.LaunchMessage         = "Welcome to Women in tech facts. I know facts about famous women in technology and computing. What would you like to know?";
            facts.LaunchMessageReprompt = "Try asking me to give you a women in tech fact";
            facts.AskMessage            = " What else would you like to know?";

            //populate the list with the facts used
            facts.Facts.Add("Sister Mary Kenneth Keller was the first women in the United States to recieve a Ph.D in computer science in 1965...");
            facts.Facts.Add("The first computer programmer was Ada Lovelace...");
            facts.Facts.Add("Edith Clarke was the first female electrical engineer and was the first female professor of electrical engineering at the University of Texas at Austin...");
            facts.Facts.Add("The first compiler was invited by Grace Hopper in 1951...");
            facts.Facts.Add("The spanning-tree protocol that makes the modern Internet possible was invented by Radia Perlmann...");
            facts.Facts.Add("Jean Jennings Bartik was one of the six first ENIAC operators and did calculations on rocket and cannon trajectories in 1945...");
            facts.Facts.Add("The Apple icon was developed by Susan Kare...");
            facts.Facts.Add("Carol Shaw was a pioneer game developer for Atari in 1978 and was noted as one of the best programmers for the 6 5 0 2 microprocessor...");
            facts.Facts.Add("In 1942 Hedy Lamarr invented the frequency-hopping technology that allows for the modern day use of wi-fi and bluetooth...");
            facts.Facts.Add("Google hired Marissa Mayer in 1999 as their first female engineer and she is now vice president of location and local services...");
            factList.Add(facts);
            return(factList);
        }
Exemplo n.º 2
0
        // <summary>
        ///  Process intents that are dialog based and may not have a speech
        ///  response. Speech responses cannot be returned with a delegate response
        /// </summary>
        /// <param name="data"></param>
        /// <param name="input"></param>
        /// <param name="response"></param>
        /// <returns>bool true if processed</returns>
        private bool ProcessDialogRequest(FactData data, SkillRequest input, SkillResponse response)
        {
            var    intentRequest  = input.Request;
            string speech_message = string.Empty;
            bool   processed      = false;

            return(processed);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the facts from the list
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        private FactData GetFacts()
        {
            if (resources == null)
            {
                resources = FactData.LoadFacts();
            }

            foreach (FactData factdata in resources)
            {
                return(factdata);
            }
            return(null);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Process and respond to the LaunchRequest with launch
 /// and reprompt message
 /// </summary>
 /// <param name="factdata"></param>
 /// <param name="response"></param>
 /// <returns>void</returns>
 private void ProcessLaunchRequest(FactData factdata, ResponseBody response)
 {
     if (factdata != null)
     {
         IOutputSpeech innerResponse = new SsmlOutputSpeech();
         (innerResponse as SsmlOutputSpeech).Ssml = SsmlDecorate(factdata.LaunchMessage);
         response.OutputSpeech = innerResponse;
         IOutputSpeech prompt = new PlainTextOutputSpeech();
         (prompt as PlainTextOutputSpeech).Text = factdata.LaunchMessageReprompt;
         response.Reprompt = new Reprompt()
         {
             OutputSpeech = prompt
         };
     }
 }
Exemplo n.º 5
0
        /// <summary>
        ///  Get a new random fact from the fact list.
        /// </summary>
        /// <param name="factdata"></param>
        /// <param name="withPreface"></param>
        /// <returns>string newfact</returns>
        private string GetNewFact(FactData factdata, bool withPreface)
        {
            string preface = string.Empty;

            if (factdata == null)
            {
                return(string.Empty);
            }

            if (withPreface)
            {
                preface = factdata.GetFactMessage;
            }

            return(preface + factdata.Facts[rand.Next(factdata.Facts.Count)] + factdata.AskMessage);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Process all not dialog based Intents
        /// </summary>
        /// <param name="factdata"></param>
        /// <param name="input"></param>
        /// <returns>IOutputSpeech innerResponse</returns>
        private IOutputSpeech ProcessIntentRequest(FactData factdata, SkillRequest input)
        {
            var           intentRequest = input.Request;
            IOutputSpeech innerResponse = new PlainTextOutputSpeech();

            switch (intentRequest.Intent.Name)
            {
            case "GetNewFactIntent":
                innerResponse = new SsmlOutputSpeech();
                (innerResponse as SsmlOutputSpeech).Ssml = GetNewFact(factdata, true);
                break;

            case AlexaConstants.CancelIntent:
                (innerResponse as PlainTextOutputSpeech).Text = factdata.StopMessage;
                response.Response.ShouldEndSession            = true;
                break;

            case AlexaConstants.StopIntent:
                (innerResponse as PlainTextOutputSpeech).Text = factdata.StopMessage;
                response.Response.ShouldEndSession            = true;
                break;

            case AlexaConstants.HelpIntent:
                (innerResponse as PlainTextOutputSpeech).Text = factdata.HelpMessage;
                break;

            default:
                (innerResponse as PlainTextOutputSpeech).Text = factdata.HelpReprompt;
                break;
            }
            if (innerResponse.Type == AlexaConstants.SSMLSpeech)
            {
                BuildCard(factdata.SkillName, (innerResponse as SsmlOutputSpeech).Ssml);
                (innerResponse as SsmlOutputSpeech).Ssml = SsmlDecorate((innerResponse as SsmlOutputSpeech).Ssml);
            }
            return(innerResponse);
        }