Coder Social home page Coder Social logo

alexa-samples / skill-sample-nodejs-fact Goto Github PK

View Code? Open in Web Editor NEW
1.1K 136.0 1.2K 444 KB

Build An Alexa Fact Skill

License: Apache License 2.0

JavaScript 86.70% PowerShell 7.88% Shell 5.42%
beginner ask-sdk-for-nodejs alexa-skill-sample ask-sdk-for-nodejs-v2

skill-sample-nodejs-fact's Introduction

Build An Alexa Fact Skill

This Alexa sample skill is a template for a basic fact skill.

Skill Architecture

Each skill consists of two basic parts, a front end and a back end. The front end is the voice interface, or VUI. The voice interface is configured through the voice interaction model. The back end is where the logic of your skill resides.

Three Options for Skill Setup

There are a number of different ways for you to setup your skill, depending on your experience and what tools you have available.


Additional Resources

Community

Tutorials & Guides

  • Voice Design Guide - A great resource for learning conversational and voice user interface design.
  • Codecademy: Learn Alexa - Learn how to build an Alexa Skill from within your browser with this beginner friendly tutorial on Codecademy!

Documentation

skill-sample-nodejs-fact's People

Contributors

ahmedgouda avatar akersh-s avatar aszk avatar bhaskarmelkani avatar deegles avatar fffej avatar franklin-lobb avatar jakemkelly avatar jbnunn avatar jeffblankenburg avatar jkelvie avatar kaydee avatar letmypeoplecode avatar mandnyc avatar mattsoftware avatar mau04 avatar memodoring avatar mikegjennings avatar rabadash8820 avatar raeglan avatar reaganmcf avatar robm26 avatar ryanjlowe avatar shreyas-vgr avatar sleepydeveloper avatar stagingreview avatar tonyamzn avatar urbanninjadev avatar xiangxie avatar ygzy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skill-sample-nodejs-fact's Issues

Issues with skill endpoint

Hi,
I applied for certification after following the skill-sample guide and got below response from Amazon.

"Future versions of the Alexa Skills Kit may add new properties to the JSON request and response formats, while maintaining backward compatibility for the existing properties. When we invoke the skill with additional parameters, the skill is rejecting it when we expect this to be accepted. Your code must be resilient to these types of changes. For example, your code for de-serializing a JSON request must not break when it encounters a new, unknown property."

However, i tried and added multiple extra elements in the request and the response always returned 200.

Below is my lambda function:

'use strict';
var Alexa = require('alexa-sdk');
var APP_ID = "amzn1.ask.skill.f472dac6-e6ca-48bb-9dfb-4d34c009b975";

 var SKILL_NAME = "Cricket Facts";
 var GET_FACT_MESSAGE = "Here's your fact: ";
  var HELP_MESSAGE = "You can say tell me a cricket fact, or, you can say exit... What can I help you with?";
 var HELP_REPROMPT = "What can I help you with?";
 var STOP_MESSAGE = "Goodbye!";

var data = [
"It is said that cricket originated in England. Since they used to raise sheep, the grass was so short that it was possible to roll a lump of wool on it which they used as a ball.",
"The first recorded game was played in 1646, and later fines were handed out for those who missed the church to play.",
"In the 1760’s, pitching a ball through the air was considered normal, thus the bat shape changed from a curve to a straight one.",
"The longest cricket match took place in 1939 between England and South Africa, after 14 days it ended with a tie.",
"The two most common causes for pausing or suspending a cricket game is rain and bad light.",
"When a batsman scores 100 runs, it called a century and is considered an achievement.",
"A cricket game was once stopped because a pig ran across the field. It is even considered legal to suspend the game if an animal entered the field.",
"Only one player can run out at a time. Usually left for the umpire to decide.",
"A cricket game has two umpires in the field and one off the field.",
"Despite being a team game, individuals are stressed upon and put under pressure.",
"Shahid Afridi used Sachin Tendulkar's bat to hit the fastest ever ODI century.",
"Chris Gayle is the only batsman to hit a six off the first ball of a Test match",
"Abbas Ali Baig was the first Indian cricketer to be kissed during a Test",
"Vinod Kambli's Test match average is better than his childhood friend Sachin Tendulkar",
"Sunil Gavaskar was out off the first ball of a Test match thrice in his career",
"ML Jaisimha and Ravi Shastri are the only Indians to bat on all five days of a Test",
"The only cricketer to play Test cricket for India and England is Saif Ali Khan’s grandfather, Iftikhar Ali Khan Pataudi",
"Lala Amarnath is the only bowler to dismiss Don Bradman hit wicket in Test cricket",
"There's an uncanny similarity between the Indo-Pak match at the Australasia Cup of 1986 and Asia Cup 2014",
"India won the 1983 World Cup and won their first ever Test at Lord’s three years later in 1986.",
"India won their second World Cup 28 years later in 2011 and remarkably won their second ever Test at Lord’s three years later in 2014.",
"India is the only country to win the 60-Over, 50-Over and 20-Over World Cup",
"Alec Stewart was born on 8-4-63 and he scored 8463 Test runs",
"Asif Karim of Kenya has played International cricket and Davis Cup (Tennis) for his country",
"Wilfred Rhodes of England played Test cricket till he was 52!",
"Allan Border played 153 consecutive Test matches",
"The only Indian Test cricketer to be knighted is Maharaja of Vizianagaram",
"Australia beat England by 45 runs in the first ever cricket Test as well as the Centenary Test in 1977",
"All four innings of a test on the same day",
"There's only one person who witnessed Jim Laker and Anil Kumble taking 10 wickets in an innings",
"On the morning of 11/11/11 South Africa needed 111 runs to win at 11:11",
"Peter Siddle is the only bowler to take a hat-trick on his birthday",
"India's Mohinder Amarnath is the only cricketer to be dismissed for handling the ball and obstructing the field",
"West Indies' Leslie Hylton is the only cricketer to be hanged for murder",
"Two Robin Singhs have played Test cricket for India and both never got to play after their debut Test",
"Sachin Tendulkar played for Pakistan before India"
];

//=========================================================================================================================================
//Editing anything below this line might break your skill.
//=========================================================================================================================================
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.APP_ID = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
};

var handlers = {
'LaunchRequest': function () {
this.emit('GetNewFactIntent');
},
'GetNewCricketFact': function () {
var factArr = data;
var factIndex = Math.floor(Math.random() * factArr.length);
var randomFact = factArr[factIndex];
var speechOutput = GET_FACT_MESSAGE + randomFact;
this.emit(':tellWithCard', speechOutput, SKILL_NAME, randomFact)
},
'AMAZON.HelpIntent': function () {
var speechOutput = HELP_MESSAGE;
var reprompt = HELP_REPROMPT;
this.emit(':ask', speechOutput, reprompt);
},
'AMAZON.CancelIntent': function () {
this.emit(':tell', STOP_MESSAGE);
},
'AMAZON.StopIntent': function () {
this.emit(':tell', STOP_MESSAGE);
}
};

Any help to understand what validation is failing? Sample request is below:

{
"session": {
"sessionId": "SessionId.8cf178d5-5687-4b6a-b8f8-dc422e186c2d",
"junkParam": "junkValue",
"application": {
"applicationId": "amzn1.ask.skill.f472dac6-e6ca-48bb-9dfb-4d34c009b975",
"junkParam": "junkValue"
},
"attributes": {
"junkParam": "junkValue"
},
"user": {
"userId": "amzn1.ask.account.AHEBAL5FTGHIGN67OVCPN3Z6YNVBSLA624DION4IYK7URUFGC3NNVI5ZGACWUBEO2FRJWJTR7S5YM62VZT4HM2R3LPQPDV666GCIIAM7ZJJBMO2ZCJSOCTJ4TMKHNRGA5S2TDY2BSSRM4DOQRLFW63LLLER72HV5YJ4IS3QIRALAMLWSKNER566S2JLFV43YRDEXZXOIH3TC6VQ",
"junkParam": "junkValue"
},
"new": true
},
"request": {
"type": "IntentRequest",
"junkParam": "junkValue",
"requestId": "EdwRequestId.d9bb38de-aa58-4981-a32b-e1d32701d1f9",
"locale": "en-US",
"timestamp": "2017-06-06T02:15:01Z",
"intent": {
"name": "GetNewCricketFact",
"junkParam": "junkValue",
"slots": {}
}
},
"version": "1.0"
}

Regards,
Navin

Intents dont launch, only invocations.

When you test and utter the sample utterance, the skill wont launch. It only launches when invocation name is called. The Python space facts also do the same.

does alexa support exclamation mark?

The documentation on amazon developer site only mentions "." "," "?" as characters that influence the speech. Does exclamation mark actually change alexa's voice? I can't hear a difference.

Error: Unhandled function is undefined....

I'm very new to making skills for Alexa, so trying to follow along but I'm stuck. Seems like I'm having a problem while testing using the skill code that's provided in this tutorial. When I test the sample code in the Lambda function code box, I get an error that states that the unhandled function is undefined. This seems to be a problem with a few folks, so I found the following code that helped to solve the error that I inserted in the handlers section:

'Unhandled': function () {
this.emit(':ask', HELP_MESSAGE, HELP_REPROMPT);
}

The error disappears, but outside of testing out launch, help, & stop/cancel intents, I am not able to get the correct responses to the my intents when I enter my utterances. The only response I can get to the utterances for the GetNewFactIntent is whatever is in the unhandled function (i.e, HELP_MESSAGE).

Hope this makes sense. Can anyone help???

Amazon Alexa Development Site Changed!

This Alexa skill sample documentation needs updating to reflect to changes made in the developer console.
If you would like help more developers you should UPDATE your documentation as this makes this current sample guide for development using its tools near impossible!!!!
If you did put this repository to help others great! if not remove it we don't need to feed your star ego!

Runtime

The Runtime needs to be changed for the AWS Lambda Template
Runtime: nodejs8.10 is not supported any longer

Error in Testing Step - Service Simulator

After entering the utterance "Tell me a fact", I am getting error as "The remote endpoint could not be called, or the response it returned was invalid." I tried the troubleshooting step, and it was fine, but in logs I found some Application ID issue. (Please check the attachment).
Can you please help me on this?
image

Voice model and sample code not working for Hindi

I've tried to use the sample code to build an alexa skill in Hindi but every time I pass a valid user input I'm not getting any proper output. I'm using alexa hosted back-end.
Example:
Me: ( A valid user invoke statement )
Alexa: "< Audio Only Response >"

Lambda ARN

Where can i find the Lambda's ARN (Amazon Resource Name)

Something went wrong

I followed the tutorial as is and tested it I am getting the correct response that is json object while testing in Alexa skill kit but when I try it on real device (echo) it keeps saying something went wrong.

Cannot find module 'alexa-sdk'" error at LAMDA FUNCTION

I'm new to Alexa skills, I fallowed all the steps. Here's the error I get on this line "var Alexa = require("alexa-sdk");". Am I doing something wrong? Or is there some configuration setting I need to do?

{
"errorMessage": "Cannot find module 'alexa-sdk'",

The remote endpoint could not be called, or the response it returned was invalid.

I am new at developing with alexa. I followed to tutorial but when I get into the testing section it gives me an error:
The remote endpoint could not be called, or the response it returned was invalid.

Don't know what I did wrong - the arn is copied correctly.
I'm following the tutorial here: https://developer.amazon.com/alexa-skills-kit/tutorials/fact-skill-4

I am facing the issue in both N Virginia and Ireland regions

Tutorial for ask-cli does not work

Hi,

the tutorial does not work completlty. If I try to enable the skill I get the error:

Call enable-skill error.
Error code: 403
{
"message": "Skill is not ready for enablement.",
"violations": [
{
"message": "custom - object has missing required properties (["endpoint"])"
}
]
}

So I guess that some configuration is missing?

alexa_skill_kit_entwicklerkonsole

Images broken in lambda-role.md

lambda-role.md uses a number of images that have been removed. Either new screenshots need to be added or the old ones restored.

Skill works fine in Simulator, but anything beyond the opening invocation fails to work

Hi! I followed this tutorial and submitted a skill to Amazon. I forgot about and came back two months later to see it had a fair amount of use, but the 1 review posted said that it opened but that subsequent commands didn't work. I checked the metrics, and that appears to be the case for everyone who downloaded it.

I didn't have any issues in the simulator, but when I tested it on echoism.io I had the same issue. Here's the code I'm using compared to the source code, and some screenshots. What am I doing incorrectly? My app is called "Good Questions" fyi.

Here's the index code comparison.
Here's the json file. It looks a little different, but when I submitted it to Amazon it was the same and it appears that the code was deprecated and the skill builder updated it automatically.

Here's a screenshot of my skill builder -
getnewfactintent

and my metrics
metrics

Let me know if you need anything else - thanks in advance!

TODOs have been removed

It looks like that all the TODOs in the index.js have been removed with this commit: fd7307a

This breaks Part 5 of the tutorial.

help with arn

I can't seem to get the correct format for arn,
is there a place i can get my arn.
I am currently using:
arn:aws:lambda:us-east:#######:ask.skill:myappname

and I keep getting the error : The provided Lambda ARN is not in the correct format.
please help

Docs: Broken link to "Interaction Model"

How to maintain the session?

Hi, I am modifying the code to include repeat intent. I need to maintain the session attributes to get the repeat working. If you know how to maintain the session, please let me know. Thanks.

FYI -- The following is the code I added for repeatIntent:

'AMAZON.RepeatIntent': function () { var reprompt = this.t("HELP_MESSAGE"); console.log('Inside RepeatIntent Stored speech attributes: ' + this.attributes['speech']); this.emit(':ask', this.attributes['speech'], reprompt); },

Sample app does not handle exit/quit/close

Hello,
The sample app does not seem to handle the phrases "Exit/close/quit" even though these are required for certification. Whats more, even if you do add these to the sample utterances and test out on developer.amazon.com, it does not seem to work at all:

AMAZON.StopIntent exit
AMAZON.StopIntent close
AMAZON.StopIntent quit

Also, just testing this on Lambda, with a Alexa End session with edited App ID fails with the message:

{
  "errorMessage": "No 'Unhandled' function defined for event: Unhandled",
  "errorType": "Error",
  "stackTrace": [
    "AlexaRequestEmitter.EmitEvent (/var/task/node_modules/alexa-sdk/lib/alexa.js:140:15)",
    "AlexaRequestEmitter.HandleLambdaEvent (/var/task/node_modules/alexa-sdk/lib/alexa.js:110:23)",
    "AlexaRequestEmitter.Object.defineProperty.value (/var/task/node_modules/alexa-sdk/lib/alexa.js:72:31)",
    "exports.handler (/var/task/index.js:34:11)"
  ]
}

EDIT: Similar to : https://forums.developer.amazon.com/questions/5938/error-with-utterances-quit-exit-remote-endpoint.html
EDIT2: The sample app does handle stop but apparently this is not sufficient for certification
What could the issue be?
@PaulCutsinger
@deegles

What are the AMAZON.* intents for?

Hi

I'm an Alexa- beginner and I do not understand the behavior of this skill:
(testing with https://developer.amazon.com/alexa/console/)

Alexa, open Space Facts

    Here's your fact: Neutron stars can spin at a rate of 600 rotations per second

afterward:

Alexa, start Space Facts to help

   The first person to reach space and the first person to be in orbit was Yuri Gagarin. 

again:

open Space Facts

    Here's your fact: The largest asteroid ever recorded is a mammoth piece of space rock named Ceres.

help

    For Help, please visit the help pages on the Amazon web site.

it seems to me that after GetNewFactIntent, the skill immediately "exit"
and I have to invoke again the skill.

So I do not understand when events will be fired:

    'AMAZON.HelpIntent': function () {
        const speechOutput = HELP_MESSAGE;
        const reprompt = HELP_REPROMPT;

        this.response.speak(speechOutput).listen(reprompt);
        this.emit(':responseReady');
    },
    'AMAZON.CancelIntent': function () {
        this.response.speak(STOP_MESSAGE);
        this.emit(':responseReady');
    },
    'AMAZON.StopIntent': function () {
        this.response.speak(STOP_MESSAGE);
        this.emit(':responseReady');

Any idea?

BTW, In general, how can I "maintain" the session open into the skill, avoiding to exit after the first intent?

Thanks
giorgio

alexa-cookbook.js

Hey franklin

Is this line required? it also will throw an error when copied to a lambda SAR

const cookbook = require('alexa-cookbook.js');

Gloucester facts doesn't exist

Mentions listening to this skill in action by adding skill "Gloucester Facts", which isn't on the marketplace when searched, also a dead link from the ReadMe.

Immediately ends session after telling fact

I used this code to make a fact skill but it immediately ends the session after giving the fact. Just saying "Alexa, open ___ facts" gives the fact and then is done. How can I get the session to stay open? I cannot figure it out. I have tried adding more intents. I've tried adding to the code. I'm definitely a newbie but I can usually figure things out but this is driving me nuts. I just want the skill to let me go through more than 1 fact. Ideally, the user could ask for facts over and over again and then just say stop or stop using it then it closes. Is this too advanced of a program for a beginner to try?

Lambda Code Inline does not display code.

Hello.

I am in tokyo so my region in Alexa dev is Tokyo

I have followed the instruction to create a space fact skill.
I arrive at the lambda configuration step, I create the function, set the trigger.
(My region in Lambda is ap-northeast-1)
When I try to open the function code in the inline editor, the editor does not display anything. The icon is moving and moving.

I can not check nor the default code neither the code I want to publish.

Regards

Emmanuel

Proposal: add external API usage with async/await to example

What I am missing so far from the basic skill examples in NodeJS is the use of an API.

alexa / skill-sample-nodejs-hello-world
alexa / skill-sample-nodejs-fact
alexa / skill-sample-nodejs-first-skill
alexa / skill-sample-nodejs-trivia
alexa / skill-sample-nodejs-quiz-game

How do you call an external service and process the response, especially with async/await.

Or did I just didn't see it when looking through the source?

I would like to modify the skill to have facts for an specific planet.

In order to acquire more "skills" on development of Alexa Skills I would like to modify this code and go in a different path. I would like to:
1.) call the skill "Alexa, open space curiosities.. "
2.) Alexa responds "For Which planet are you looking for facts ?"
3.) I will respond for example "Saturn"
4.) Then alexa goes to the fact "website database" and respond with a fact BUT just for the chosed planet.

Somebody has ideas on how to start ?
I guess first I need to work with the slots and then with the index.js file don´t ?

Sample is not ready for FR-fr

Looking at the folder skill-sample-nodejs-fact/models/, there is no sample interaction model for the French locale.
In particular, what sample utterances would you recommend using in French for "tell me a fact"?

Cannot find module './question'

I copied and pasted the code then tested, but it doesn't work.
{
"errorMessage": "Cannot find module './question'",
"errorType": "Error",
"stackTrace": [
"Function.Module._load (module.js:417:25)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"Object. (/var/task/index.js:16:19)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)"
]
}
when I call this function in ASK, it doesn't retrun anything.
Anyone here can help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.