Shivansh Singh
Created June 13, 2017

Making of Star Wars

This is an Alexa skill which gives some interesting facts about Making of Start Wars movie.

42
Making of Star Wars

Things used in this project

Story

Read more

Code

index.js

JavaScript
'use strict';
var Alexa = require('alexa-sdk');
var APP_ID = undefined;  // TODO replace with your app ID (OPTIONAL).

var languageStrings = {
    "en-US": {
        "translation": {
            "FACTS": [
                "The movie's original title was Star wars, not a new hope.",
			    "In an early version, the saga was called the journal of the whills.",
			    "Luke was originally a 60 year old named luke starkiller.",
			    "Han solo was an ugly alien with green scaly skin.",
			    "Harrison ford was not supposed to be cast in the film.",
			    "Alec Guinness once paid Mark Hamill money to go away.",
			    "Chewbacca was modeled after George Luca's dog.",
			    "At one point Chewbacca was supposed to wear shorts.",
			    "C three P zero was supposed to sound like a used car salesman.",
			    "Orson welles was the first choice for Darth Vader.",
			    "James earl jones didn't receive billing on the 1977 release.",
			    "Vader's mask was designed as an outer space breathing apparatus.",
			    "Darth Vades has only 12 minutes of screen time.",
			    "Star wars is the only film where Darth Vader is never seen without mask.",
			    "Lucas referred to the film as a Disney movie ironically, disney bought Lucas film in 2012.",
			    "Leia is the only person to get stunned by a blaster, ever.",
			    "Haan will always shoot first in the film.",
			    "Jawas speak a sped-up version of the south african language, zulu.",
			    "The tusken raider was edited to appear more menacing.",
			    "The only female characters are Leia and aunt Beru.",
			    "Most of the storm troopers are left-handed because of the prop gun that was used.",
			    "Tie fighter stands for twin ion engines.",
			    "Mark Hamill was hurt in a car crash during re-shoots which explains the wampa in empire.",
			    "Spielberg thought the film would be a hit, while Lucas thought it would be a flop.",
			    "The film went to gross more than 775 million through multiple releases.",
			    "Star wars was the first sci-fi film to be nominated for best picture.",
			    "Darth Vader is Luke's father."
			],
            "SKILL_NAME" : "Facts about Making of Star Wars",
            "GET_FACT_MESSAGE" : "Here's your Making of Star Wars fact: ",
            "HELP_MESSAGE" : "You can say tell me a star war fact, 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

Shivansh Singh

Shivansh Singh

6 projects • 23 followers

Comments