Search code examples
aws-lambdaalexa-skills-kit

How to get the account info of the user when the user uses an Alexa Skill


We are going to create an Alexa Skill that allows the user to control a Wi-Fi LED. Every time the user uses that Skill, we hope that we can get the user's account info in a callback of the SDK used in the AWS Lambda function for that skill.

Like for instance, the user logged in to his Amazon Account and used his Alexa-Enabled device and spoke "Alexa, ask to turn on". Then the skill we made will trigger the Lambda function and pass on the user's account details so that we could check it in our host whether that user own's that device.

So, is there any callback in the Java SDK used in the Alexa Skill Kit containing the account info of the user?

Thanks!


Solution

  • The SDK just provides you with a userId...

    {
      "session": {
        "user": {
          "userId": "amzn1.ask.account.AFPabcdef<etc>"
    

    This identifies a particular user, for one installation of your app. That is all you get automatically.

    You can use account linking to manually associate this user with other accounts:
    https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/linking-an-alexa-user-with-a-user-in-your-system

    You will need to store information about this user in some sort of database/datastore, but you don't need to load/save it with each request - you can store this user info (or any other session data) in your response and the SDK will pass it back to you in the next request within the same session.