Ruchir
Published

Iron-Rich Foods!

A necessary skill for all people with iron deficiencies. It's always hard to find foods that are rich in iron. Until now. Just ask Alexa!

EasyShowcase (no instructions)1 hour164
Iron-Rich Foods!

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
AWS Lambda
Amazon Web Services AWS Lambda

Story

Read more

Schematics

Diagram

How the skill works
Alexa diagram d5zfptlsid

Code

AWS Lambda code

JavaScript
Server end code to generate Alexa response
'use strict';
var Alexa = require('alexa-sdk');

var APP_ID = "ID here";
var SKILL_NAME = "ironrich";

/**
 * Array containing iron rich foods.
 */
var lines = [
"Clams, canned, drained Kellogg's",
"Special K cereal Grape Nuts",
"Cheerios",
"Cream of Wheat (instant)",
"Raw oysters",
"Hamburger",
"Carnation Instant Breakfast",
"Pizza w/meat, vegetables, thick crust Lentils",
"Spinach",
"Potato, baked",
"Beef steak, lean",
"Kidney beans",
"Shrimp",
"Spaghetti w/tomato sauce Oatbran muffin",
"Turkey, dark meat, cooked Hummus",
"Macaroni",
"Pumpkin, canned",
"Eggs, scrambled Mushrooms, cooked",
"Tofu, raw, firm",
"French toast",
"Whole wheat bread",
"Green peas",
"Figs, dried"
];

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  food from the   list
        var factIndex = Math.floor(Math.random() * lines.length);
        var randomline = lines[factIndex];

        // Create speech output
        var speechOutput = randomline;

        this.emit(':tellWithCard', speechOutput, SKILL_NAME, randomline)
    },
    'AMAZON.HelpIntent': function () {
        var speechOutput = "Say something like give me a food rich in iron";
        var reprompt = "Give me a food rich in iron";
        this.emit(':ask', speechOutput, reprompt);
    },
    'AMAZON.CancelIntent': function () {
        this.emit(':tell', 'Goodbye!');
    },
    'AMAZON.StopIntent': function () {
        this.emit(':tell', 'Goodbye!');
    }
};

Credits

Ruchir

Ruchir

0 projects • 0 followers
Contact

Comments

Add projectSign up / Login