2017-11-17 12 views
0
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에 데이터를 보낼 수 있습니까? POST 데이터 앱에 알렉사.Alexa 람다 노드 JS에서 수신 및 수신 데이터를 보내려합니다.

  • 사실 나는 오디오와 함께 람다 함수에 데이터를 보내려고합니다.

  • 알렉사에서 일부 응용 프로그램으로 JSON 데이터를 보내고 싶습니다.

  • 모바일 앱을 개발 중입니다. 알렉사 음성 서비스.

Alexa를 사용하여 데이터를 보내고받을 수있는 방법이 있습니까?

답변

0

질문을 올바르게 이해하면 AWS API 게이트웨이를 사용하여 모바일 앱의 데이터를 Alexa 기술에 사용되는 람다 함수로 POST 할 수있는 엔드 포인트를 설정할 수 있습니다.

다음은 Lambda와 함께 API 게이트웨이를 설정하는 데 필요한 문서에 대한 링크입니다. 무엇을 당신이하려는 것은 모바일 앱에서 게시 할 때 알렉사 장치에 "경고"와 같은 무언가를 보낼 경우

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

하지만 - 그것은이 시점에서 수 없습니다.

+0

'name'= "Alexa"키를 요청과 함께 보내려는 경우 js 노드에서이 키를 읽으 려합니다. – Dev

+0

Alexa 서비스는 [특정 형식] (https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#request-format)으로 람다 함수에 게시물을 보냅니다. API 게이트웨이 엔드 포인트에 게시 할 때도 사용할 것입니다. 그런 식으로 요청에서'attributes' 노드를 사용하여 원하는 키/값 쌍을 전달할 수 있습니다. –