Alexa Skills: project structure

I couldn’t find anything mandating project structure. So I have taken the “speechAssets, src” pattern that you see (mostly) on the Amazon Alexa github repo, and adapted for my own wants:

For example…

 

Advertisements

Node.js: The [assert] package

I was tempted to write something about Assert with examples… but no point, as this person/persons has/have done a way better job than I would/could (Ed: enough).

And, in fact, this is part of a very generous GitBook:

[Later…] in fact I gave the book credit for giving more comprehensive coverage of Node.js that I assumed on first glance. This is the sum total of the book’s coverage:
NodeJs05

Regardless, thanks to Nelson/Nelsonic for at least giving us this.

 

AWS Lambda/Node: starting unit testing

After some evenings of googling [AWS Lambda/Node/unit test framework] and playing with the results, I think I am pretty much up and running thanks to this person or persons…

and their excellent lambda-tester framework here and here.

For me, they have really abstracted things away well, and left very few moving parts behind to trip you up. ¬†Thanks! ūüôā

Important points:

  • Node in AWS Lambda works on a latest version of 6.10.* (I’m using 6.10.3, on Windows, FWIW). There are 2 other (earlier) supported versions – I’d stick with 6.10.
  • Sucking eggs: unless you are already clued up on AWS Lambda and Node (I’m using it for Alexa Skills, and I am a noob at this), do the Simplest Thing Possible to start with. On the Amazon side, I suggest that means the HelloWorld blueprint below. Then play with the first callback argument being null (success), and not null (failure), and see it come through when you run mocha. Point being ref Mocha: I think the lambda-tester help is pretty comprehensive for getting just enough knowledge on these supporting packages. Ping me if you want some help on this. I’m not many steps ahead of you, believe me :-). Of course, Hello World gives you nothing useful of itself. But this exercise is all about seeing the round trip working from a test to a function under test, both for a success, and for a failure.

Node: basic testing

Gist.

AWS Lambda testing: dump of notes so far

Lessons: node 6.10.3. Don’t try the current version – it won’t work.
In my js/noob world, Lambda-tester is looking the simplest way so far to test AWS Lambdas. I’m not quite there yet, but will return to this very soon.

https://www.npmjs.com/package/lambda-tester

  Id CommandLine
 -- -----------
 1 node -v
 2 npm -v
 3 function prompt(){}
 6 pwd
 7 cd C:\Github\Alexa\MagContact\src\PackageSet\test
 8 pwd
 9 ls
 10 mocha
 11 cd ..
 12 pwd
 13 mocha
 15 npm install lambda-tester --save-dev
 16 npm install nonsense --save-dev
 17 npm install nonsensex --save-dev
 18 npm install lambda-tester --save-dev
 19 ls
 20 mocha
 21 npm install mocha -g
 23 mocha
 24 Get-History

6.10.3

http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html

https://nodejs.org/en/blog/release/v6.10.3/

Windows 32-bit Installer: https://nodejs.org/dist/v6.10.3/node-v6.10.3-x86.msi
Windows 64-bit Installer: https://nodejs.org/dist/v6.10.3/node-v6.10.3-x64.msi
Windows 32-bit Binary: https://nodejs.org/dist/v6.10.3/win-x86/node.exe
Windows 64-bit Binary: https://nodejs.org/dist/v6.10.3/win-x64/node.exe

https://nodejs.org/dist/v6.10.3/node-v6.10.3-x64.msi

https://github.com/mapbox/lambda-cfn/issues/54

 

 

Node: Install

You might also want to see the earlier post here.

I went to a new Windows Server, and dumbly starting typing in Node, and npm, and nothing…

NodeInstall00

Go here.

NodeInstall02.PNG

Grab whichever version suits you…

NodeInstall03.PNG

NodeInstall04.PNG

NodeInstall05.PNG

NodeInstall06.PNG

NodeInstall07.PNG

Better…

NodeInstall08.PNG

And now for the web server. Again credit to this person here

npm install express

NodeInstall09.PNG

HTML5: Referencing one HTML page from another HTML page

I was trying to reference a HTML file B from an HTML file A, without using a server (“server” in this context as in Node or IIS), because I wanted something very lightweight. However, while HTML5 introduces the ability to do such referencing, when trying to do it via a File protocol, it constantly fails with errors stemming from (quite reasonably, I think) restrictions imposed by¬†Cross-Origin Resource Sharing:

In the end, I gave up, and used Node and Express as a light-weight server. Diagram with the key points here Рyou can download it as SVG for the detail.

Credit due for the Node/Express example here, and for the pointers on HTML5 HTML links here.