简体   繁体   English

如何在自己的服务器上使用带有Node.js的alexa-sdk运行Alexa技能而不使用Lambda drop-in?

[英]How to run Alexa skill with the alexa-sdk on own server with Node.js without Lambda drop-in?

The Alexa skill docs will eventually allow you to send webhooks to https endpoints. Alexa技能文档最终将允许您将webhooks发送到https端点。 However the SDK only documents lambda style alexa-sdk usage. 然而,SDK仅记录lambda样式alexa-sdk用法。 How would one go about running Alexa applications on one's own server without anything abstracting Lambda? 如何在没有任何抽象Lambda的情况下在自己的服务器上运行Alexa应用程序? Is it possible to wrap the event and context objects? 是否可以包装eventcontext对象?

You can already use your own endpoint. 您已经可以使用自己的端点了。 When you create a new skill, in the configuration tab, just choose HTTPS and provide your https endpoint. 创建新技能时,在配置选项卡中,只需选择HTTPS并提供https端点。 ASK will call your endpoint where you can run anything you want (tip, check ngrok.com to tunnel to your own dev machine). ASK将调用您的端点,您可以在其中运行任何您想要的东西(提示,检查ngrok.com以隧道到您自己的开发机器)。 Regarding the event and context objects; 关于eventcontext对象; your endpoint will receive the event object information. 您的端点将收到event对象信息。 You don't need the context object for anything, that just lets you interact with Lambda-specific stuff ( http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html ). 您不需要任何context对象,只允许您与Lambda特定的东西进行交互( http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html )。 Just make sure that you comply with the (undocumented) timeouts by ASK and you are good to go. 只要确保你遵守ASK的(未记录的)超时,你就可以了。

Here's a way to do this that requires only a small change to your Skill code: 这是一种方法,只需要对您的技能代码进行少量更改:

  1. In your main index.js entry point, instead of: 在主index.js入口点,而不是:

     exports.handler = function (event, context) { 

    use something like: 使用类似的东西:

     exports.myAppName = function (funcEvent, res) { 
  2. Below that, add 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); } }; 
  3. Install and use Google Cloud Functions Local Emulator on your laptop. 在笔记本电脑上安装并使用Google Cloud Functions Local Emulator When you start and deploy your function to the emulator, you will get back a Resource URL something like http://localhost:8010/my-project-id/us-central1/myAppName . 当您启动函数并将其部署到模拟器时,您将获得类似http:// localhost:8010 / my-project-id / us-central1 / myAppName的资源URL。

  4. Create a tunnel with ngrok . ngrok创建一个隧道。 Then take the ngrok endpoint and put it in place of localhost:8010 in the Resource URL above. 然后取ngrok端点并将其放在上面资源URL中的localhost:8010的位置。 Your resulting fulfillment URL will be something like: https://b0xyz04e.ngrok.io/my-project-id/us-central1/myAppName 您生成的履行URL将类似于: https//b0xyz04e.ngrok.io/my-project-id/us-central1/myAppName

  5. Use the fulfillment URL (like above) under Configuration in the Alexa dev console, selecting https as the Service Endpoint Type. 使用Alexa dev控制台中Configuration下的履行URL(如上所述),选择https作为服务端点类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何使用alexa-sdk在我的alexa技能中使用http? - How would I go about using http in my alexa skill using alexa-sdk? 在使用alexa-sdk节点lib时,如何让Alexa Lambda FN不抛出类型错误? - How do I get Alexa Lambda FN not to throw Type Error when using alexa-sdk node lib? 在AnswerIntentHandler中运行exports.handle-node.js-Alexa技能 - Run exports.handle in AnswerIntentHandler - node.js - alexa skill 可以使用AWS Lambda,Node.js和Alexa技能套件阅读Facebook帖子的Alexa技能 - Alexa skill which can read Facebook posts using AWS Lambda, Node.js and the Alexa Skills Kit Alexa Node.js技能无法达到目的 - Alexa Node.js skill not getting into intent 如何创建从HTTP / HTTPS API获取数据的Alexa技能(在AWS Lambda上使用Node.js的“Alexa Skills Kit”) - How do I create an Alexa Skill that gets data from an HTTP/HTTPS API (using “Alexa Skills Kit” for Node.js on AWS Lambda) 使用node.js和AWS Lambda将Alexa技能连接到mysql数据库 - Connecting Alexa skill to mysql database using node.js and aws lambda Amazon Echo-Alexa-ContextClient是Node.js中Lambda的空开发技能 - Amazon Echo - Alexa - ContextClient is null developing skill with Lambda in node.js Alexa-SDK音频问题 - Alexa-SDK Audio Issue 使用Lambda函数从S3存储桶中检索数据以链接到node.js中的alexa技能 - Retrieve data from S3 bucket with Lambda function link to an alexa skill in node.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM