question

MikeV avatar image
MikeV asked

Alexa Skill Kit - Fact Skill - NextFactIntent and RepeatFactIntent

I have added NextFactIntent and RepeatFactIntent to skills and cannot figure out how to invoke them through Alexa.

I have used the Interaction Model - "Launch Skill Builder (Beta)" to define them.

Is there any reference guide / tutorial / tips book that describes, in detail,

1) how to set these up in the Interaction Model

2) what else is needed, likely in the Lambda Console, in the Function, so that the function invokes NextFactIntent and RepeatFactIntent correctly

3) any other setup - anything we need to do outside the Interaction Model or Function definition

?

Thanks,

Mike

alexa skills kitlambdaresponsesdkinteraction model
1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jenn@amazon avatar image
Jenn@amazon answered

Did you get the basic Fact Skill Sample working?

If so, what you'll need to do is alter the sample Lambda code to handle the New Intents you're adding.

Post the code you're currently using and we can guide you through what needs to be added.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

MikeV avatar image
MikeV answered

Jenn, Thanks! I've suspected back in July that may be the case - supplement Interaction Model with Lambda code... buuuut how?

These are my three related posts from this summer.

Am I on the right track, at last with the first two?

If the editor would not delete the extra blank spaces I intentionally put between sections, these may be easier to read; I hope you can follow them easily enough.

Do NextIntent and RepeatIntent need Lambda Function Updates?

https://forums.developer.amazon.com/questions/74015/do-nextintent-and-repeatintent-need-lambda-functio.html

&

How to make Next Fact, and how does it work?

https://forums.developer.amazon.com/questions/71571/how-to-make-next-fact-and-how-does-it-work.html

&

Interaction Model BETA Builder dropped Next and Repeat Intents. Any ideas why?

https://forums.developer.amazon.com/questions/73791/interaction-model-beta-builder-dropped-next-and-re.html

Thanks,

Mike

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

MikeV avatar image
MikeV answered

P.S. Yes, our family has created seven fact skills; all working the same, and for all I hope to add Repeat and Next. Please see - https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dalexa-skills&field-keywords=Twice+Energy&rh=n%3A13727921011%2Ck%3ATwice+Energy

Thanks, Mike

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

MikeV avatar image
MikeV answered

OK...

I'll re-share in this post code from the other post... I'll use many dashes to separate the questions, to ease reading. Ultimately I seek a example (or two) of a Lambda function that uses NextIntent and RepeatIntent at the same time, to show that... when the Fact Skill gets to the point where Alexa states your random fact, she asks "would you like me to repeat that, or would you like another fact?".

Thanks, Mike

------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------

This is pasted from our "Space Flight Fun Facts" skill

https://www.amazon.com/Michael-Van-Vooren-Space-Flight/dp/B06XYM6RX9/ref=sr_1_3?s=digital-skills&ie=UTF8&qid=1491394931&sr=1-3&keywords=vooren

This Lambda function is "SpaceFlightFacts."

------------------------------------------------------------------------------------------------

This is the part of our Lambda function "SpaceFlightFacts" that gets a random number and uses that to get a fact from the Fact array: Pasting here straight from my Lambda function:

}, 'GetFact': function () {

// Get a random space flight fact from the space facts list

var factIndex = Math.floor(Math.random() * FACTS.length);

var randomFact = FACTS[factIndex];

// Create speech output

var speechOutput = "Here's your fun fact about space flight: " + randomFact;

this.emit(':tellWithCard', speechOutput, SKILL_NAME, randomFact)

},

------------------------------------------------------------------------------------------------

At this point Alexa just spoke the fun fact in the fact array.

------------------------------------------------------------------------------------------------

Question: Shouldn't this be where the Lambda is updated with the NextFact and RepeatFact intents?

If so, how? Can you share an example of that code for Next and for Repeat? Would the Lambda function look something like this?

-----------

Mike's understanding of how the Lambda function is organized to invoke Repeat or Next, which may not be correct.

// Create speech output

var speechOutput = "Here's your fun fact about space flight: " + randomFact <SOMETHING_1> WHAT TO DO RIGHT HERE TO MAKE ALEXA ASK "want another" or "repeat";

this.emit(':tellWithCard', speechOutput, SKILL_NAME, randomFact)

And then should there be <SOMETHING_2>...

{

in another curley bracket section with

AMAZON.NextIntent

}

And should there also be <SOMETHING_3>...

{

in another curley bracket section with

AMAZON.RepeattIntent

}

------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------

Now let's go to REPEAT

------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------

REPEAT

RepeatIntent...

For RepeatIntent to work, how does Alexa know how to restate what she just said, how to say the same speechOutput again?

a) does Alexa already know the fact she just read - does Alexa have that specific fact in some memory buffer? If so, how to access that memory buffer and get her to restate that fact?

------------

Example for a):

Math.random just picked fact 7, which is:

"The United States’ first man-made satellite was Explorer 1. It launched on January 31, 1958, and was almost seven feet long. ... remained in orbit until it re-entered Earths’ atmosphere on March 31, 1970.",

So I could reword my question a) as...

Does Alexa have this specific sentence somewhere in memory and at this point in the Lambda function, so Alexa can just state it again ("The United States' first ... 1970") again?

------------

OR... if not a)...

------------

b) does Alexa not have the specific fact in memory, but she does have the random number still in memory, so you just invoke logic for GetFact using the same number, the last random number Alexa generated? If so, how to do that, as the current logic uses Math.random to get the fact... how to retrieve from the Fact array a specific fact?

------------

Example for b):

Math.random just picked fact 7, which is:

"The United States’ first man-made satellite was Explorer 1. It launched on January 31, 1958, and was almost seven feet long. ... remained in orbit until it re-entered Earths’ atmosphere on March 31, 1970.",

and Alexa does not have this sentence anywhere in memory BUT Alex does have the random # 7 still in memory, so you could pass to GetFact the number 7 and Alexa can retrieve that same 7th fact "The United States' first ... 1970" sentence and restate it.

If so, how to pass that value to GetFact... what is the specific code needed to make that work?

------------

------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------

Now let's go to NEXT

------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------

NEXT

NextIntent...

For NextIntent to work, how does Alexa determine what next fact to read:

a) does the Lambda function need to just re-invoke the same GetFact using the same Math.random number?

OR

b) is there some NextFact to invoke instead

?

------------

Example for a):

The default logic for GetFact, from the Fact Skill Template, is:

}, 'GetFact': function () {

// Get a random space flight fact from the space facts list

var factIndex = Math.floor(Math.random() * FACTS.length);

var randomFact = FACTS[factIndex];

// Create speech output

var speechOutput = "Here's your fun fact about space flight: " + randomFact;

this.emit(':tellWithCard', speechOutput, SKILL_NAME, randomFact)

},

-->> At this point,

If we just re-invoke the same GetFact using the sameMath.random number,

how to you re-invoke / re-call the GetFact?

What statement returns you to }, 'GetFact": ... ?

Does the Lambda Function need to "call GetFact" or "GOTO GetFact"?

------------

OR... if not a)...

------------

if there is b) there some NextFact to invoke instead

------------

------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------

Thanks!

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jamie Grossman avatar image Jamie Grossman ♦♦ commented ·

Hopefully I was able to answer your question in your other thread here.

0 Likes 0 ·