Posted in Groovy, Java EE, JSON

Groovy String comparison in WorkFusion

For instance I have this variable of json expression:

<var-def name=”successFlag”>
<json expression   =”$….Response…..SuccessFlag”>
<var name=”HTTP_RESPONSE” />
</json>
</var-def>

to compare it with for an if else condition case, I need to create a boolean variable then put it in the condition; this was really tricky to use, I tried equals, == and some converting ones but this one works like a piece of cake:

then:

<case>
<if condition=”${eduSuccess.equals(‘true’)}”>
.

.

.

</if>

<else>

</else>

</case>

Posted in Alexa, Alexa Lambda Function Skill, Amazon Web Service, AWS, JSON, Node.js

Create a custom Alexa Lambda Function Skill

 

  1. Login to Amazon Developer account, Navigate to “AWS Lambda”; then create a new Lambda function using a blueprint with code for the basic functions that implements a simple skill in Node.js or Python. To start with sample code, click Blueprints, then select one of the skill kits, for instance “alexa-skills-kit-color-expert”
  2. Then Enter a “name” for the function.
  3. Select the “Role”, use the role under “Existing role”.
  4. and then “Create function”.
  5. This will create a sample that we can edit later as needed.

 

Then in another browser login to your “AWS Management Console” and navigate to AWS Lambda.

  • Select “US East (N. Virginia) Region on upper-right corner of the console.

8

  • Select “Enable” for Skill ID Verification.

9

  • And copy the Skill ID from Developer Console > Your Skills > Skill-Name> Endpoint tab>

4

and past it into the Skill ID edit box as shown below:

9

  • Then click “Add” and “Save”. And copy the ARN from AWS Console and past into Skill Function > Endpoint > Default Region. In this way they can interact and handshake together.

5

 

To test our sample Lambda Function code in the Console:

10

  • In the Function list, click the function name to open the details for the function and click the “select a test event > configure test events > Create new test event > Select one of the sample Alexa requests from the Event template, I choose “Alexa Start Session” > Enter the Event name > Create.

11

Then click the “Test” button. The Execution result should be succeeded.

12

This test was for testing the interaction. To test the skill itself, we open the skill at developer amazon console; there is a “Skill builder checklist” that I modified as needed;

1

“Invocation Name” is the name of the skill to begin interaction with a particular custom skill; for instance, if invocation name is: business library then user can say: hey Alexa, open / start {Skill Invocation Name}.

2

An “Intent” represents an action that fulfills a user’s spoken request. Intents can optionally have arguments called “Slots”. For example, in a Library Skill; defining librarians contact define an intent name “librarianContact” that has slots named name or contact.

There are two json files to modify/ import the custom function skill; one in developer console to “Json editor” that defines the interaction and one at AWS Console “index.js”.

Then Click “Build Model”.

3

Then Click “Test” menu, to test the custom skill;

  • In the text box in Alexa Simulator, type: Alexa, open {Invocation Name};

It will show the content we provided in the “WELCOME_MESSAGE” in the json file (index.js).6

 

Then we can ask or type more questions to interact with the simulator.

Posted in JSON, WEB-SERVICE, XML

JSON vs XML

JSON: JavaScript Object Notation XML: eXtensible Markup Language
data-oriented document-oriented
Types Number, Array, Boolean, String, Object and Null All string
Data JSON Objects are typed XML data is typeless
Simplicity of read/ write shorter & faster, no end tag
Easy to learn
Capability to display No Yes,

capable to display data because it is a markup language

Support array
secured more
Human readable more
Datatype support only text and number text, number, images, charts, graphs etc.

Also, XML offers options for transferring the format/structure of the data with actual data

Parsed by a standard JavaScript function into ready-to-use JavaScript object An XML parser