我想从Alexa lambda节点JS发送接收和接收数据

时间:2017-11-17 11:39:25

标签: alexa alexa-skills-kit alexa-skill alexa-voice-service

Alexa should ask for use strict';

const Alexa      = require('alexa-sdk');
exports.handler  = (event, context) => {
  const alexa    = Alexa.handler(event, context);
  var APP_ID     = "amzn1.ask.skill.[XXXXX-45cc-9558-3c284b72148f]";
  alexa.APP_ID   = APP_ID;

  alexa.dynamoDBTableName = 'LongFormAudioSample'; // creates new table for session.attributes
  alexa.registerHandlers(handlers);
  alexa.execute();
};

const handlers = {
  'LaunchRequest': function() {
  },
  'NewSession': function() {
    this.attributes['eventType'] = "";
  },
  'SessionEndedRequest': function() {
    //this.attributesp["crash:emergency"] = null;
    this.emit(':tell', "Thank you");
  },

  'WishingWelcomeIntent': function( ) {
    // here I want to send  username
    var username = ''; // should get from request
    var json = {
      place : "USA";
    }

    // this.emit(":tell", "Hi", +username, "you'r welcome", json should 
      send along with the audio response from Alexa );


     },

    };

我们如何向Alexa发送数据? 将数据Alexa发布到应用程序。

  • 实际上,我想将数据与音频一起发送到lambda函数。

  • 我想从Alexa向我的应用程序发送一些JSON数据。

  • 我正在开发移动应用。与Alexa语音服务。

有没有办法使用Alexa发送和接收数据?

1 个答案:

答案 0 :(得分:0)

如果我正确理解您的问题,您可以使用AWS API Gateway并设置一个端点,该端点可让您将数据从移动应用发布到您用于Alexa技能的Lambda函数。

以下是使用Lambda设置API网关的文档的链接。

http://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-lambda.html

但是,如果您尝试做的是在从移动应用发布时向Alexa设备发送类似“提醒”的内容 - 此时无法做到这一点。

相关问题