0

Can we use Rest API instead of using Lambda. The reason im asking is because we got the request, we know what alexa accepts as a response, and we know that it is a POST. So connect all of these into REST API. The reason im asking is that the whole project is based in Jax-RS, so we want to have it all in one place, wihtout using lamda or anything. Not that lamda isn't that great.

So the request that alexa passes to Lambda is:

{
  "session": {
    "sessionId": "SessionId.a82f0b92-3650-4d45-8f12-e030ffc10894",
    "application": {
      "applicationId": "amzn1.echo-sdk-ams.app.8f35038e-13ac-4327-8e4f-e5df52dc1432"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.ask.account.AFP3ZWPOS2BGJR7OWJZ3DHPKMOMNWY4AY66FUR7ILBWANIHQN73QGGUEQZ7YXOLC7NYVD3JPUAHAGUS4ZFXJ6ZMS4EHO2CJFPWFLWLYZLDP7S227ADI54A2ZMLZLDO5CXSIB47ELNY54S2M7FDNJFHTSU67B7HB3UZUN6OUUR5BYS3UBRSIPBG4IWRLHUN36NXDYBWUM3NMQZRA"
    },
    "new": true
  },
  "request": {
    "type": "IntentRequest",
    "requestId": "EdwRequestId.bfdb3c27-028b-4224-977a-558129808e9a",
    "timestamp": "2016-07-11T17:52:55Z",
    "intent": {
      "name": "HelloWorldIntent",
      "slots": {}
    },
    "locale": "en-US"
  },
  "version": "1.0"
}

Response:

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "Hello World!"
    },
    "card": {
      "content": "Hello World!",
      "title": "Greeter",
      "type": "Simple"
    },
    "shouldEndSession": true
  },
  "sessionAttributes": {}
}
Suneet Patil
  • 608
  • 9
  • 21
rpajaziti
  • 171
  • 1
  • 5
  • 13
  • Please do not edit a solution into your question. Instead, post it as a separate answer below. Please see http://stackoverflow.com/help/self-answer – Matt Sep 11 '16 at 15:50

3 Answers3

5

Sure you can. In fact, when you are creating your skill in the Alexa Developer Portal, you have that option. The caveat is that you will need to manage your own TLS certificate and will have to make sure that the latency/responsiveness is decent based on the location of your users.

If you would like to explore this further, you can use Amazon's Java code examples. They can be found at: https://github.com/amzn/alexa-skills-kit-java.

Vladan
  • 371
  • 6
  • 13
  • One more good article to refer to: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/deploying-a-sample-skill-as-a-web-service – Vladan Oct 03 '16 at 01:03
0

You can definitely set up a RESTful service API for use with Alexa.

And, if you set it up in Azure, you don't even need to create your own certificate.

0

You can use a rest api as the endpoint for alexa skills. The apis will be invoked in the following manner

[Configured_URL]>/**alexa/[intent]**

Where [Configured_URL] - is the url endpoint configured in amazon site for invoking

[intent] - is the name of the intent

You should host your service accordingly

https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-web-service

https://iwritecrappycode.wordpress.com/2016/04/01/create-an-alexa-skill-in-node-js-and-hosting-it-on-heroku/

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
  • I'm unfamiliar with this "configured url" syntax - not all alexa requests come in to an endpoint this way. In fact, the endpoint that Alexa POSTs to is entirely configurable in the Amazon developer console for the skill. – Noah Gilmore Apr 24 '17 at 22:02
  • There is only one endpoint and you POST intents as part of the Request, so an Alexa REST url looks more like this: https://mydomain/api/alexa Amazon dev portal shows you what the structure of the Request needs to be. I wrote it in C# but it can be any language which outputs json. – smoore4 Jun 19 '17 at 16:34