Skip to content

Instantly share code, notes, and snippets.

@danmayer
Last active July 24, 2018 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danmayer/34c645ef1780fed7510cf904e04dcc7b to your computer and use it in GitHub Desktop.
Save danmayer/34c645ef1780fed7510cf904e04dcc7b to your computer and use it in GitHub Desktop.
Alexa skill to compliment my wife
/* eslint-disable func-names */
/* eslint quote-props: ["error", "consistent"]*/
/**
* This is an skill to learn how the Alexa API works. Created by Dan Mayer
* Built with the Amazon Alexa Skills nodejs skill development kit.
* Initially edited from the getFact example.
**/
'use strict';
const Alexa = require('alexa-sdk');
const APP_ID = 'amzn1.ask.skill.7fe0eeac-012d-4eba-b9b0-eb32b31c66c5';
var states = {
GETNAME: '_GETNAME', // User is trying to guess the number.
COMPLIMENT: '_COMPLIMENT' // Prompt the user to start or restart the game.
};
const languageStrings = {
'en-US': {
translation: {
// https://www.happier.com/blog/nice-things-to-say-100-compliments
PRETTY: [
"Your smile is contagious.",
"You look great today.",
"You're a smart cookie.",
"You have eyes a man could drown in",
"You're the most beautiful woman here tonight",
"I love talking with you; you’re interesting and funny.",
"I bet you make babies smile.",
"You have impeccable manners.",
"I like your style.",
"You have the best laugh.",
"I appreciate you, and everything you do",
"You are the most perfect you, there is.",
"You are more than enough.",
"You're super pretty, like shockingly pretty.",
"Your perspective is refreshing, or so I say as I get lost in your eyes.",
"You light up the room.",
"You deserve a hug right now.",
"You should be proud of yourself. For being so hot",
"Your going to be one hot mamma",
"You haven't worn make up all week? Gee-wiz, you are gorgeous!",
"Wow, that confidence looks sexy on you.",
"I love seeing your smile, it brightens my day every time",
"I Love the Way You Walk",
"I could listen to you talk forever",
"You are worthy of the last french fry in the bag",
"I bet you could make one of those british queen's guards smile",
"Looking forward to being married when we are ninety",
"You have the prettiest skin, you glow",
"You look amazing, did you just get back from vacation?",
"You are a godly woman.",
"You’re as beautiful to me as the day we married.",
"I only have eyes for you.",
"You look fabulous in that outfit!",
"When you walked into the room, you took my breath away.",
"You are a beautiful person, inside and out.",
"You’re no pushover. I love your spine of steel."
],
SEXY: [
"I appreciate you, mostly I appreciate your sexy butt",
"You are the most perfect you there is.",
"You're strong and super sexy.",
"You're an awesome friend, a friend with benifits.",
"You deserve a hug right now. A sexy hug.",
"You should be proud of yourself. For being so hot",
"Your going to be one hot mamma",
"You haven't worn make up all week? wow, you are gorgeous!",
"Wow, that confidence looks sexy on you.",
"Dang Girl is your name Wifi ? Because I’m feeling a connection!",
"Aside from being sexy, what do you do for a living?",
"Hey, my name's Microsoft. Can I crash at your place tonight?",
"Are you a parking ticket? Because you've got FINE written all over you.",
"How much does it cost to date you? Cause wow, you look expensive!",
"Baby, if you were words on a page, you'd be fine print.",
"Did you just come out of the oven? Because you're hot.",
"It's a good thing I have my library card, because I am totally checking you out.",
"You are hotter than the bottom of my laptop.",
"Your shirt has to go, but you can stay.",
"You’re like my own personal brand of heroin.",
"Did you get plastic surgery to look that good.",
"I'm really proud of you. You're the only girl who didn't become a cow after high school.",
"You’re the finest woman on the planet!",
"I don’t deserve you... but, I’m glad you’re mine!",
"You’re one in a million . . . and you’re mine!",
"I’m a rich man because you are my wife."
],
LOVE: [
"I love you.",
"You give a lot, and I appreciate how much you give.",
"You make me want to be a better man.",
"I like spending time with you.",
"You’re fun to be with.",
"You make wonderful things.",
"Thanks for your diligence in running this house.",
"Our kids are so fortunate to have you as their mother.",
"You bring out the best in me.",
"You are a fantastic person.",
"My favorite place to be is with you.",
"You make loving fun.",
"You complete me.",
"I really admire your inner strength",
"You know you’re my best friend, don’t you?",
"You are so thoughtful.",
"I’m proud to be your husband.",
"I respect the woman you are.",
"You’ve got great ideas.",
"I married up!",
"I married a winner!",
"You are the best woman I know.",
"I want to grow old with you.",
"You bring me joy.",
"You are my dream girl.",
"I’ll be the one to cook dinner tonight! What do you like?",
"Let’s take a walk at the park and breathe some fresh air."
],
SKILL_NAME: 'My Wife',
GET_FACT_MESSAGE: "Hey ",
HELP_MESSAGE: 'You can say tell my wife she is pretty, or, you can say exit... What can I help you with?',
HELP_REPROMPT: 'What can I help you with?',
STOP_MESSAGE: 'Goodbye!',
},
}
};
const newSessionHandlers = {
'LaunchRequest': function () {
console.log("this is new session launch request");
this.emit('GetPretty');
},
'NewSession': function() {
if(Object.keys(this.attributes).length === 0) {
this.attributes['wifeName'] = 'Wife';
}
this.handler.state = states.COMPLIMENT;
console.log("this state: " + this.handler.state);
var intent = 'none';
try {
intent = this.event.request.intent.name;
} catch (err) {
intent = 'error';
}
if(['PrettyIntent','SexyIntent','SetNameIntent', 'LoveIntent'].indexOf(intent) > -1) {
this.emitWithState(intent);
} else {
this.emitWithState('PrettyIntent');
}
},
'SetNameIntent': function () {
const wifename = this.event.request.intent.slots.wifename.value;
console.log("Compliment SetNameIntent: " + wifename);
this.attributes['wifeName'] = wifename;
this.emit(':tell', "Wife's name is now set to " + wifename);
},
'AMAZON.HelpIntent': function () {
const speechOutput = this.t('HELP_MESSAGE');
const reprompt = this.t('HELP_MESSAGE');
this.emit(':ask', speechOutput, reprompt);
},
'AMAZON.CancelIntent': function () {
this.emit(':tell', this.t('STOP_MESSAGE'));
},
'AMAZON.StopIntent': function () {
this.emit(':tell', this.t('STOP_MESSAGE'));
},
'SessionEndedRequest': function () {
this.emit(':tell', this.t('STOP_MESSAGE'));
},
};
const handlers = Alexa.CreateStateHandler(states.COMPLIMENT, {
'LaunchRequest': function () {
console.log("this is compliment launch request");
this.emit('GetPretty');
},
'NewSession': function() {
console.log("this newsession of compliment");
console.log("this state: " + this.handler.state);
var intent = 'none';
try {
intent = this.event.request.intent.name;
} catch (err) {
intent = 'error';
}
console.log("this intent: " + intent);
if(['PrettyIntent','SexyIntent','SetNameIntent','LoveIntent'].indexOf(intent) > -1) {
this.emitWithState(intent);
} else {
this.emitWithState('PrettyIntent');
}
},
'PrettyIntent': function () {
this.emitWithState('GetPretty');
},
'GetPretty': function () {
console.log("compliment GetPretty");
// Get a random space fact from the space facts list
// Use this.t() to get corresponding language data
const factArr = this.t('PRETTY');
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
const speechOutput = this.t('GET_FACT_MESSAGE') + this.attributes['wifeName'] + ": " + randomFact;
this.emit(':tellWithCard', speechOutput, this.t('SKILL_NAME'), randomFact);
},
'SexyIntent': function () {
this.emitWithState('GetSexy');
},
'GetSexy': function () {
// Get a random space fact from the space facts list
// Use this.t() to get corresponding language data
const factArr = this.t('SEXY');
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
// Create speech output
const speechOutput = this.t('GET_FACT_MESSAGE') + this.attributes['wifeName'] + ": " + randomFact;
this.emit(':tellWithCard', speechOutput, this.t('SKILL_NAME'), randomFact);
},
'LoveIntent': function () {
this.emitWithState('GetLove');
},
'GetLove': function () {
// Get a random space fact from the space facts list
// Use this.t() to get corresponding language data
const factArr = this.t('LOVE');
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
// Create speech output
const speechOutput = this.t('GET_FACT_MESSAGE') + this.attributes['wifeName'] + ": " + randomFact;
this.emit(':tellWithCard', speechOutput, this.t('SKILL_NAME'), randomFact);
},
'SetNameIntent': function () {
const wifename = this.event.request.intent.slots.wifename.value;
console.log("Compliment SetNameIntent: " + wifename);
this.attributes['wifeName'] = wifename;
this.emit(':tell', "Wife's name is now set to " + wifename);
},
'AMAZON.HelpIntent': function () {
const speechOutput = this.t('HELP_MESSAGE');
const reprompt = this.t('HELP_MESSAGE');
this.emit(':ask', speechOutput, reprompt);
},
'AMAZON.CancelIntent': function () {
this.emit(':tell', this.t('STOP_MESSAGE'));
},
'AMAZON.StopIntent': function () {
this.emit(':tell', this.t('STOP_MESSAGE'));
},
'SessionEndedRequest': function () {
this.emit(':tell', this.t('STOP_MESSAGE'));
},
'Unhandled': function() {
console.log("UNHANDLED");
var message = 'The request sent was unknown, try again.';
this.emit(':tell', message);
}
});
exports.handler = (event, context) => {
const alexa = Alexa.handler(event, context);
alexa.appId = APP_ID;
alexa.dynamoDBTableName = 'myWifeData';
// To enable string internationalization (i18n) features, set a resources object.
alexa.resources = languageStrings;
alexa.registerHandlers(newSessionHandlers, handlers);
alexa.execute();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment