vishalvinjapuri
Created June 11, 2017

Water Facts

This revolutionary skill can read you various interesting facts about water.

52
Water Facts

Things used in this project

Hardware components

Echo Dot
Amazon Alexa Echo Dot
×1

Software apps and online services

Alexa Skills Kit
Amazon Alexa Alexa Skills Kit
AWS Lambda
Amazon Web Services AWS Lambda

Story

Read more

Schematics

Flowchart/VUI

Code

Function code for Lambda plus Alexa SDK

JavaScript
'use strict';
var Alexa = require('alexa-sdk');

var APP_ID = undefined; //OPTIONAL: replace with "amzn1.echo-sdk-ams.app.[your-unique-value-here]";
var SKILL_NAME = 'Water Facts UK';

/**
 * Array containing water facts.
 */
var FACTS = [
    "There is the same amount of water on Earth as there was when the Earth was formed. The water from your faucet could contain molecules that dinosaurs drank.",
    "Water is composed of two elements, Hydrogen and Oxygen. 2 Hydrogen + 1 Oxygen = H2O.",
    "Nearly 97% of the world’s water is salty or otherwise undrinkable. Another 2% is locked in ice caps and glaciers. That leaves just 1% for all of humanity’s needs — all its agricultural, residential, manufacturing, community, and personal needs.",
    "Water regulates the Earth’s temperature. It also regulates the temperature of the human body, carries nutrients and oxygen to cells, cushions joints, protects organs and tissues, and removes wastes.",
    "75% of the human brain is water and 75% of a living tree is water.",
    "A person can live about a month without food, but only about a week without water.",
    "Water is part of a deeply interconnected system. What we pour on the ground ends up in our water, and what we spew into the sky ends up in our water.",
    "The average total home water use for each person in the U.S. is about 50 gallons a day.",
    "The average cost for water supplied to a home in the U.S. is about $2.00 for 1,000 gallons, which equals about 5 gallons for a penny.",
    "Water expands by 9% when it freezes. Frozen water (ice) is lighter than water, which is why ice floats in water.",
    "Water covers 70.9 percent of the planet’s surface.",
    "There is more water in the atmosphere than in all of our rivers combined.",
    "In a year, the average American residence uses over 100,000 gallons."
];

exports.handler = function(event, context, callback) {
    var alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    alexa.registerHandlers(handlers);
    alexa.execute();
};

var handlers = {
    'LaunchRequest': function () {
        this.emit('GetFact');
    },
    'GetNewFactIntent': function () {
        this.emit('GetFact');
    },
    'GetFact': function () {
        // Get a random space fact from the water facts list
        var factIndex = Math.floor(Math.random() * FACTS.length);
        var randomFact = FACTS[factIndex];

        // Create speech output
        var speechOutput = "Here's your fact: " + randomFact;

        this.emit(':tellWithCard', speechOutput, SKILL_NAME, randomFact)
    },
    'AMAZON.HelpIntent': function () {
        var speechOutput = "You can say tell me a water fact, or, you can say exit... What can I help you with?";
        var reprompt = "What can I help you with?";
        this.emit(':ask', speechOutput, reprompt);
    },
    'AMAZON.CancelIntent': function () {
        this.emit(':tell', 'Goodbye!');
    },
    'AMAZON.StopIntent': function () {
        this.emit(':tell', 'Goodbye!');
    }
};

Credits

vishalvinjapuri

vishalvinjapuri

0 projects • 0 followers

Comments