Search code examples
alexa-skills-kitalexa-slot

Alexa skill Rest API


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": {}
}

Solution

  • 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.