Things used in this project

Schematics

flow_diagram_hz0dv0YZY0.jpg
Flow diagram hz0dv0yzy0

Code

Alexa Skill Index FileJavaScript
This is the file used in AWS Lambda to elicit responses from Amazon Alexa. This index file contains the code for all possible intents (conversation options).
'use strict';

const Alexa = require('alexa-sdk');
const records = require('./records');

const APP_ID = 'your app id';

const handlers = {
    'NewSession': function () {
        this.attributes.speechOutput = this.t('WELCOME_MESSAGE', this.t('SKILL_NAME'));
        this.attributes.repromptSpeech = this.t('WELCOME_REPROMT');
        this.emit(':ask', this.attributes.speechOutput, this.attributes.repromptSpeech);
    },
    'RecipeIntent': function () {
        const itemSlot = this.event.request.intent.slots.Item;
        let itemName;
        if (itemSlot && itemSlot.value) {
            itemName = itemSlot.value.toLowerCase();
        }

        const cardTitle = this.t('DISPLAY_CARD_TITLE', this.t('SKILL_NAME'), itemName);
        const myRecipes = this.t('RECORDS');
        const record = myRecipes[itemName];

        if (record) {
            this.attributes.speechOutput = record;
            this.attributes.repromptSpeech = this.t('RECORD_REPEAT_MESSAGE');
            this.emit(':askWithCard', record, this.attributes.repromptSpeech, cardTitle, record);
        } else {
            let speechOutput = this.t('RECORD_NOT_FOUND_MESSAGE');
            const repromptSpeech = this.t('RECORD_NOT_FOUND_REPROMPT');
            if (itemName) {
                speechOutput += this.t('RECORD_NOT_FOUND_WITH_ITEM_NAME', itemName);
            } else {
                speechOutput += this.t('RECORD_NOT_FOUND_WITHOUT_ITEM_NAME');
            }
            speechOutput += repromptSpeech;

            this.attributes.speechOutput = speechOutput;
            this.attributes.repromptSpeech = repromptSpeech;

            this.emit(':ask', speechOutput, repromptSpeech);
        }
    },
    'EmergencyIntent': function () {
      const sessionAttributes = {};
      const cardTitle = 'Emergency';
      const speechOutput = 'Don\'t worry, I\'m here to help, I have contacted emergency services and they are on their way.';
      const repromptText = 'I have already sent emergency services to your location.';
      const shouldEndSession = false;
      this.emit(':ask', speechOutput, repromptText);
    },
    'AddIntent': function () {
      const sessionAttributes = {};
      const cardTitle = 'Add Info';
      const addSpeechOutput = 'Okay, I\'ll record that in your profile.';
      const addRepromptText = 'I recorded what you told me in your profile.';
      const shouldEndSession = false;
      this.emit(':ask', addSpeechOutput, addRepromptText);
    },
    'AMAZON.HelpIntent': function () {
    this.emit('EmergencyIntent');
    },
    'AMAZON.RepeatIntent': function () {
        this.emit(':ask', this.attributes.speechOutput, this.attributes.repromptSpeech);
    },
    'AMAZON.StopIntent': function () {
        this.emit('SessionEndedRequest');
    },
    'AMAZON.CancelIntent': function () {
        this.emit('SessionEndedRequest');
    },
    'SessionEndedRequest': function () {
        this.emit(':tell', this.t('STOP_MESSAGE'));
    },
};

const languageStrings = {
    'en-US': {
        translation: {
            RECORDS: records.RECORD_EN_US,
            SKILL_NAME: 'ConvoCare',
            WELCOME_MESSAGE: "%s is ready to help.",
            WELCOME_REPROMT: 'You can ask for medical information such as the name, age, date of birth, allergies, or medications.',
            DISPLAY_CARD_TITLE: '%s  - Information for %s.',
            HELP_MESSAGE: "I can provide medical information on the occupant. You can ask questions such as, what is her blood type?" +
            "For a summary, you can say, give me the medical profile.",
            HELP_REPROMT: "You can say things like, what is her blood type?, or you can say exit...how can i help?",
            STOP_MESSAGE: 'Goodbye!',
            RECORD_REPEAT_MESSAGE: 'Try saying repeat.',
            RECORD_NOT_FOUND_MESSAGE: "I\'m sorry, I currently do not know ",
            RECORD_NOT_FOUND_WITH_ITEM_NAME: 'the information for %s. ',
            RECORD_NOT_FOUND_WITHOUT_ITEM_NAME: 'that information. ',
            RECORD_NOT_FOUND_REPROMPT: 'What else can I help with?',
        },
    }
};

exports.handler = (event, context) => {
    const alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    alexa.resources = languageStrings;
    alexa.registerHandlers(handlers);
    alexa.execute();
};
Alexa Skill Records FileJavaScript
The file containing all records that Amazon Alexa can use to answer questions. It contains medical information on the occupant such as their name, birth date, allergies, and medications.
module.exports = {
    RECORD_EN_US: {
        'name': 'The occupant\'s name is jane doe.',
        'gender': 'The occupant\'s gender is female.',
        'age': 'The occupant\'s age is 64.',
        'height' : 'The occupant\'s height is 5 foot 4 inches.',
        'weight' : 'The occupant\'s weight is 160 pounds.',
        'date of birth': 'The occupant\'s date of birth is august 22nd 1952.',
        'birth day': 'The occupant\'s birth day is august 22nd 1952.',
        'birth date': 'The occupant\'s birth date is august 22nd 1952.',
        'blood type': 'The occupant\'s blood type is O positive.',
        'allergies': 'The occupant is allergic to latex and peanuts.',
        'medications': 'The occupant is currently taking Verapamil, 100 milligrams daily.',
        'existing conditions': 'The occupant has a history of high blood pressure.',
        'emergency contact': 'The emergency contact\'s name is Peter Smith ' +
            'and his phone number is 8 6 7 5 3 O 9',
        'contact': 'The emergency contact\'s name is Peter Smith ' +
            'and his phone number is 8 6 7 5 3 O 9',
        'full history': 'jane doe is a 64 year old female, born august 22nd 1952,' +
            'She is 5 foot 4 inches and weighs 160 pounds,' +
            'She is allergic to latex and peanuts, Her blood type is O positive,' +
            'She is taking Verapamil 100 milligrams daily, She has a history of high blood pressure,' +
            'Her emergency contact\'s name is Peter Smith and his phone number is 8 6 7 5 3 O 9',
        'history': 'jane doe is a 64 year old female, born august 22nd 1952,' +
            'She is 5 foot 4 inches and weighs 160 pounds,' +
            'She is allergic to latex and peanuts, Her blood type is O positive,' +
            'She is taking Verapamil 100 milligrams daily, She has a history of high blood pressure,' +
            'Her emergency contact\'s name is Peter Smith and his phone number is 8 6 7 5 3 O 9',
        'medical profile': 'jane doe is a 64 year old female, born august 22nd 1952,' +
            'She is 5 foot 4 inches and weighs 160 pounds,' +
            'She is allergic to latex and peanuts, Her blood type is O positive,' +
            'She is taking Verapamil 100 milligrams daily, She has a history of high blood pressure,' +
            'Her emergency contact\'s name is Peter Smith and his phone number is 8 6 7 5 3 O 9',
        'profile': 'jane doe is a 64 year old female, born august 22nd 1952,' +
            'She is 5 foot 4 inches and weighs 160 pounds,' +
            'She is allergic to latex and peanuts, Her blood type is O positive,' +
            'She is taking Verapamil 100 milligrams daily, She has a history of high blood pressure,' +
            'Her emergency contact\'s name is Peter Smith and his phone number is 8 6 7 5 3 O 9',
        'details': 'jane doe is a 64 year old female, born august 22nd 1952,' +
            'She is 5 foot 4 inches and weighs 160 pounds,' +
            'She is allergic to latex and peanuts, Her blood type is O positive,' +
            'She is taking Verapamil 100 milligrams daily, She has a history of high blood pressure,' +
            'Her emergency contact\'s name is Peter Smith and his phone number is 8 6 7 5 3 O 9',
    }
};

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Stream Music Over Wi-Fi to Amazon Echo Through AirPlay
Intermediate
  • 573
  • 8

Protip

Turn an Amazon Echo into a multi-room speaker.

Eco-Thing #1  "Eco-Smart-Container V1.0"
Intermediate
  • 1,744
  • 13

Full instructions

An IoT device that could help keep the Sandy River Delta clean, as garbage is a very common problem.

Smart Garbage Monitoring System Using Arduino 101
Intermediate
  • 748
  • 5

Full instructions

A method in which waste management is automated. An innovative system that will help keep the city clean and healthy

Christmas Gift Box
Intermediate
  • 3,679
  • 595

Full instructions

Christmas Gift Box plays music and sends an email when it is opened.

IoT Red Phone
Intermediate
  • 2,760
  • 15

Work in progress

The phone will ring if you have an alert in your AWS Cloudwatch. If you pick up the handset, it tells you whats wrong.

SensorBoat
Intermediate
  • 176
  • 2

Full instructions

An Arduino controlled boat that takes temperature, accelerometer, and light data from any body of water.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog