Things used in this project

Hardware components:
Echo
Amazon Alexa Amazon Echo
×1
Amazon echo dot
Amazon Alexa Echo Dot
×1
Amazon tap
Amazon Alexa Amazon Tap
×1
Software apps and online services:
Dp image kit 02
Amazon Alexa Alexa Skills Kit
Screen%20shot%202015 07 20%20at%206.10.26%20pm
Amazon Web Services AWS Lambda

Code

index.jsJavaScript
alexa skill
/**
    Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
    Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
        http://aws.amazon.com/apache2.0/
    or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/


var APP_ID = 'amzn1.ask.skill.95bfe4b6-e869-4745-adae-843e02fed1f3'; //OPTIONAL: replace with "amzn1.echo-sdk-ams.app.[your-unique-value-here]";

/**
 * Array containing space facts.
 */
var FACTS = [
"Gorillas can catch human colds and other illnesses.",
"A newborn Chinese water deer is so small it can almost be held in the palm of the hand.",
"Ostriches can run faster than horses, and the males can roar like lions.",
"A lion in the wild usually makes no more than twenty kills a year.",
"The female lion does ninety percent of the hunting.",
"The world’s smallest dog was a Yorkshire Terrier, which weighed just four ounces.",
"Turtles, water snakes, crocodiles, alligators, dolphins, whales, and other water going creatures will drown if kept underwater too long.",
"Almost half the pigs in the world are kept by farmers in China.",
"On average, dogs have better eyesight than humans, although not as colorful.",
"Deer have no gall bladders.",
"There is an average of 50,000 spiders per acre in green areas.",
"Snakes are carnivores, which means they only eat animals, often small ones such as insects, birds, frogs and other small mammals.",
"In Alaska it is illegal to whisper in someone’s ear while they’re moose hunting.",
"The bat is the only mammal that can fly.",
"The leg bones of a bat are so thin that no bat can walk.",
"Some male songbirds sing more than 2000 times each day.",
"The only mammals to undergo menopause are elephants, humpback whales and human females.",
"Blue-eyed lemurs are one of two (non-human) primates to have truly blue eyes.",
"A tarantula spider can survive for more than two years without food.",
"For every human in the world there are one million ants.",
"If you lift a kangaroo’s tail off the ground it can’t hop – they use their tails for balance.",
"If you keep a goldfish. in a dark room, it will become pale!",
"Cows can sleep standing up, but they can only dream lying down.",
"The sentence “The quick brown fox jumps over a lazy dog.” uses every letter of the alphabet.",
"The average fox weighs 14 pounds.",
"The scientific name of the red fox is Vulpes vulpes.",
"Alligators can live up to 100 years.",
"A single elephant tooth can weigh as much as 9 pounds.",
"The turkey is one of the most famous birds in North America.",
"A housefly hums in the key of F.",
"During World War II, Americans tried to train bats to drop bombs.",
"Canis lupus lupus is the scientific name for a grey wolf.",
"To escape the grip of a crocodile’s jaw, push your thumb into its eyeballs-it will let you go instantly.",
"It is much easier for dogs to learn spoken commands if they are given in conjunction with hand signals or gestures.",
"Even a small amount of alcohol placed on a scorpion will make it go crazy and sting itself to death!",
"Male rabbits are called “bucks,” females are “does.”",
"The flamingo can only eat when its head is upside down.",
"Animals generate 30 times more waste than humans which is 1.4 billion tons every year.",
"Ants never sleep. Also they don’t have lungs.",
"A group of owls is called a parliament.",
"Just one cow gives off enough harmful methane gas in a single day to fill around 400 litre bottles.",
"Apple and pear seeds contain arsenic, which may be deadly to dogs.",
"Cows have one large stomach that is divided into four compartments to go through the different stages of digestion.",
"An anteater is nearly 6 feet long, yet its mouth is only an inch wide.",
"The blue whale weighs as much as thirty elephants and is as long as three Greyhound buses.",
"A herd of sixty cows is capable of producing a ton of milk in less than a day.",
"A grasshopper can leap 20 times the length of its own body.",
"At birth, baby kangaroos are only about an inch long – no bigger than a large water bug or a queen bee.",
"The smell of a skunk can be detected by a human a mile away.",
"There is a butterfly in Africa with enough poison in its body to kill six cats!",
"Cats have lived with people for only 7,000 years.",
"A black panther is really a black leopard.",
"The honey bee has been around for 30 million years.",
"The dumbest dog in the world is the Afghan hounds.",
"A cat has 32 muscles in each ear.",
"A dog’s shoulder blades are unattached to the rest of the skeleton to allow greater flexibility for running.",
"Tigers have striped skin as well as their fur.",
"Hippos can run faster than humans!",
"The Latin name for moose is alces alces.",
"The earliest European images of dogs are found in cave paintings dating back 12,000 years ago in Spain.",
"Baby horses can walk and run after just a few hours of being born.",
"The kangaroo’s ancestors lived in trees. Today there are eight different kinds of tree kangaroos.",
"A woodpecker can peck 20 times per second.",
"The great horned owl has no sense of smell.",
"Scientists have performed brain surgery on cockroaches.",
"The flea can jump up to 200 times its own height. This is equal to a man jumping the Empire State Building in New York.",
"Most elephants weigh less than the tongue of a blue whale.",
"The very first bomb that the Allies dropped on Berlin in World War Two hit an elephant.",
"A garden caterpillar has 248 muscles in its head.",
"A moth has no stomach.",
"George Washington’s teeth were made of elephant ivory, and walrus tusks.",
"Reindeer milk has more fat than cow milk.",
"Goats and sheep are seasonal breeders.",
"An elephant can smell water up to 3 miles away.",
"Deer can’t eat hay.",
"A skunk will not bite and throw its scent at the same time.",
"In 2003, Dr. Roger Mugford invented the “wag-o-meter” a device that claims to interpret a dog’s exact mood by measuring the wag of its tail.",
"Every day of the year, 100 whales are killed by whale fisherman.",
"If you cut off a snail’s eye, it will grow a new one.",
"The ostrich has two toes on each foot which gives it greater speed.",
"Lonomia obliqua is the world’s deadliest caterpillar.",
"‘Jaws’ is the most common name for a goldfish.",
"The most dogs ever owned by one person were 5,000 Mastiffs owned by Kubla Khan.",
"On average, cows poop 16 times per day!",
"The phrase “raining cats and dogs” originated in seventeenth-century England. During heavy rainstorms, many homeless animals would drown and float down the streets, giving the appearance that it had actually rained cats and dogs.",
"The most poisonous fish in the world is the stone fish.",
"Killer whales are not whales at all, rather a species of dolphin.",
"Goats were the first animals domesticated by man in 10,000 B.C.",
"Dogs have sweat glands in between their paws.",
"The fear of animals is called zoophobia.",
"We share 70% of our DNA with a slug.",
"We share 98.4% of our DNA with a chimp.",
"Fireflies do not bite or have pincers. Fireflies are harmless, they don’t even carry diseases.",
"Chocolate, macadamia nuts, cooked onions, or anything with caffeine is harmful to dogs.",
"No two tigers ever have the same stripes, and this is how individual tigers can be identified.",
"The American Kennel Club, the most influential dog club in the United States, was founded in 1884.",
"The longest recorded life span of a slug was 1 year, 6 months.",
"A whale’s heart beats only nine times a minute.",
"Elephants are covered with hair.",
"A ‘haw’ is the third eyelid of a cat, which can only be seen when the cat isn’t well.",
"A python can swallow a rabbit whole and may eat as many as 150 mice in a six-month period.",
"The placement of the eyes of a donkey enables them to see all four of their legs at all times.",
"At birth, a panda is smaller than a mouse and weighs about four ounces.",
"Oysters can change from one gender to another and back again depending on which is best for mating.",
"Fireflies are the only creatures that give off light without generating heat.",
"Hummingbirds beat their wings 60 to 80 times per second.",
"Only half of a dolphin’s brain sleeps at a time. The other awake half makes the dolphin come up for air when needed to prevent drowning.",
"Dogs have about 1,700 taste buds.",
"It takes 3,000 cows to supply the NFL with enough leather for a year’s supply of footballs.",
"A completely blind chameleon will still take on the colors of its environment.",
"A rodent’s teeth never stop growing.",
"When young abalones feed on red seaweed their shells turn red.",
"Small quantities of grapes and raisins can cause renal failure in dogs.",
"The hippopotamus is born underwater.",
"Taurophobia is the fear of bulls.",
"A bat can eat up to 1,000 insects per hour.",
"One million stray dogs and 500,000 stray cats live in New York City metropolitan area.",
"You can tell a turtle’s gender by the noise it makes. Males grunt, females hiss.",
"An elephant’s trunk has around 15,000 muscles. 200 litres of water is drunk from it per day.",
"The most popular female dog name is Maggie. The most popular male dog name is Max.",
"A large group of goats is called a herd.",
"Squirrels cannot see the color red.",
"The average chicken lays about 260 eggs per year.",
"A starving mouse will eat its own tail.",
"Only 5 to 10 percent of cheetah cubs make it to adulthood.",
"Ferrets sleep around 20 hours a day.",
"Birds can recognise landmarks, which they use to help them navigate.",
"The starfish is the only animal capable of turning its stomach inside-out.",
"Male dogs will raise their legs while urinating to aim higher on a tree or lamppost because they want to leave a message that they are tall and intimidating. Some wild dogs in Africa try to run up tree trunks while they are urinating to appear to be very large.",
"Sharks have been around longer than dinosaurs.",
"About two-thirds of shark attacks on humans have taken place in water less than six feet deep.",
"Sharks are immune to cancer!",
"Worldwide, more people eat and drink milk from goats than any other animal.",
"Alligators cannot move backwards.",
"The most popular dog breed in Canada, America, and Great Britain is the labrador retriever.",
"The largest giant squid ever found weighed 8,000 pounds.",
"Approximately 100 people die each year when they are stepped on by cows.",
"A butterfly has 12,000 eyes.",
"Humpback whales create the loudest sound of any living creature.",
"Hippo’s sweat is pink.",
"Whale milk is 50% fat.",
"In Croatia, scientists discovered that lampposts were falling down because a chemical in the urine of male dogs was rotting the metal.",
"In the Caribbean there are oysters that can climb trees.",
"The swan has over 25,000 feathers in its body.",
"The blue whale is the largest of all whales and is also considered the largest animal to have ever existed in the world.",
"Giraffes have no vocal cords.",
"Starfish have eight eyes – one at the end of each leg.",
"There are almost 60 million dogs in the United States.",
"After eating, a housefly regurgitates its food and then eats it again.",
"A mole can dig a tunnel 300 feet long in just one night.",
"Back in 1924, a monkey was convicted in South Bend of the crime of smoking a cigarette and sentenced to pay a 25 dollar fine!",
"Flamingos are pink because shrimp is one of their main sources of food.",
"The Mayans and Aztecs symbolised every tenth day with the dog, and those born under this sign were believed to have outstanding leadership skills.",
"When a male tiger and female lion mate they make a tigon, when a male lion and female tiger mate they make a liger.",
"French poodles did not originate in France – they came from Germany.",
"The breeding age for male goats is between 8-10 months.",
"Elephants don’t drink through their trunks like a straw.",
"Baby whales grow to a 1/3 of their mother’s length in the womb.",
"Goats do not have teeth in their upper front jaw.",
"Goat’s milk is higher in calcium, vitamin A and niacin than cow’s milk.",
"Turkeys have a poor sense of smell, but excellent sense of taste.",
"Cats can hear ultrasound.",
"Tuna fish can swim 40 miles in a single day.",
"Bumblebees have hair on their eyes.",
"Penguins can jump 6 feet out of water.",
"Giraffe hearts pump twice as hard as a cow’s to get blood to its brain.",
"Blue whales have large enough aortas (the main blood vessel) for a human to crawl through.",
"Some dogs can smell dead bodies under water!",
"More than 45 million turkeys are cooked and eaten in the US at Thanksgiving.",
"Baby whales can gain up to 200 pounds per day.",
"Dogs have a wet nose to collect more of the tiny droplets of smelling chemicals in the air.",
"Cats have over one hundred vocal sounds, while dogs only have about ten.",
"Cat owners are 30% less likely to suffer a heart attack.",
"Barn owls hunt mostly small mammals such as the short-tailed vole.",
"A ducks quack does echo, it’s just almost impossible to hear.",
"A cheetahs lifespan is up to 12 years in the wild.",
"Shark corneas are being used in human eye transplants.",
"Dogs are about as smart as a two or three-year-old child.",
"Butterflies have their skeletons on the outside of their bodies, this is known as the exoskeleton.",
"Arachnophobia is the fear of spiders.",
"Polar bears are the world’s largest land predators.",
"Hippos attract mates by urinating and defecating.",
"Butterflies can only see the colors red, green and yellow.",
"Yellowtail is the general name for loads of different species of fish that have yellow tails or a yellow body.",
"There are roughly twenty-four thousand species of butterflies.",
"A dik-dik is a tiny antelope that lives in East Africa, Namibia and Angola.",
"Dik-diks weigh between three and six kilogrammes.",
"Female polar bears normally start having baby cubs at the age of four or five.",
"Fireflies are also known as lightning bugs.",
"Noctule bats fly before sunset, whereas Pipistrelles appear soon after sunset.",
"In general, Asiatic jerboas have five toes on their back feet and African jerboas have three.",
"Even though a polar bears average body temperature is 37°C; they don’t give off any detectable heat, so they won’t show up in infrared photographs.",
"Dogs can see better when the light is low.",
"Dumbledore isn’t only the Headmaster of Hogwarts; in fact a dumbledore is an old English term for a type of bee.",
"Most young fireflies feed on nectar and pollen, although adult fireflies do not need to eat to survive.",
"79% of pet owners sleep with their pets.",
"Two dogs were among the Titanic survivors.",
"Many species of owls have special feathers for flying silently.",
"An elephant can smell water up to 3 miles away.",
"The animal on the Firefox logo is not a fox, but a red panda."
];

/**
 * The AlexaSkill prototype and helper functions
 */
var AlexaSkill = require('./AlexaSkill');

/**
 * SpaceGeek is a child of AlexaSkill.
 * To read more about inheritance in JavaScript, see the link below.
 *
 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript#Inheritance
 */
var Fact = function () {
    AlexaSkill.call(this, APP_ID);
};

// Extend AlexaSkill
Fact.prototype = Object.create(AlexaSkill.prototype);
Fact.prototype.constructor = Fact;

Fact.prototype.eventHandlers.onSessionStarted = function (sessionStartedRequest, session) {
    //console.log("onSessionStarted requestId: " + sessionStartedRequest.requestId + ", sessionId: " + session.sessionId);
    // any initialization logic goes here
};

Fact.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {
    //console.log("onLaunch requestId: " + launchRequest.requestId + ", sessionId: " + session.sessionId);
    handleNewFactRequest(response);
};

/**
 * Overridden to show that a subclass can override this function to teardown session state.
 */
Fact.prototype.eventHandlers.onSessionEnded = function (sessionEndedRequest, session) {
    //console.log("onSessionEnded requestId: " + sessionEndedRequest.requestId + ", sessionId: " + session.sessionId);
    // any cleanup logic goes here
};

Fact.prototype.intentHandlers = {
    "GetNewFactIntent": function (intent, session, response) {
        handleNewFactRequest(response);
    },

    "AMAZON.HelpIntent": function (intent, session, response) {
        response.ask("You can say tell me a fact, or, you can say exit... What can I help you with?", "What can I help you with?");
    },

    "AMAZON.StopIntent": function (intent, session, response) {
        var speechOutput = "Goodbye";
        response.tell(speechOutput);
    },

    "AMAZON.CancelIntent": function (intent, session, response) {
        var speechOutput = "Goodbye";
        response.tell(speechOutput);
    }
};

/**
 * Gets a random new fact from the list and returns to the user.
 */
function handleNewFactRequest(response) {
    // Get a random space fact from the space facts list
    var factIndex = Math.floor(Math.random() * FACTS.length);
    var randomFact = FACTS[factIndex];

    // Create speech output
    var speechOutput = "Here's your fact: " + randomFact;
    var cardTitle = "Wildlife Fact";
    response.tellWithCard(speechOutput, cardTitle, speechOutput);
}

// Create the handler that responds to the Alexa Request.
exports.handler = function (event, context) {
    // Create an instance of the SpaceGeek skill.
    var fact = new Fact();
    fact.execute(event, context);
};

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Iron-Rich Foods!
Easy
  • 49
  • 3

A necessary skill for all people with iron deficiencies. It's always hard to find foods that are rich in iron. Until now. Just ask Alexa!

Movie Quotes Trivia
Easy
  • 18
  • 1

Full instructions

Test your knowledge of great movies by matching five famous movies quotes. It will be great fun activities among famaly and friends.

Wise Quotes
Easy
  • 133
  • 3

Full instructions

More than 100 wise quotes to empower you everyday.

Compost Helper Alexa Skill
Easy
  • 152
  • 3

Use Alexa to find out if a household item can be added to your compost.

Ferrari Facts
Easy
  • 266
  • 4

Full instructions

learn about the most expensive cars in the world with Ferrari Facts you you will know some interesting facts that you probably didn't hear a

A Study in Gameful Thinking :: Gamification
Easy
  • 42
  • 1

Full instructions

Learn about gamification principles and current research associated with adoption of it.

Add projectSign up / Login