How to run Alexa skill with alexa-sdk on my own server with Node.js without adding Lambda?

Alexa skill docs will ultimately allow you to submit websites to endpoints https

. However, the SDK only uses lambda style alexa-sdk

. How can you run Alexa apps on the same server without any Lambda abstraction? Is it possible to wrap objects event

and context

?

+3


source to share


2 answers


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.



+1


source


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.

0


source







All Articles