Beverly WoodDonji YDAlexandra WashburnJinger ZengAndrew Cross
Published © MIT

Convo-Care: Alexa-Controlled E-Health App

Convo-Care provides a better e-health experience through a conversational UI.

IntermediateProtip2 hours1,779
Convo-Care: Alexa-Controlled E-Health App

Things used in this project

Story

Read more

Schematics

flow_diagram_hz0dv0YZY0.jpg

Code

Alexa Skill Index File

JavaScript
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 File

JavaScript
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

Beverly Wood

Beverly Wood

1 project • 1 follower
Donji YD

Donji YD

1 project • 2 followers
I'm a ux designer.
Alexandra Washburn

Alexandra Washburn

1 project • 2 followers
Jinger Zeng

Jinger Zeng

2 projects • 14 followers
Andrew Cross

Andrew Cross

1 project • 2 followers

Comments