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

The composting friend
Intermediate
  • 711
  • 34

Full instructions

Our goal is to make composting easier to use and to maintain.

Smart Mirror (with Optional Alexa)
Intermediate
  • 19,423
  • 94

Full instructions

A low cost and easy to build smart mirror with off the shelf parts.

Smart Room Slack Bot
Intermediate
  • 202
  • 2

Full instructions

A Slack bot that manages each room in a venue. The bot takes bookings and monitors the environment (temp, light, power) and occupancy (PIR).

HVAC
Intermediate
  • 977
  • 42

Work in progress

Heating ventilation and air-conditioning for a dome.

SORT4U
Intermediate
  • 421
  • 14

Full instructions

It's the sorting machine that you've been waiting for. Just throw all your junk in it and let it sort for you.

SORT4U

Team The Avengers

Home Automation Orchestrator
Intermediate
  • 478
  • 6

Full instructions

A device that gathers information from various home automation agents and that dispatch orders to those devices based on rules

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback