Livewire Shadow
Created June 12, 2017

Computer Facts

A great skill that can teach you more about computers!

22
Computer Facts

Things used in this project

Hardware components

Echo Dot
Amazon Alexa Echo Dot
×1

Software apps and online services

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

Story

Read more

Schematics

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 = 'Computer Facts';

/**
 * Array containing Computer facts.
 */
var FACTS = [
    "In 1833 a man by the name of Charles Babbage invented all the parts that are now used for a modern computer. But it was only 120 years later that the first ‘modern’ computers were invented.",
    "Konrad Zuse was the inventor of the first computer in the world in 1936 and he named it the Z1. In 1939, he created the Z2 as the first electro-mechanical computer in the world.",
    "So computers were born, and these early computers were made in the 1940s and were around the size of a large room and they used heaps of electricity. Can you imagine having a computer the size of a large room? How would you be able to sit in front of it?",
    "On Mars, the Sun appears about half the size as it does on Earth.",
    "Computers as we know them today only really started being made in 1980.",
    "In 1980, the first one gigabyte disk drive was released in the world. It was a whopping US$40,000 with the weight of 550 pounds (almost 227kg). How on Earth did they move it?",
    "Well, it’s literally a machine that takes what you put into it, and then gives you some information back. So you give it a command, just like you would your dog and it follows the command to give you the result you want. Pretty awesome machines these are.",
    "Computers have something called a microprocessor that can make calculations super-fast.",
    "They also have a memory, or what is referred to as RAM. This stores all the information you need when you’re not using it. It also keeps everything your computer needs to work nice and safe.",
    "Computers have fans to keep them cool; otherwise they’ll get too hot.",
    "Over 6,000 computer viruses are released each month.",
    "The first Apple computer ever made by Steve Jobs and Steve Wozniak was made from old parts they collected for free from their staff.",
    "Facebook has over a billion users. If it was a country it would be the third largest in the world."
];

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 Computer fact from the Computer 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 Computer 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

Livewire Shadow

Livewire Shadow

1 project • 0 followers

Comments