This is a lambda function that drives the Alexa skill for Scout.
Uses Alexa Skills Kit SDK for Node.js v2. Backwards compatibility with v1: see ASK SDK Migration Guide.
Requirements: scout-ua, Auth Lamdba Functions and Auth API Gateways are deployed.
Create an AWS Lambda Function on AWS Lambda.
Add the following environment variables to your Lambda function:
APP_ID
: Alexa Skill ID. You can find it in the Alexa Skills Kit ConsoleJWOT_TOKEN
: JWOT token to access API (scout-ua). Generate using the api/auth/register endpoint from scout-ua (POST request with name
, email
, password
fields).SCOUT_ADDR
: API hostname for scout-ua (yourserver.com
for instance)LOG_LEVEL
: Optional. Winston logging level.SUMMARY
: Optional. If this is there and set to 'false', the user will not get an option to hear the summary. The only option will be the full article.POCKET_KEY
: Optional. If you want to send metrics to the Pocket server, this can be your pocket consumer key.In order to run this on Amazon, some of the node packages need to be cross-compiled on Amazon Linux to work properly. Here is a set of steps to do this:
Create an Alexa Skill on Alexa Skills Kit.
You can put Scout
as an invocation name.
skill.json
file.skill_id
in .ask/config
with your Skill Id from Alexa Skills Kit.uri
in .ask/config
with your ARN from your AWS Lambda function.Deploy using ask deploy
(require AWS command line tools). You may require to create an AWS IAM user with correct permissions to deploy with command line.
Go to alexa.amazon.com. In Skills/Your Skills/Dev Skill you should see your Skill in development. Enable-it. You should get redirected to Pocket to authorize the app. Authorize-it.
Testing using Bespoken virtual-alexa.
To run tests, you need the following configuration:
SCOUT_ADDR=<domain for scout-ua server (not a full URL), e.g. "scout-ua.herokuapp.com"
JWOT_TOKEN=<valid scout-ua JWT token>
SUMMARY=true
STRING_BRAND=./scout_strings.json
TEST_ACCT1=<user1>@email.com
TEST_ACCT2=<user2>@email.com
TEST_ACCT_INVALID=<non-existent-user>@email.com
<user1>@email.com
<user2>@email.com
<non-existent-user>@email.com
Sample URLs that will make the tests pass: http://www.businessinsider.com/details-emerge-of-intel-ceo-brian-krzanich-office-affair-resignation-2018-6 https://www.bloomberg.com/news/articles/2018-09-18/amazon-dominates-early-emmy-awards-in-sign-tv-bet-is-paying-off https://www.theverge.com/transportation/2018/9/13/17856078/elon-musk-boring-company-underground-garage-hyperloop https://www.cnn.com/2018/09/19/politics/donald-trump-ethics-analysis/index.html https://techcrunch.com/2018/09/18/mozillas-firefox-reality-web-browser-is-now-available/ http://www.spiegel.de/politik/ausland/usa-paul-manafort-kooperiert-mit-sonderermittler-robert-mueller-a-1228236.html https://www.nytimes.com/2018/04/20/well/family/nobody-tells-you-how-long-a-marriage-is.html https://www.newyorker.com/books/page-turner/my-last-day-as-a-surgeon
Do not add more than the 8 URLs.
To run tests manually: npm test
from inside the lambda/custom directory. The node_modules must be generated locally on the machine your running the tests from. Using the node_modules generated on the EC2 instance will not work. It's best to backup any EC2 node_modules directory you have, run npm install
and then run npm test
.
Note that tests may fail if run from a forked repo due to lack of security keys. Before landing a patch, please make sure that the integrations tests pass when you run them locally.