Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Brian Cottrell
Published © Apache-2.0

Invention of the Day

When asked, Invention of the Day will randomly give details about a particular invention including the inventor and the year it was invented

BeginnerProtip3 hours633

Things used in this project

Hardware components

Amazon Echo
Amazon Alexa Amazon Echo
×1

Software apps and online services

Alexa Skills Kit
Amazon Alexa Alexa Skills Kit

Story

Read more

Code

index.js

JavaScript
AWS Lambda function for Invention of the Day
'use strict';
var Alexa = require('alexa-sdk');
var APP_ID = "amzn1.echo-sdk-ams.app.amzn1.ask.skill.789cda88-d3d4-4536-bc1b-21164b6a2a05";

var languageStrings = {
    "en-GB": {
        "translation": {
            "FACTS": [
                "The first true edible conical shaped cone for serving ice cream was created at the St. Louis World's Fair by Ernest Hamwi, a Syrian concessionaire in 1904.",
                "In 1869, American Cornelius Swartwout patented a waffle iron for stovetop use consisting of cast iron plates joined by a hinge that swiveled in a cast iron collar.",
                "The first lawn mower was invented by Edwin Budding in 1830 in Thrupp, just outside Stroud, in Gloucestershire, England.",
                "Scotch Tape or cellophane tape was invented in 1930 by banjo playing 3M engineer Richard Drew.",
                "Willem Kolff invented both the first artificial heart and the first artificial kidney dialysis machine.",
                "Dee Horton and Lew Hewitt invented the sliding automatic door in 1954.",
                "The ball-point pen was invented by Ladislo Biro in 1938..",
                "The first rubber balloons were made in 1824 by Professor Michael Faraday for use in his experiments with hydrogen.",
                "Band-Aid is the trademarked name for the 1920 invention belonging to Earle Dickson.",
                "The first patents for bar code were issued to Joseph Woodland and Bernard Silver on October 7, 1952.",
                "The Barbie doll was invented in 1959 by Ruth Handler.",
                "2000 was the 201th anniversary of the invention of the battery by Alessandro Volta.",
                "Today’s wire coat hanger was inspired by a clothes hook patented in 1869 by O. A. North.",
                "James Russell invented the compact disc in 1965. Russell was granted a total of 22 patents for various elements of his system.",
                "The convenient disposable diaper was invented by New Yorker Marion Donovan in 1950.",
                "Josephine Cochran invented the dishwasher in 1886.",
                "Chester Greenwood, a grammar school dropout, invented earmuffs at the age of 15 and accumulated over 100 patents in his lifetime.",
                "In 1891, Jesse Reno created a new novelty ride at Coney Island that led to the invention of the escalator.",
                "The Etch-A-Sketch was developed in the late 1950s by Arthur Granjean.",
                "Sylvester Graham invented Graham Crackers in 1829.",
                "Hans Riegel invented gummi bears during the 1920s.",
                "The hovercraft was invented by Christopher Cockerell in 1956.",
                "Invented in 1839 by Sir William Grove, hydrogen fuel cells have now becoming the power source for the 21st century.",
                "The first flexible stainless steel, all-metal ice tray was invented by Guy Tinkham in 1933.",
                "An improvement to the ironing board was patented by African American inventor, Sarah Boone.",
                "John Spilsbury created the first jigsaw puzzle in 1767.",
                "The kaleidoscope was invented by Sir David Brewster and patented by him in 1817.",
                "John Larson invented the polygraph or lie detector in 1921.",
                "Garnet Carter was the first person to patent a game of miniature golf called Tom Thumb Golf in 1927.",
                "The honor of father of modern necktie construction goes to the American tie manufacturer Jesse Langsdorf, who in 1920 patented the all-weather, wrinkle-free tie.",
                "David Paul Gregg first envisioned the optical or laser disc in 1958 and patented it in 1969.",
                "The paint roller was invented by Norman Breakey of Toronto in 1940.",
                "Louis Sebastien Lenormand is credited with being the first person to demonstrate the principle of the parachute in 1783.",
                "Carl Magee invented the first parking meter in 1932.",
                "The safety pin was invented by Walter Hunt in 1849.",
                "Jan Matzeliger developed an automatic method for lasting shoes and made the mass production of affordable shoes possible.",
                "Around 1622, the circular and rectangular slide rule was invented by Episcopalean minister William Oughtred.",
                "Canadian, Arthur Sicard invented the snowblower in 1925.",
                "In 1819, the soda fountain was patented by Samuel Fahnestock.",
                "Rowland Hill invented the postage stamp in 1837, an act for which he was knighted.",
                "In 1888, Marvin Stone patented the spiral winding process to manufacture the first paper drinking straws.",
                "C. B. Brooks invented an improved street sweeper truck and patented it on March 17, 1896.",
                "Around the year 1752, James Ayscough introduced his spectacles with lenses made of tinted glass.",
                "In 1873, Walter Wingfield invented a game called Sphairistikè which evolved into modern outdoor tennis.",
                "The tuxedo was invented by Pierre Lorillard of New York City.",
                "Volleyball was invented by William Morgan in 1895.",
                "The earliest washing machine the scrub board was invented in 1797.",
                "Edwin Ruud invented the automatic storage water heater in 1889.",
                "Waterskiing was invented in 1922 by Ralph Samuelson, an eighteen-year-old from Minnesota.",
                "What can be considered the first modern thermometer, the mercury thermometer with a standardized Fahrenheit scale, was invented by Daniel Gabriel Fahrenheit in 1714."
            ],
            "SKILL_NAME" : "Invention of the Day",
            "GET_FACT_MESSAGE" : "Here is today's invention fact: ",
            "HELP_MESSAGE" : "You can ask me for today's invention, or, you can say exit... What can I help you with?",
            "HELP_REPROMPT" : "What can I help you with?",
            "STOP_MESSAGE" : "Goodbye!"
        }
    },
    "en-US": {
        "translation": {
            "FACTS": [
                "The first true edible conical shaped cone for serving ice cream was created at the St. Louis World's Fair by Ernest Hamwi, a Syrian concessionaire in 1904.",
                "In 1869, American Cornelius Swartwout patented a waffle iron for stovetop use consisting of cast iron plates joined by a hinge that swiveled in a cast iron collar.",
                "The first lawn mower was invented by Edwin Budding in 1830 in Thrupp, just outside Stroud, in Gloucestershire, England.",
                "Scotch Tape or cellophane tape was invented in 1930 by banjo playing 3M engineer Richard Drew.",
                "Willem Kolff invented both the first artificial heart and the first artificial kidney dialysis machine.",
                "Dee Horton and Lew Hewitt invented the sliding automatic door in 1954.",
                "The ball-point pen was invented by Ladislo Biro in 1938..",
                "The first rubber balloons were made in 1824 by Professor Michael Faraday for use in his experiments with hydrogen.",
                "Band-Aid is the trademarked name for the 1920 invention belonging to Earle Dickson.",
                "The first patents for bar code were issued to Joseph Woodland and Bernard Silver on October 7, 1952.",
                "The Barbie doll was invented in 1959 by Ruth Handler.",
                "2000 was the 201th anniversary of the invention of the battery by Alessandro Volta.",
                "Today’s wire coat hanger was inspired by a clothes hook patented in 1869 by O. A. North.",
                "James Russell invented the compact disc in 1965. Russell was granted a total of 22 patents for various elements of his system.",
                "The convenient disposable diaper was invented by New Yorker Marion Donovan in 1950.",
                "Josephine Cochran invented the dishwasher in 1886.",
                "Chester Greenwood, a grammar school dropout, invented earmuffs at the age of 15 and accumulated over 100 patents in his lifetime.",
                "In 1891, Jesse Reno created a new novelty ride at Coney Island that led to the invention of the escalator.",
                "The Etch-A-Sketch was developed in the late 1950s by Arthur Granjean.",
                "Sylvester Graham invented Graham Crackers in 1829.",
                "Hans Riegel invented gummi bears during the 1920s.",
                "The hovercraft was invented by Christopher Cockerell in 1956.",
                "Invented in 1839 by Sir William Grove, hydrogen fuel cells have now becoming the power source for the 21st century.",
                "The first flexible stainless steel, all-metal ice tray was invented by Guy Tinkham in 1933.",
                "An improvement to the ironing board was patented by African American inventor, Sarah Boone.",
                "John Spilsbury created the first jigsaw puzzle in 1767.",
                "The kaleidoscope was invented by Sir David Brewster and patented by him in 1817.",
                "John Larson invented the polygraph or lie detector in 1921.",
                "Garnet Carter was the first person to patent a game of miniature golf called Tom Thumb Golf in 1927.",
                "The honor of father of modern necktie construction goes to the American tie manufacturer Jesse Langsdorf, who in 1920 patented the all-weather, wrinkle-free tie.",
                "David Paul Gregg first envisioned the optical or laser disc in 1958 and patented it in 1969.",
                "The paint roller was invented by Norman Breakey of Toronto in 1940.",
                "Louis Sebastien Lenormand is credited with being the first person to demonstrate the principle of the parachute in 1783.",
                "Carl Magee invented the first parking meter in 1932.",
                "The safety pin was invented by Walter Hunt in 1849.",
                "Jan Matzeliger developed an automatic method for lasting shoes and made the mass production of affordable shoes possible.",
                "Around 1622, the circular and rectangular slide rule was invented by Episcopalean minister William Oughtred.",
                "Canadian, Arthur Sicard invented the snowblower in 1925.",
                "In 1819, the soda fountain was patented by Samuel Fahnestock.",
                "Rowland Hill invented the postage stamp in 1837, an act for which he was knighted.",
                "In 1888, Marvin Stone patented the spiral winding process to manufacture the first paper drinking straws.",
                "C. B. Brooks invented an improved street sweeper truck and patented it on March 17, 1896.",
                "Around the year 1752, James Ayscough introduced his spectacles with lenses made of tinted glass.",
                "In 1873, Walter Wingfield invented a game called Sphairistikè which evolved into modern outdoor tennis.",
                "The tuxedo was invented by Pierre Lorillard of New York City.",
                "Volleyball was invented by William Morgan in 1895.",
                "The earliest washing machine the scrub board was invented in 1797.",
                "Edwin Ruud invented the automatic storage water heater in 1889.",
                "Waterskiing was invented in 1922 by Ralph Samuelson, an eighteen-year-old from Minnesota.",
                "What can be considered the first modern thermometer, the mercury thermometer with a standardized Fahrenheit scale, was invented by Daniel Gabriel Fahrenheit in 1714."
            ],
            "SKILL_NAME" : "Invention of the Day",
            "GET_FACT_MESSAGE" : "Here is today's invention fact: ",
            "HELP_MESSAGE" : "You can ask me for today's invention, or, you can say exit... What can I help you with?",
            "HELP_REPROMPT" : "What can I help you with?",
            "STOP_MESSAGE" : "Goodbye!"
        }
    },
    "de-DE": {
        "translation": {
            "FACTS": [
                "The first true edible conical shaped cone for serving ice cream was created at the St. Louis World's Fair by Ernest Hamwi, a Syrian concessionaire in 1904.",
                "In 1869, American Cornelius Swartwout patented a waffle iron for stovetop use consisting of cast iron plates joined by a hinge that swiveled in a cast iron collar.",
                "The first lawn mower was invented by Edwin Budding in 1830 in Thrupp, just outside Stroud, in Gloucestershire, England.",
                "Scotch Tape or cellophane tape was invented in 1930 by banjo playing 3M engineer Richard Drew.",
                "Willem Kolff invented both the first artificial heart and the first artificial kidney dialysis machine.",
                "Dee Horton and Lew Hewitt invented the sliding automatic door in 1954.",
                "The ball-point pen was invented by Ladislo Biro in 1938..",
                "The first rubber balloons were made in 1824 by Professor Michael Faraday for use in his experiments with hydrogen.",
                "Band-Aid is the trademarked name for the 1920 invention belonging to Earle Dickson.",
                "The first patents for bar code were issued to Joseph Woodland and Bernard Silver on October 7, 1952.",
                "The Barbie doll was invented in 1959 by Ruth Handler.",
                "2000 was the 201th anniversary of the invention of the battery by Alessandro Volta.",
                "Today’s wire coat hanger was inspired by a clothes hook patented in 1869 by O. A. North.",
                "James Russell invented the compact disc in 1965. Russell was granted a total of 22 patents for various elements of his system.",
                "The convenient disposable diaper was invented by New Yorker Marion Donovan in 1950.",
                "Josephine Cochran invented the dishwasher in 1886.",
                "Chester Greenwood, a grammar school dropout, invented earmuffs at the age of 15 and accumulated over 100 patents in his lifetime.",
                "In 1891, Jesse Reno created a new novelty ride at Coney Island that led to the invention of the escalator.",
                "The Etch-A-Sketch was developed in the late 1950s by Arthur Granjean.",
                "Sylvester Graham invented Graham Crackers in 1829.",
                "Hans Riegel invented gummi bears during the 1920s.",
                "The hovercraft was invented by Christopher Cockerell in 1956.",
                "Invented in 1839 by Sir William Grove, hydrogen fuel cells have now becoming the power source for the 21st century.",
                "The first flexible stainless steel, all-metal ice tray was invented by Guy Tinkham in 1933.",
                "An improvement to the ironing board was patented by African American inventor, Sarah Boone.",
                "John Spilsbury created the first jigsaw puzzle in 1767.",
                "The kaleidoscope was invented by Sir David Brewster and patented by him in 1817.",
                "John Larson invented the polygraph or lie detector in 1921.",
                "Garnet Carter was the first person to patent a game of miniature golf called Tom Thumb Golf in 1927.",
                "The honor of father of modern necktie construction goes to the American tie manufacturer Jesse Langsdorf, who in 1920 patented the all-weather, wrinkle-free tie.",
                "David Paul Gregg first envisioned the optical or laser disc in 1958 and patented it in 1969.",
                "The paint roller was invented by Norman Breakey of Toronto in 1940.",
                "Louis Sebastien Lenormand is credited with being the first person to demonstrate the principle of the parachute in 1783.",
                "Carl Magee invented the first parking meter in 1932.",
                "The safety pin was invented by Walter Hunt in 1849.",
                "Jan Matzeliger developed an automatic method for lasting shoes and made the mass production of affordable shoes possible.",
                "Around 1622, the circular and rectangular slide rule was invented by Episcopalean minister William Oughtred.",
                "Canadian, Arthur Sicard invented the snowblower in 1925.",
                "In 1819, the soda fountain was patented by Samuel Fahnestock.",
                "Rowland Hill invented the postage stamp in 1837, an act for which he was knighted.",
                "In 1888, Marvin Stone patented the spiral winding process to manufacture the first paper drinking straws.",
                "C. B. Brooks invented an improved street sweeper truck and patented it on March 17, 1896.",
                "Around the year 1752, James Ayscough introduced his spectacles with lenses made of tinted glass.",
                "In 1873, Walter Wingfield invented a game called Sphairistikè which evolved into modern outdoor tennis.",
                "The tuxedo was invented by Pierre Lorillard of New York City.",
                "Volleyball was invented by William Morgan in 1895.",
                "The earliest washing machine the scrub board was invented in 1797.",
                "Edwin Ruud invented the automatic storage water heater in 1889.",
                "Waterskiing was invented in 1922 by Ralph Samuelson, an eighteen-year-old from Minnesota.",
                "What can be considered the first modern thermometer, the mercury thermometer with a standardized Fahrenheit scale, was invented by Daniel Gabriel Fahrenheit in 1714."
            ],
            "SKILL_NAME" : "Invention of the Day",
            "GET_FACT_MESSAGE" : "Here is today's invention fact: ",
            "HELP_MESSAGE" : "You can ask me for today's invention, or, you can say exit... What can I help you with?",
            "HELP_REPROMPT" : "What can I help you with?",
            "STOP_MESSAGE" : "Goodbye!"
        }
    }
};

exports.handler = function(event, context, callback) {
    var alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    // To enable string internationalization (i18n) features, set a resources object.
    alexa.resources = languageStrings;
    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 space facts list
        // Use this.t() to get corresponding language data
        var factArr = this.t('FACTS');
        var factIndex = Math.floor(Math.random() * factArr.length);
        var randomFact = factArr[factIndex];

        // Create speech output
        var speechOutput = this.t("GET_FACT_MESSAGE") + randomFact;
        this.emit(':tellWithCard', speechOutput, this.t("SKILL_NAME"), randomFact)
    },
    'AMAZON.HelpIntent': function () {
        var speechOutput = this.t("HELP_MESSAGE");
        var reprompt = this.t("HELP_MESSAGE");
        this.emit(':ask', speechOutput, reprompt);
    },
    'AMAZON.CancelIntent': function () {
        this.emit(':tell', this.t("STOP_MESSAGE"));
    },
    'AMAZON.StopIntent': function () {
        this.emit(':tell', this.t("STOP_MESSAGE"));
    }
};

Credits

Brian Cottrell

Brian Cottrell

11 projects • 16 followers
I am a software developer with a background in physics and low level programming and I am currently focused on web and mobile development.

Comments