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

Run Google Assistant on Your Amazon Echo
Intermediate
  • 249
  • 7

Full instructions

This is an implementation of the Google Assistant API wrapped as an Alexa skill.

Controlling IR Appliances by Schedule
Intermediate
  • 189
  • 7

This project helps you control your IR appliances by setting schedule.

UK Treasure Hunt
Intermediate
  • 63
  • 4

Full instructions

Find Precious Treasures from across the United Kingdom..!

 Controlling IR-Controlled Appliances Through Internet
Intermediate
  • 323
  • 8

Turning your AC on before arriving at the office, changing your room temperature before coming back home by imitating IR signal.

Parliament Election Support from you Alexa
Intermediate
  • 71
  • 3

Full instructions

Democracy calls! Use this Alexa skill for who is running for the UK Parliament on the snap election for the 8th of June, as well as who won.

Unofficial Pokedex (Updated 06/2017) - Alexa Skill
Intermediate
  • 63
  • 3

This is an updated version: now the response card shows the Pokemon image and you are able to ask for the Pokemon's evolution.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login