Javascript jasmine node.js and Alexa

Posted in :

Reading Time: 2 minutes

(Update 11-23-2023) It’s funny, I found out when I changed the mac input mode from English to Chinese (Pin’yin), and it messed up all the special symbols in the javscript code, double quotes, semi colon, bracket etc. It’s probably due to the difference between Ascii and Unicode.

(Update 10-14-2023) I messed up the folder name AWS lambda – the fix is to correct the folder name. I typed something like “oralce” instead of “oracle” for the folder name. Took me a while to find out. The error message says it could not find the index.mjs file which is usually the entry point for node.js app (including lambda function on AWS).

  "errorType": "Runtime.ImportModuleError",
  "errorMessage": "Error: Cannot find module 'index'\nRequire stack:\n- /var/runtime/index.mjs",
  "stack": [
    "Runtime.ImportModuleError: Error: Cannot find module 'index'",
    "Require stack:",
    "- /var/runtime/index.mjs",
    "    at _loadUserApp (file:///var/runtime/index.mjs:997:17)",
    "    at async Object.load (file:///var/runtime/index.mjs:1032:21)",
    "    at async start (file:///var/runtime/index.mjs:1195:23)",
    "    at async file:///var/runtime/index.mjs:1201:1"

I encountered some other error too, and some of which includes traceback to my own code, which gives hints on what went wrong. Another tricky one is whether to include { in the import statement (When should I use curly braces for ES6 import?).

Another error from Oracle DB is it didn’t like the SQL with single quote, and at the same time the sql itself has a condition of =’1’. Put the slash before the single quote to escape the single quote before 1, in cloud 9, and cloud 9 automatically add double quote around the sql, and it seems solve the issue.

  "errorType": "Runtime.UserCodeSyntaxError",
  "errorMessage": "SyntaxError: Unexpected number",
  "stack": [
    "Runtime.UserCodeSyntaxError: SyntaxError: Unexpected number",
    "    at _loadUserApp (file:///var/runtime/index.mjs:1058:17)",
    "    at async Object.load (file:///var/runtime/index.mjs:1093:21)",
    "    at async start (file:///var/runtime/index.mjs:1256:23)",
    "    at async file:///var/runtime/index.mjs:1262:1"

(Update 12-22-2022)

The Modern JavaScript Tutorial


(Original 02-27-2019 below)


Alexa Account Linking: 5 Steps to Seamlessly Link Your Alexa Skill to User Systems That Require Authentication (Sebastien Stormacq, done)

User Account Linking in Alexa with ASP.NET Web API (Heather Downing, Okta)

Linking Your Alexa Skill Securely with Okta (Jefferson Haw, Okta)

Account Linking : Amazon Alexa and ForgeRock OpenAM using OAuth2 Authorization grant (karthik, Medium)

How to set up Account Linking for Alexa with Auth0 and Jovo (Kaan Kilic, Jovo)

Build an Alexa Skill in Node.js with Jovo (Jan Konig, Jovo, done) : If a user responds with a name, the MyNameIsIntent is triggered. The code is shown below in index.js

Webhook.listen(port, () => {`Local server listening on port ${port}.`);
});‘/webhook’, async (req, res) => {
await app.handle(new ExpressJS(req, res));

also, how to test the code in AWS Lamda…Click “Test” right next to the “Save” button and select “Alexa Start Session” as the event template…

Interaction-Based Authentication for Alexa Skills with Auth0 (Joao Angelo, Auth0)

Developing Alexa Skills Locally with Node.js: Account Linking Using OAuth (Juan Pablo Claude)

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.

Node.js based testing (npm test)

jasmine official website

commonly used commands:
npm install –save-dev jasmine
npm init
npm test

Sample project can be seen here: (please contact me if the repository is private)

Also from Okta dev blogs:
Learn JavaScript in 2019 (David Neal)

Add Authentication to Your Vanilla JavaScript App in 20 Minutes (work in progress):

With ES6, async/await brings you added control over asynchronous programming by leveraging promises but in a synchronous way. You can use async/await to make your code cleaner while maintaining non-blocking operations. github

Note this post has some examples that uses angular as well.

%d bloggers like this: