question

Aliyah avatar image
Aliyah asked

Call One Skill From Another

Hi Guys, Need help with the following. Please provide suggestions/pointers. I have two movie character skills. One is a guess the movie game. The other is a conversational skill. Both written differently. One uses AlexaSkill module, the other does not. Each are now in separate Lambda functions. I'd now like to be able to do one of the following, but having trouble finding out if this can be done in ASK, by default. 1) Call one skill from another, thru Intent. Meaning, be able to execute the Launch request of the 2nd skill from the first skill's custom intent. 2) Create a 3rd skill (middle man) that will launch either skill thru Intent. (overhead).(i.e. For Sales, say Sales. For Support, say Support) 3) Put each skill in the same solution (using VS), in separate nodes and somehow do what alexa-app (Mike Kruse) does to access the defined apps. Meaning, do this using standard ASK without having to re-write each skill to support alexa-app. I haven't found an example for alexa-app or base ASK, like what I'm looking for. Thanks, Aliya H
alexa skills kitsubmission testing certification
10 |5000

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

jjaquinta avatar image
jjaquinta answered
You can take any of those approaches. It's just coding. Nothing special about Alexa. 1) Any Lambda function can call another Lambda function. You can do that, and pass back the result. What you have to worry about is latency. There is overhead in calling a Lambda function, and Alexa will only wait so long before it gives up. As long as your skill is fast, you are fine. If you want to just pass-through, both skills will need the same (or compatible) interaction models. If not, you are going to have to compose your own submission request JSON. But the specs are there. I did it for EchoSim. It's not that hard. 2) This is just (1), but done with a precursor skill. Same things to watch out for. 3) This like writing one big skill with a split interaction model. A curious idea. I'll be bringing out companion skills to StarLanes, and have been looking at lots of duplicate code. It would be kind of interesting to do it this way instead. So it's really just a matter of writing code. If you aren't an advanced code writer then, yes, it will be confusing. You should probably aim for something less ambitious until you build up your coding skills. But if you are, than any of those approaches should work.
10 |5000

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

Aliyah avatar image
Aliyah answered
Thanks, jjaquinta. Since it can be accomplished , I'd like to do 3 or 1. I know it would consist of writing code. But How? C# is my coding language. I saw a C# template on github, but decided to stick with what was completely supported by ASK. So java(script) it is. Either way, ASK is not well/fully documented and I've found a bunch of ah ha's, after reading other sites. Especially on the dev console's bugs. Anyhow, if a js example could be provided by you or anyone, that is all I need to finish my work. The code for the skills is done. I just have not figured out how to bind them. How to call one Amazon Lamba function from another? Searched here and google and found nothing on this before posting. If #3 is a matter of just writing code, I've seen no examples of this being done without Mike's node modules. So is the only way to do it, to re-invent Mike's wheel? Is this supported using just the AlexaSkill module? Are there any examples out there, for any of the options? I thought that one of these designs would be in use by now, by those that have multiple skills.
10 |5000

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

jjaquinta avatar image
jjaquinta answered
If you need help writing node.js code, there should be plenty of resources on the internet. I learned it about six months ago and I think I mostly picked it up from w3schools. The biggest difference between node.js and your standard procedural language is does everything through callbacks rather than return values. Very useful for non-blocking server code, but a royal pain for anything else. When you block your code out, mentally, it's just everywhere you would normally make a call to another procedure, and then execute more code afterwards, you need to instead make the call, and pass the rest of your code in as a callback parameter. Also how you call between different files is not straightforward. I never mastered that. The app we were using it for is split across multiple docker containers. That's nice because you can use different technologies in each container. And we only used node.js for the non-blocking servlet front end rather than the heavy business logic. Matt's code is a good place to start. It handles the "I've got input, and I'm going to do different things based on that input." Just instead of proxying to another web address, you are calling another procedure. And it's not very long. So even if you re-invent it in the course of learning node.js, it's not that bad. There are at least three javascript framework floating around the forum. Hobbyist developers have a huge propensity towards reinventing the wheel. Your other alternative is to skip Javascript altogether and just write it in Java. That's going to be a lot more like C#. If you are going to do anything serious or lengthy, it's a better choice anyway. Like I said, node.js is great for simple non-blocking REST APIs, but its advantage start to become disadvantages as you add in more business logic. The compile-time verification you get with Java really helps in writing easier to maintain code once you get beyond a thousand lines or so. StarLanes is approaching 100Kloc. A lot of that is inherited from previous projects, but even so, I wouldn't dream of maintaining that much code in node.js!
10 |5000

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

Aliyah avatar image
Aliyah answered
Thanks jjaquinta. Thanks for the learning to code tips, but this is not why I posted the question and why I've rarely posted for help in the past 15 years. The help I needed, just found on stackoverflow, rather than where I should have gotten it. Here. http://stackoverflow.com/questions/31714788/can-an-aws-lambda-function-call-another
10 |5000

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

jjaquinta avatar image
jjaquinta answered
Not to be pedantic, but this is the Alexa Skills Kit forum, not the Amazon Web Services forum. Lambda is a feature of the Amazon Web Services, and is no more related to the Alexa Skill Kit than, say, Elastic Beanstalk. If you have questions about Lambda beyond what the Stackoverflow link answers, you should probably look into the AWS forum, not here. https://forums.aws.amazon.com/index.jspa Good luck!
10 |5000

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

Aliyah avatar image
Aliyah answered
jjaquinta, Thank you for the non-pedantic code writing, posting and definition of Lambda tips that have answered my questions.
10 |5000

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