Alex Merchen
Created June 10, 2017

Alexa Storytime

Create an Alexa app that will read classic fables to users.

56
Alexa Storytime

Things used in this project

Hardware components

Echo Dot
Amazon Alexa Echo Dot
×1

Software apps and online services

AWS Lambda
Amazon Web Services AWS Lambda
Alexa Skills Kit
Amazon Alexa Alexa Skills Kit

Story

Read more

Code

Lambda Code

JavaScript
This is the code that I used for my lambda function
/* eslint-disable  func-names */
/* eslint quote-props: ["error", "consistent"]*/
/**
 * This sample demonstrates a simple skill built with the Amazon Alexa Skills
 * nodejs skill development kit.
 * This sample supports multiple lauguages. (en-US, en-GB, de-DE).
 * The Intent Schema, Custom Slots and Sample Utterances for this skill, as well
 * as testing instructions are located at https://github.com/alexa/skill-sample-nodejs-fact
 **/

'use strict';

const Alexa = require('alexa-sdk');

const APP_ID = "my App ID";  // TODO replace with your app ID (OPTIONAL).

const languageStrings = {
    'en': {
        translation: {
            FACTS: [
                'Avaricious and Envious. Two neighbours came before Jupiter and prayed him to grant their hearts desire. Now the one was full of avarice, and the other eaten up with envy. So to punish them both, Jupiter granted that each might have whatever he wished for himself, but only on condition that his neighbour had twice as much. The Avaricious man prayed to have a room full of gold. No sooner said than done; but all his joy was turned to grief when he found that his neighbour had two rooms full of the precious metal. Then came the turn of the Envious man, who could not bear to think that his neighbour had any joy at all. So he prayed that he might have one of his own eyes put out, by which means his companion would become totally blind.',
                'Hercules and the Waggoner. A Waggoner was once driving a heavy load along a very muddy way. At last he came to a part of the road where the wheels sank half-way into the mire, and the more the horses pulled, the deeper sank the wheels. So the Waggoner threw down his whip, and knelt down and prayed to Hercules the Strong. O Hercules, help me in this my hour of distress, quoth he. But Hercules appeared to him, and said: Tut, man, dont sprawl there. Get up and put your shoulder to the wheel.',
                'The Ant and the Grasshopper. In a field one summers day a Grasshopper was hopping about, chirping and singing to its hearts content. An Ant passed by, bearing along with great toil an ear of corn he was taking to the nest. Why not come and chat with me, said the Grasshopper, instead of toiling and moiling in that way? I am helping to lay up food for the winter, said the Ant, and recommend you to do the same. Why bother about winter? said the Grasshopper; we have got plenty of food at present. But the Ant went on its way and continued its toil. When the winter came the Grasshopper had no food and found itself dying of hunger, while it saw the ants distributing every day corn and grain from the stores they had collected in the summer. Then the Grasshopper knew: It is best to prepare for the days of necessity.',
                'The Bald Man and the Fly. There was once a Bald Man who sat down after work on a hot summers day. A Fly came up and kept buzzing about his bald pate, and stinging him from time to time. The Man aimed a blow at his little enemy, but his palm came on his head instead. Again the Fly tormented him, but this time the Man was wiser and said: You will only injure yourself if you take notice of despicable enemies.',
                'The Belly and the Members Fable. One fine day it occurred to the Members of the Body that they were doing all the work and the Belly was having all the food. So they held a meeting, and after a long discussion, decided to strike work till the Belly consented to take its proper share of the work. So for a day or two, the Hands refused to take the food, the Mouth refused to receive it, and the Teeth had no work to do. But after a day or two the Members began to find that they themselves were not in a very active condition: The Hands could hardly move, and the Mouth was all parched and dry, while the Legs were unable to support the rest. So thus they found that even the Belly in its dull quiet way was doing necessary work for the Body, and that all must work together or the Body will go to pieces.',
                'The Boys and the Frogs. Some boys, playing near a pond, saw a number of Frogs in the water, and began to pelt them with stones. They killed several of them, when one of the Frogs, lifting his head out of the water, cried out: Pray stop, my boys; what is sport to you is death to us.',
                'The Buffoon and the Countryman. At a country fair there was a Buffoon who made all the people laugh by imitating the cries of various animals. He finished off by squeaking so like a pig that the spectators thought that he had a porker concealed about him. But a Countryman who stood by said: Call that a pigs squeak! Nothing like it. You give me till tomorrow and I will show you what its like. The audience laughed, but next day, sure enough, the Countryman appeared on the stage, and putting his head down squealed so hideously that the spectators hissed and threw stones at him to make him stop.  You fools! he cried, see what you have been hissing, and held up a little pig whose ear he had been pinching to make him utter the squeals.',
                'The Bundle of Sticks. An old man on the point of death summoned his sons around him to give them some parting advice. He ordered his servants to bring in a group of sticks, and said to his eldest son:  Break it.  The son strained and strained, but with all his efforts was unable to break the Bundle. The other sons also tried, but none of them was successful.  Untie the group, said the father, and each of you take a stick. When they had done so, he called out to them:  Now, break, and each stick was easily broken. You see my meaning, said their father.',
                'The Camel and the Arab. An Arab Camel-driver having completed the lading of his Camel, asked him which he would like best, to go up hill or down hill. The poor beast replied, not without a touch of reason: Why do you ask me? Is it that the level way through the desert is closed?',
                'The Cat Maiden. The gods were once disputing whether it was possible for a living being to change its nature.  Jupiter said Yes, but Venus said No. So, to try the question, Jupiter turned a Cat into a Maiden, and gave her to a young man for a wife. The wedding was duly performed and the young couple sat down to the wedding-feast. See, said Jupiter, to Venus, how becomingly she behaves. Who could tell that yesterday she was but a Cat? Surely her nature is changed? Wait a minute, replied Venus, and let loose a mouse into the room. No sooner did the bride see this than she jumped up from her seat and tried to pounce upon the mouse.  Ah, you see, said Venus, Nature will out',
                'The Nurse and the Wolf. Be quiet now, said an old Nurse to a child sitting on her lap. If you make that noise again I will throw you to the Wolf. Now it chanced that a Wolf was passing close under the window as this was said. So he crouched down by the side of the house and waited. I am in good luck to-day, thought he. It is sure to cry soon, and a daintier morsel I havent had for many a long day. So he waited, and he waited, and he waited, till at last the child began to cry, and the Wolf came forward before the window, and looked up to the Nurse, wagging his tail. But all the Nurse did was to shut down the window and call for help, and the dogs of the house came rushing out. Ah, said the Wolf as he galloped away, Enemies promises were made to be broken.',
                'The Milkmade and her Pail. Patty the Milkmaid was going to market carrying her milk in a Pail on her head. As she went along she began calculating what she would do with the money she would get for the milk.  Ill buy some fowls from Farmer Brown, said she, and they will lay eggs each morning, which I will sell to the parsons wife. With the money that I get from the sale of these eggs Ill buy myself a new dimity frock and a chip hat; and when I go to market, wont all the young men come up and speak to me! Polly Shaw will be that jealous; but I dont care. I shall just look at her and toss my head like this. As she spoke she tossed her head back, the Pail fell off it, and all the milk was spilt. So she had to go home and tell her mother what had occurred. Ah, my child, said the mother: Do not count your chickens before they are hatched',
                'The Man and His Two Wives. In the old days, when men were allowed to have many wives, a middle-aged Man had one wife that was old and one that was young; each loved him very much, and desired to see him like herself. Now the Mans hair was turning grey, which the young Wife did not like, as it made him look too old for her husband. So every night she used to comb his hair and pick out the white ones. But the elder Wife saw her husband growing grey with great pleasure, for she did not like to be mistaken for his mother. So every morning she used to arrange his hair and pick out as many of the black ones as she could. The consequence was the Man soon found himself entirely bald.',
                'The Bat, the Birds, and the Beasts. A great conflict was about to come off between the Birds and the Beasts. When the two armies were collected together the Bat hesitated which to join. The Birds that passed his perch said: Come with us; but he said: I am a Beast. Later on, some Beasts who were passing underneath him looked up and said: Come with us; but he said: I am a Bird. Luckily at the last moment peace was made, and no battle took place, so the Bat came to the Birds and wished to join in the rejoicings, but they all turned against him and he had to fly away. He then went to the Beasts, but soon had to beat a retreat, or else they would have torn him to pieces.  Ah, said the Bat, I see now, He that is neither one thing nor the other has no friends.',
                'A Lion once fell in love with a beautiful maiden and proposed marriage to her parents. The old people did not know what to say. They did not like to give their daughter to the Lion, yet they did not wish to enrage the King of Beasts. At last the father said: We feel highly honoured by your Majestys proposal, but you see our daughter is a tender young thing, and we fear that in the vehemence of your affection you might possibly do her some injury. Might I venture to suggest that your Majesty should have your claws removed, and your teeth extracted, then we would gladly consider your proposal again. The Lion was so much in love that he had his claws trimmed and his big teeth taken out. But when he came again to the parents of the young girl they simply laughed in his face, and bade him do his worst.',
                'A Sailor, bound on a long voyage, took with him a Monkey to amuse him while on shipboard. As he sailed off the coast of Greece, a violent tempest arose, in which the ship was wrecked, and he, his Monkey and all the crew were obliged to swim for their lives. A Dolphin saw the Monkey contending with the waves, and supposing him to be a man (whom he is always said to befriend), came and placed himself under him, to convey him on his back in safety to the shore. When the Dolphin arrived with his burden in sight of land not far from Athens, he demanded of the Monkey if he were an Athenian, who answered that he was, and that he was descended from one of the noblest families in that city. The Dolphin then inquired if he knew the Piræus (the famous harbor of Athens). The Monkey, supposing that a man was meant, and being obliged to support his previous lie, answered that he knew him very well, and that he was an intimate friend, who would, no doubt, be very glad to see him. The Dolphin, indignant at these falsehoods, dipped the Monkey under the water, and drowned him.',
            ],
            SKILL_NAME: 'Story Time',
            GET_FACT_MESSAGE: "Here's your story: ",
            HELP_MESSAGE: 'You can say tell me a story, or, you can say exit... What can I help you with?',
            HELP_REPROMPT: 'What can I help you with?',
            STOP_MESSAGE: 'Goodbye!',
        },
    },
    'en-US': {
        translation: {
            FACTS: [
                'Avaricious and Envious. Two neighbours came before Jupiter and prayed him to grant their hearts desire. Now the one was full of avarice, and the other eaten up with envy. So to punish them both, Jupiter granted that each might have whatever he wished for himself, but only on condition that his neighbour had twice as much. The Avaricious man prayed to have a room full of gold. No sooner said than done; but all his joy was turned to grief when he found that his neighbour had two rooms full of the precious metal. Then came the turn of the Envious man, who could not bear to think that his neighbour had any joy at all. So he prayed that he might have one of his own eyes put out, by which means his companion would become totally blind.',
                'Hercules and the Waggoner. A Waggoner was once driving a heavy load along a very muddy way. At last he came to a part of the road where the wheels sank half-way into the mire, and the more the horses pulled, the deeper sank the wheels. So the Waggoner threw down his whip, and knelt down and prayed to Hercules the Strong. O Hercules, help me in this my hour of distress, quoth he. But Hercules appeared to him, and said: Tut, man, dont sprawl there. Get up and put your shoulder to the wheel.',
                'The Ant and the Grasshopper. In a field one summers day a Grasshopper was hopping about, chirping and singing to its hearts content. An Ant passed by, bearing along with great toil an ear of corn he was taking to the nest. Why not come and chat with me, said the Grasshopper, instead of toiling and moiling in that way? I am helping to lay up food for the winter, said the Ant, and recommend you to do the same. Why bother about winter? said the Grasshopper; we have got plenty of food at present. But the Ant went on its way and continued its toil. When the winter came the Grasshopper had no food and found itself dying of hunger, while it saw the ants distributing every day corn and grain from the stores they had collected in the summer. Then the Grasshopper knew: It is best to prepare for the days of necessity.',
                'The Bald Man and the Fly. There was once a Bald Man who sat down after work on a hot summers day. A Fly came up and kept buzzing about his bald pate, and stinging him from time to time. The Man aimed a blow at his little enemy, but his palm came on his head instead. Again the Fly tormented him, but this time the Man was wiser and said: You will only injure yourself if you take notice of despicable enemies.',
                'The Belly and the Members Fable. One fine day it occurred to the Members of the Body that they were doing all the work and the Belly was having all the food. So they held a meeting, and after a long discussion, decided to strike work till the Belly consented to take its proper share of the work. So for a day or two, the Hands refused to take the food, the Mouth refused to receive it, and the Teeth had no work to do. But after a day or two the Members began to find that they themselves were not in a very active condition: The Hands could hardly move, and the Mouth was all parched and dry, while the Legs were unable to support the rest. So thus they found that even the Belly in its dull quiet way was doing necessary work for the Body, and that all must work together or the Body will go to pieces.',
                'The Boys and the Frogs. Some boys, playing near a pond, saw a number of Frogs in the water, and began to pelt them with stones. They killed several of them, when one of the Frogs, lifting his head out of the water, cried out: Pray stop, my boys; what is sport to you is death to us.',
                'The Buffoon and the Countryman. At a country fair there was a Buffoon who made all the people laugh by imitating the cries of various animals. He finished off by squeaking so like a pig that the spectators thought that he had a porker concealed about him. But a Countryman who stood by said: Call that a pigs squeak! Nothing like it. You give me till tomorrow and I will show you what its like. The audience laughed, but next day, sure enough, the Countryman appeared on the stage, and putting his head down squealed so hideously that the spectators hissed and threw stones at him to make him stop.  You fools! he cried, see what you have been hissing, and held up a little pig whose ear he had been pinching to make him utter the squeals.',
                'The Bundle of Sticks. An old man on the point of death summoned his sons around him to give them some parting advice. He ordered his servants to bring in a group of sticks, and said to his eldest son:  Break it.  The son strained and strained, but with all his efforts was unable to break the Bundle. The other sons also tried, but none of them was successful.  Untie the group, said the father, and each of you take a stick. When they had done so, he called out to them:  Now, break, and each stick was easily broken. You see my meaning, said their father.',
                'The Camel and the Arab. An Arab Camel-driver having completed the lading of his Camel, asked him which he would like best, to go up hill or down hill. The poor beast replied, not without a touch of reason: Why do you ask me? Is it that the level way through the desert is closed?',
                'The Cat Maiden. The gods were once disputing whether it was possible for a living being to change its nature.  Jupiter said Yes, but Venus said No. So, to try the question, Jupiter turned a Cat into a Maiden, and gave her to a young man for a wife. The wedding was duly performed and the young couple sat down to the wedding-feast. See, said Jupiter, to Venus, how becomingly she behaves. Who could tell that yesterday she was but a Cat? Surely her nature is changed? Wait a minute, replied Venus, and let loose a mouse into the room. No sooner did the bride see this than she jumped up from her seat and tried to pounce upon the mouse.  Ah, you see, said Venus, Nature will out',
                'The Nurse and the Wolf. Be quiet now, said an old Nurse to a child sitting on her lap. If you make that noise again I will throw you to the Wolf. Now it chanced that a Wolf was passing close under the window as this was said. So he crouched down by the side of the house and waited. I am in good luck to-day, thought he. It is sure to cry soon, and a daintier morsel I havent had for many a long day. So he waited, and he waited, and he waited, till at last the child began to cry, and the Wolf came forward before the window, and looked up to the Nurse, wagging his tail. But all the Nurse did was to shut down the window and call for help, and the dogs of the house came rushing out. Ah, said the Wolf as he galloped away, Enemies promises were made to be broken.',
                'The Milkmade and her Pail. Patty the Milkmaid was going to market carrying her milk in a Pail on her head. As she went along she began calculating what she would do with the money she would get for the milk.  Ill buy some fowls from Farmer Brown, said she, and they will lay eggs each morning, which I will sell to the parsons wife. With the money that I get from the sale of these eggs Ill buy myself a new dimity frock and a chip hat; and when I go to market, wont all the young men come up and speak to me! Polly Shaw will be that jealous; but I dont care. I shall just look at her and toss my head like this. As she spoke she tossed her head back, the Pail fell off it, and all the milk was spilt. So she had to go home and tell her mother what had occurred. Ah, my child, said the mother: Do not count your chickens before they are hatched',
                'The Man and His Two Wives. In the old days, when men were allowed to have many wives, a middle-aged Man had one wife that was old and one that was young; each loved him very much, and desired to see him like herself. Now the Mans hair was turning grey, which the young Wife did not like, as it made him look too old for her husband. So every night she used to comb his hair and pick out the white ones. But the elder Wife saw her husband growing grey with great pleasure, for she did not like to be mistaken for his mother. So every morning she used to arrange his hair and pick out as many of the black ones as she could. The consequence was the Man soon found himself entirely bald.',
                'The Bat, the Birds, and the Beasts. A great conflict was about to come off between the Birds and the Beasts. When the two armies were collected together the Bat hesitated which to join. The Birds that passed his perch said: Come with us; but he said: I am a Beast. Later on, some Beasts who were passing underneath him looked up and said: Come with us; but he said: I am a Bird. Luckily at the last moment peace was made, and no battle took place, so the Bat came to the Birds and wished to join in the rejoicings, but they all turned against him and he had to fly away. He then went to the Beasts, but soon had to beat a retreat, or else they would have torn him to pieces.  Ah, said the Bat, I see now, He that is neither one thing nor the other has no friends.',
                'A Lion once fell in love with a beautiful maiden and proposed marriage to her parents. The old people did not know what to say. They did not like to give their daughter to the Lion, yet they did not wish to enrage the King of Beasts. At last the father said: We feel highly honoured by your Majestys proposal, but you see our daughter is a tender young thing, and we fear that in the vehemence of your affection you might possibly do her some injury. Might I venture to suggest that your Majesty should have your claws removed, and your teeth extracted, then we would gladly consider your proposal again. The Lion was so much in love that he had his claws trimmed and his big teeth taken out. But when he came again to the parents of the young girl they simply laughed in his face, and bade him do his worst.',
                'A Sailor, bound on a long voyage, took with him a Monkey to amuse him while on shipboard. As he sailed off the coast of Greece, a violent tempest arose, in which the ship was wrecked, and he, his Monkey and all the crew were obliged to swim for their lives. A Dolphin saw the Monkey contending with the waves, and supposing him to be a man (whom he is always said to befriend), came and placed himself under him, to convey him on his back in safety to the shore. When the Dolphin arrived with his burden in sight of land not far from Athens, he demanded of the Monkey if he were an Athenian, who answered that he was, and that he was descended from one of the noblest families in that city. The Dolphin then inquired if he knew the Piræus (the famous harbor of Athens). The Monkey, supposing that a man was meant, and being obliged to support his previous lie, answered that he knew him very well, and that he was an intimate friend, who would, no doubt, be very glad to see him. The Dolphin, indignant at these falsehoods, dipped the Monkey under the water, and drowned him.',
            ],
            SKILL_NAME: 'American Story Time',
        },
    },
    'en-GB': {
        translation: {
            FACTS: [
                'Avaricious and Envious. Two neighbours came before Jupiter and prayed him to grant their hearts desire. Now the one was full of avarice, and the other eaten up with envy. So to punish them both, Jupiter granted that each might have whatever he wished for himself, but only on condition that his neighbour had twice as much. The Avaricious man prayed to have a room full of gold. No sooner said than done; but all his joy was turned to grief when he found that his neighbour had two rooms full of the precious metal. Then came the turn of the Envious man, who could not bear to think that his neighbour had any joy at all. So he prayed that he might have one of his own eyes put out, by which means his companion would become totally blind.',
                'Hercules and the Waggoner. A Waggoner was once driving a heavy load along a very muddy way. At last he came to a part of the road where the wheels sank half-way into the mire, and the more the horses pulled, the deeper sank the wheels. So the Waggoner threw down his whip, and knelt down and prayed to Hercules the Strong. O Hercules, help me in this my hour of distress, quoth he. But Hercules appeared to him, and said: Tut, man, dont sprawl there. Get up and put your shoulder to the wheel.',
                'The Ant and the Grasshopper. In a field one summers day a Grasshopper was hopping about, chirping and singing to its hearts content. An Ant passed by, bearing along with great toil an ear of corn he was taking to the nest. Why not come and chat with me, said the Grasshopper, instead of toiling and moiling in that way? I am helping to lay up food for the winter, said the Ant, and recommend you to do the same. Why bother about winter? said the Grasshopper; we have got plenty of food at present. But the Ant went on its way and continued its toil. When the winter came the Grasshopper had no food and found itself dying of hunger, while it saw the ants distributing every day corn and grain from the stores they had collected in the summer. Then the Grasshopper knew: It is best to prepare for the days of necessity.',
                'The Bald Man and the Fly. There was once a Bald Man who sat down after work on a hot summers day. A Fly came up and kept buzzing about his bald pate, and stinging him from time to time. The Man aimed a blow at his little enemy, but his palm came on his head instead. Again the Fly tormented him, but this time the Man was wiser and said: You will only injure yourself if you take notice of despicable enemies.',
                'The Belly and the Members Fable. One fine day it occurred to the Members of the Body that they were doing all the work and the Belly was having all the food. So they held a meeting, and after a long discussion, decided to strike work till the Belly consented to take its proper share of the work. So for a day or two, the Hands refused to take the food, the Mouth refused to receive it, and the Teeth had no work to do. But after a day or two the Members began to find that they themselves were not in a very active condition: The Hands could hardly move, and the Mouth was all parched and dry, while the Legs were unable to support the rest. So thus they found that even the Belly in its dull quiet way was doing necessary work for the Body, and that all must work together or the Body will go to pieces.',
                'The Boys and the Frogs. Some boys, playing near a pond, saw a number of Frogs in the water, and began to pelt them with stones. They killed several of them, when one of the Frogs, lifting his head out of the water, cried out: Pray stop, my boys; what is sport to you is death to us.',
                'The Buffoon and the Countryman. At a country fair there was a Buffoon who made all the people laugh by imitating the cries of various animals. He finished off by squeaking so like a pig that the spectators thought that he had a porker concealed about him. But a Countryman who stood by said: Call that a pigs squeak! Nothing like it. You give me till tomorrow and I will show you what its like. The audience laughed, but next day, sure enough, the Countryman appeared on the stage, and putting his head down squealed so hideously that the spectators hissed and threw stones at him to make him stop.  You fools! he cried, see what you have been hissing, and held up a little pig whose ear he had been pinching to make him utter the squeals.',
                'The Bundle of Sticks. An old man on the point of death summoned his sons around him to give them some parting advice. He ordered his servants to bring in a group of sticks, and said to his eldest son:  Break it.  The son strained and strained, but with all his efforts was unable to break the Bundle. The other sons also tried, but none of them was successful.  Untie the group, said the father, and each of you take a stick. When they had done so, he called out to them:  Now, break, and each stick was easily broken. You see my meaning, said their father.',
                'The Camel and the Arab. An Arab Camel-driver having completed the lading of his Camel, asked him which he would like best, to go up hill or down hill. The poor beast replied, not without a touch of reason: Why do you ask me? Is it that the level way through the desert is closed?',
                'The Cat Maiden. The gods were once disputing whether it was possible for a living being to change its nature.  Jupiter said Yes, but Venus said No. So, to try the question, Jupiter turned a Cat into a Maiden, and gave her to a young man for a wife. The wedding was duly performed and the young couple sat down to the wedding-feast. See, said Jupiter, to Venus, how becomingly she behaves. Who could tell that yesterday she was but a Cat? Surely her nature is changed? Wait a minute, replied Venus, and let loose a mouse into the room. No sooner did the bride see this than she jumped up from her seat and tried to pounce upon the mouse.  Ah, you see, said Venus, Nature will out',
                'The Nurse and the Wolf. Be quiet now, said an old Nurse to a child sitting on her lap. If you make that noise again I will throw you to the Wolf. Now it chanced that a Wolf was passing close under the window as this was said. So he crouched down by the side of the house and waited. I am in good luck to-day, thought he. It is sure to cry soon, and a daintier morsel I havent had for many a long day. So he waited, and he waited, and he waited, till at last the child began to cry, and the Wolf came forward before the window, and looked up to the Nurse, wagging his tail. But all the Nurse did was to shut down the window and call for help, and the dogs of the house came rushing out. Ah, said the Wolf as he galloped away, Enemies promises were made to be broken.',
                'The Milkmade and her Pail. Patty the Milkmaid was going to market carrying her milk in a Pail on her head. As she went along she began calculating what she would do with the money she would get for the milk.  Ill buy some fowls from Farmer Brown, said she, and they will lay eggs each morning, which I will sell to the parsons wife. With the money that I get from the sale of these eggs Ill buy myself a new dimity frock and a chip hat; and when I go to market, wont all the young men come up and speak to me! Polly Shaw will be that jealous; but I dont care. I shall just look at her and toss my head like this. As she spoke she tossed her head back, the Pail fell off it, and all the milk was spilt. So she had to go home and tell her mother what had occurred. Ah, my child, said the mother: Do not count your chickens before they are hatched',
                'The Man and His Two Wives. In the old days, when men were allowed to have many wives, a middle-aged Man had one wife that was old and one that was young; each loved him very much, and desired to see him like herself. Now the Mans hair was turning grey, which the young Wife did not like, as it made him look too old for her husband. So every night she used to comb his hair and pick out the white ones. But the elder Wife saw her husband growing grey with great pleasure, for she did not like to be mistaken for his mother. So every morning she used to arrange his hair and pick out as many of the black ones as she could. The consequence was the Man soon found himself entirely bald.',
                'The Bat, the Birds, and the Beasts. A great conflict was about to come off between the Birds and the Beasts. When the two armies were collected together the Bat hesitated which to join. The Birds that passed his perch said: Come with us; but he said: I am a Beast. Later on, some Beasts who were passing underneath him looked up and said: Come with us; but he said: I am a Bird. Luckily at the last moment peace was made, and no battle took place, so the Bat came to the Birds and wished to join in the rejoicings, but they all turned against him and he had to fly away. He then went to the Beasts, but soon had to beat a retreat, or else they would have torn him to pieces.  Ah, said the Bat, I see now, He that is neither one thing nor the other has no friends.',
                'A Lion once fell in love with a beautiful maiden and proposed marriage to her parents. The old people did not know what to say. They did not like to give their daughter to the Lion, yet they did not wish to enrage the King of Beasts. At last the father said: We feel highly honoured by your Majestys proposal, but you see our daughter is a tender young thing, and we fear that in the vehemence of your affection you might possibly do her some injury. Might I venture to suggest that your Majesty should have your claws removed, and your teeth extracted, then we would gladly consider your proposal again. The Lion was so much in love that he had his claws trimmed and his big teeth taken out. But when he came again to the parents of the young girl they simply laughed in his face, and bade him do his worst.',
                'A Sailor, bound on a long voyage, took with him a Monkey to amuse him while on shipboard. As he sailed off the coast of Greece, a violent tempest arose, in which the ship was wrecked, and he, his Monkey and all the crew were obliged to swim for their lives. A Dolphin saw the Monkey contending with the waves, and supposing him to be a man (whom he is always said to befriend), came and placed himself under him, to convey him on his back in safety to the shore. When the Dolphin arrived with his burden in sight of land not far from Athens, he demanded of the Monkey if he were an Athenian, who answered that he was, and that he was descended from one of the noblest families in that city. The Dolphin then inquired if he knew the Piræus (the famous harbor of Athens). The Monkey, supposing that a man was meant, and being obliged to support his previous lie, answered that he knew him very well, and that he was an intimate friend, who would, no doubt, be very glad to see him. The Dolphin, indignant at these falsehoods, dipped the Monkey under the water, and drowned him.',
            ],
            SKILL_NAME: 'British Story Time',
        },
    },
};

const handlers = {
    'LaunchRequest': function () {
        this.emit('GetFact');
    },
    'GetNewFactIntent': function () {
        this.emit('GetFact');
    },
    'GetFact': function () {
        // Get a random space fact from the space facts list
        // Use this.t() to get corresponding language data
        const factArr = this.t('FACTS');
        const factIndex = Math.floor(Math.random() * factArr.length);
        const randomFact = factArr[factIndex];

        // Create speech output
        const speechOutput = this.t('GET_FACT_MESSAGE') + randomFact;
        this.emit(':tellWithCard', speechOutput, this.t('SKILL_NAME'), randomFact);
    },
    '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'));
    },
};

exports.handler = function (event, context) {
    const alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    // To enable string internationalization (i18n) features, set a resources object.
    alexa.resources = languageStrings;
    alexa.registerHandlers(handlers);
    alexa.execute();
};

Credits

Alex Merchen

Alex Merchen

22 projects • 37 followers
I'm an EE with a Masters in ECE. I like building things.

Comments