How to run Alexa skill with alexa-sdk on my own server with Node.js without adding Lambda?
You can already use your endpoint. When you create a new skill, in the config tab, simply select HTTPS and specify the https endpoint. The ASK will call your endpoint where you can run whatever you want (prompt, check ngrok.com for a tunnel to your own developer machine). As for the objects event
and context
; your endpoint will receive information about the object event
. You don't need an object context
for anything that just lets you interact with specific Lambda stuff ( http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html ). Just make sure you respect the (undocumented) ASK timeouts and you're good to go.
source to share
Here's a way to do it, which requires only a small change in your skill code:
-
In your main entry point index.js, instead of:
exports.handler = function (event, context) {
use something like:
exports.myAppName = function (funcEvent, res) {
-
Following is the following workaround:
var event = funcEvent.body // since not using Lambda, create dummy context with fail and succeed functions const context = { fail: () => { res.sendStatus(500); }, succeed: data => { res.send(data); } };
-
Install and use Google Local Cloud Features Emulator on your laptop. When you run and deploy your function to the emulator, you return the resource url, for example, http: // localhost: 8010 / my-project-id / us-central1 / myAppName .
-
Create a tunnel with ngrok . Then take the ngrok endpoint and place it instead of localhost: 8010 in the resource url above. Your final execution URL will look like this: https://b0xyz04e.ngrok.io/my-project-id/us-central1/myAppName
-
Use the Run URL (like above) in the Configuration section of the Alexa dev console, choosing https as the Service Endpoint Type.
source to share