amazon-web-servicesalexa-skills-kituserid

Amazon Alexa Skills Kit: How do you link with external app account / userId


In an Amazon alexa skill request, there is a userId. I'm trying to understand what this is and if there is some reference for it because I want to link and Amazon Echo user account with an account in my own app and to do this I would have to have some kind of static userId to work with.

Example request:

{
 "version": "1.0",
 "session": {
   "new": false,
   "application": {
   "applicationId": "amzn1.echo-sdk-ams.app.[unique-value-here]"
  },
  "sessionId": "session1234",
  "attributes": {},
  "user": {
    "userId": null //IS THERE A DETAILED REFERENCE OF THIS SOMEWHERE?
  }
},
"request": {
"type": "IntentRequest",
"requestId": "request5678",
"intent": {
  "name": "MyColorIsIntent",
  "slots": {
    "Color": {
      "name": "Color",
      "value": "blue"
    }
  }
}
}
}

Solution

  • I don't know why the original answer has been deleted but Amazon now lets you link an Alexa User with a user in your system. Here's the announcement.

    How End Users Set Up Account Linking for a Skill

    Users link their accounts using the Amazon Alexa app. Note that users must use the app. There is no support for establishing the link solely by voice.

    Users normally start the process when initially enabling your skill in the app:

    1. In the Alexa app, the user enables the skill.
    2. The app displays your login page right within the app, using the authorization URL you provide when registering your skill on the developer portal. When the companion app calls this URL, it includes state, client_id, and scope as query string parameters.

      • The state is used by the Alexa service during the account linking process. Your page needs to keep track of this value, as you must
        pass it back later.
      • The client_id is defined by you. Your login page can use this to determine that the request came from your Alexa skill.
      • The scope is an optional list of access scopes indicating the level of access requested. You define the set of scopes to support when enabling account linking for your skill.
    3. The user logs in using their normal credentials for your site.

    4. Your service authenticates the user and then generates an access token that uniquely identifies the user in your system.

    5. Your service redirects the user to an Amazon-specific URL and passes along the state, access_token, and token_type in the URL fragment.

    6. The Alexa service validates the returned information and then saves the access_token for the Alexa user.

    At this point, the skill is enabled, the user’s Alexa account is linked to the account in your service, and the skill is ready to be used.