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 );


     },

    };

How can we send data to Alexa? POST data Alexa to the app.

  • Actually, I want to send data to the lambda function along with the audio.

  • I want to send some JSON data from Alexa to my application.

  • I am developing the mobile app. with Alexa voice service.

Is there any way to send and receive data using Alexa?

1 Answers1

0

If I understand your question correctly, you could use AWS API Gateway and setup an endpoint that would let you POST data from a mobile app to the Lambda function you use for your Alexa skill.

Here is a link to the documentation for setting up API Gateway with Lambda.

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

However, if what you're trying to do is send something like an "alert" to an Alexa device when you post from the mobile app - that's not possible at this point.

Steve Tingiris
  • 331
  • 1
  • 5
  • let's say I want to send my key 'name'' = "Alexa" with the request, I want to read this in node js. –  Nov 28 '17 at 10:32
  • The Alexa service will send posts to the Lambda function in a [specific format](https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#request-format) that I would also use when you post to the API Gateway endpoint. That way, you could use the `attributes` node in the request to pass any key/value pairs you want. – Steve Tingiris Nov 28 '17 at 12:24