Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ask-sdk-core/util) Add new helper function to get user id #546

merged 1 commit into from May 6, 2019


None yet
4 participants
Copy link

commented May 2, 2019

We can get user id from the SDK.


Add the getUserId function into the utils.
We can get the user id more easier.

Motivation and Context

Now we can get the requested user's device id by the SDK.
But we want to get the user id too.


const userId = handlerInput.requestEnvelope.context.System.user.userId 

Our code will be too long line :(


const userId = getUserId(handlerInput.requestEnvelope)

It is the simplest way to get the user ID :)


To run unit test by gulp.

$ lerna bootstrap
$ lerna --scope ask-sdk-core run gulp -- test
  110 passing (76ms)

=============================== Coverage summary ===============================
Statements   : 100% ( 351/351 )
Branches     : 100% ( 88/88 )
Functions    : 96.26% ( 103/107 )
Lines        : 100% ( 330/330 )

[09:57:52] Finished 'test' after 1.76 s
lerna success run Ran npm script 'gulp' in 1 package in 2.9s:
lerna success - ask-sdk-core

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Docs(Add new document content)
  • Translate Docs(Translate document content)


  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • My commit message follows Conventional Commit Guideline


  • I confirm that this pull request can be released under the Apache 2 license

This comment has been minimized.

Copy link

commented May 2, 2019


@@ -43,7 +44,7 @@ describe('RequestEnvelopeUtils', () => {
templateVersion : '1.0',
markupVersion : '1.0',
};requestEnvelope.context.System.user.userId = 'mockUserId'

This comment has been minimized.

Copy link

ShenChen-Amazon May 2, 2019


Could you please write this one in a new line?

This comment has been minimized.

Copy link

hideokamoto May 2, 2019

Author Contributor

Thanks for the feedback!
I've fixed it :)


This comment has been minimized.

Copy link

commented May 3, 2019

Hi @hideokamoto

The code looks good. Before I merge it in, could you please modify the commit name to "feat: add getUserId util function", In order to fit conventional commits structure.


feat: add getUserId util function
feat(docs) add getUserId into the docs

fix(ask-sdk-core) lint error of getUserId

fix[ask-sdk-core] make a new line to define the user id

@hideokamoto hideokamoto force-pushed the hideokamoto:feature/utils/getUserId branch from 7260ebb to 1d85349 May 5, 2019


This comment has been minimized.

Copy link
Contributor Author

commented May 5, 2019

I've rebased my commits.

@nikhilym nikhilym requested a review from alexa/ask-sdk May 6, 2019

Copy link

left a comment


@ShenChen-Amazon ShenChen-Amazon merged commit 4941344 into alexa:2.0.x May 6, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.

Copy link

commented May 6, 2019

Hi, @hideokamoto

Thanks for the PR! Merging this in. It will be included in the next SDK release.


@hideokamoto hideokamoto referenced this pull request Jun 11, 2019


fix: export getUserId() at index.ts #561

1 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.