Category Archives: RAW JS

Alexa App Development – Important Notes

Alexa Develpoment

  • Alexa Skills Kit
  • JavaScript ES6 (EcmaScript 2015) || write code in ES5
    • babel transpiler needed
      • If you use babel. I would suggest you have it compile on save.
  • Break your API calls down into modules
  • Keep your entry page clean and easy to read.

Files

speechAssets/

  • IntentSchema.json
    • JSON file that should contain your Alexa Skill Intents

root “intents

{ "intents" : [] }
Intents is an array that will hold all of your intent objects

Intent Objects

{ "intent": "myIntent", "slots" : [ ] }
The intent object contains the name of your intent under the key intent and any slots you may need.

Slots

"slots": [{ "name": "MySlot", "type": "MY_SLOT_TYPE" }]
Custom slot types are like your parameters. Some one says an Utterance of … “Tell me about my boots” … boots would be the slot type. The Utterance will resemble.
me about my {item}
Where item will be brought into your Alexa Skill Entry Point as an argument with a value of “boots”.

  • SampleUtterances.txt

Use of !! in JavaScript

BANG BANG

Want to find out if something is false if it is a string, number, obj etc….


var x = “No”
typeof x
// string

var xBools = !!x;
//true – because variable x has a string of No, could be a string of false as well. A string is an object and that object has alpha characters
typeof xBools
// boolean

var emptyString = “”;
typeof emptyString 
// string

var emptyStringBools = !!emptyString;
//false – because the string is empty
typeof emptyStringBools 
// Boolean

var nulls = null;
typeof nulls
// object

var nullsBools = !!nulls;
//false
typeof nullsBools
// boolean

var under;
typeof under
// undefined

var underBools = !!under;
//false
typeof underBools
// boolean

Check to see if a variable has a value and if that value is usable.

ADVANCED : JAVASCRIPT FUNCTIONS!

What are functions in JavaScript?

Functions are like any other item in JavaScript, functions are “OBJECTS”. Think about all the advanced things you can do with objects. Now apply that to functions. I have run across scripts written by all levels of UI developers and I rarely see anyone use a function to its full potential. Below I list some of the familiar and not so familiar features of a JavaScript function.

Continue reading

JavaScript : Helper Function of the Month! Remove Duplicates from Array

May have run into a problem where you need to remove duplicates from an array. It is usually a good idea not to mess with the base JavaScript objects but I like to add functionality that I believe should already be part of the the base JavaScript object. Today I am going to talk about JavaScript Arrays! How handy would it be to call myArray.removeDuplicates(). Some of you may think this method name is to long but I like to name methods with the functionality they perform. So lets get started with the code.
Continue reading

Adv. JavaScript : Class Creation with Object.create

I will discuss how to create JavaScript objects that look and feel like classes. We can use the new operator but there is a better way. There is not a single right way of performing any task when it comes to development. JavaScript is a pretty loose and dynamic language so there are many ways to complete you task at hand.
Continue reading

In depth JavaScript : Apply / Call

Why use Apply or Call?

Call takes the value to be used as the “this” object as the first object in the parameter list. The rest of the parameters will come after the first object and separated by commas.

callFunction.call(thisObjectPassedIn, param1, param2)

Apply is just like call but the second parameter is an array of parameters.

applyFunction.apply(thisObjectPassedIn, [param1, param2])

In depth JavaScript : Callbacks

JavaScript – Object based language

Functions are OBJECTS

var myFunction = function(){
  alert('test');
}

function doFunction(myFunction){
  //do something
  myFunction();
}

Things to understand about functions

  • functions can be stored as a variable
  • functions take parameters that can be variables
  • can be created by functions
  • can be returned from functions

Continue reading