Skip to Main Content
Alexa Skills Projects
book

Alexa Skills Projects

by Madhur Bhargava
June 2018
Beginner to intermediate content levelBeginner to intermediate
250 pages
4h 41m
English
Packt Publishing
Content preview from Alexa Skills Projects

Coding the Lambda function

We will be editing the code inline, in the index.js file in the developer portal itself:

  1. First of all, we shall define an array of JSON, which will contain the quiz questions to be posed by the trivia skill. This can be defined right at the top of the index.js file, even before the exports.handler:

//questions is an array of json objectsvar questions = [    {        "World War I began in which year?": [            "1923",            "1938",            "1917",            "1914"        ]    },    {        "Adolf Hitler was born in which country?": [            "France",            "Austria",            "Hungary",            "Germany"        ]    },    {        "The battle of Hastings was fought in which country?": [            "France",            "Russia",            "England",            "Norway"        ]    }];var correctAnswerSlots = [3, 1, 2];

As shown in the preceding code, apart from the questions ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-on Building Alexa Skills

Hands-on Building Alexa Skills

Paul Hickey

Publisher Resources

ISBN: 9781788997256Supplemental Content