Alexa WorkShop – High low Sample Project @ Bangalore

Yesterday(June 16th, 2018) I got an opportunity to Participate in the Alexa introduction workshop organized by Amazon.

Here I’m sharing my experience and Short tour to quickly set up the sample Alexa project(high low game).

  • Setup your amazon developer access Amazon Developer Account & AWS Account  Complete the verification steps for enabling an Amazon verified account, including payment details, profile info, and phone verification as applicable.
  • InSide AWS Account you have to create one developer user.  you have to use the created developer account for the subsequent login.

Sample Project – High Low Scanner

Here I’m walking you through step by step creating the High-Low Scanner Application in Alexa(Mini Project)

Step1: Login to Alexa then click on Your Alexa Console –> Skills

ax_1.jpg

Step2: Create new skill, click on create new skill and name it as high low scanner first app and change the default language to English(IN), then click on Next Button

ax_2

ax_3.jpg

Step3: Select Custom and click on Create Skill Button , Because we are going to use node js custom development.ax_4.jpg

Step4: the next screen is the Alexa developer console screen, here you can build, simulate test

ax_5.jpg

Step5:  login to AWS Account  by using your developer account. Then select the default region to  US East (N. Virginia)

ax_6ax_7

Step6: Click on Services –> Lambda , then click on Create Function

ax_8-e1529248966656.jpgax_9.jpg

Step7: Click on ServerLess Application Repository. then type facts and then press enter then click on alexa-skills-kit-nodejs-factskill

ax_10

note: alexa-skills-kit-nodejs-factskill is the sample template created by Amazon developer team,  by default it’s installed node.js. It helps to create the new node.js project easily. otherwise, if you are starting with the blank template,, you need to take care of installing node.js and other default configurations

Step8: in the next page, scroll down and enter the application name as Alexa-HighLow-Game then click on Deploy.

ax_11

Step9: once deployed you can able to see the three Green Checkmarks , then click on alexaskillskitnodejsfactskill then you can able to see

ax_12.jpg

Next Page Configuration and Monitoring Screen.

ax_13.jpg

Configuration and Monitoring Screen.: scroll down –> Function Code

ax_14.jpg

Index.js

Click on Index.js –> it holds the source code for sample project. till the previous step we did the basic setup for the Alexa app.

Now its time to Attach the sourcecode of High low game to our created project.

Open the following URL :

highlow

Then Open lamba/custom and then copy the entire content from index.js

attaching the index.js here

ax_15

Copy the entire content and go back to Function Code and then replace the index.js content and then click on Save

ax_16.jpg

Step10: Go back to Alexa Console , then open high-low scanner app , then click on JSON Editor

ax_21.jpg

then go to the following github url and copy the raw value.

https://github.com/alexa/skill-sample-nodejs-highlowgame/blob/master/models/en-GB.json

then come back to the JSONEditor and paste the data, then Click on Save Model , then click on Build Model.

ax_22.jpg

to verify the build, check the below intents & Slot types are created.

ax_23.jpg

Step10: its time to update EndPoints. Go to the lambda Console and copy the arn Urlax_24.jpg

Come back to the Alexa Console and then click on EndPoints and then select AWS Lambda ARN,  then paste the copied ARN Url , and then Save End Points

ax_25.jpg

 

Step10: In our sample project, we are using Session storage and during the session end event we are capturing the session data inside the table, Amazon has dynamodb its basically NoSql Db, for first 25 gb lines is free in our  free account.

So i’m giving the read-write access for my Lamba

  • open https://console.aws.amazon.com, then click on services and then Type IAM and click
  • roles and then click on the role name assigned to your project.
    • you can check the role name in the lamba console and then check the execution role –> existing role
    • find the same role name in the list from the IAM–> Roles
  • click on Attach Policy, then type dynamodb, select –> AmazonDynamoDBFullAccess then click on Attach Policyax_17ax_18ax_19.jpg
  • To verify the access go back to your lambda console ,Then you can see the lot of apps added to the Lamba section.

ax_20.jpg

Its Show Time :

giphy

game Rule: Alexa will store the random number and save it in session, we have to guess the number by telling, alexa will validate the request and provide the response.

  • Open Alexa Console, select the High low game and then click on Test Tab and then enable the test

ax_26.jpg

  • Type high low game then you can able to see the result as like below

ax_27.jpg

  • Then Typed Yes and then started playing the game by providing the different types of inputs, see the screenshot below. then ended the game. i started from fifty to 1, My bad the number is 1 😦

ax_28

in the next post, I will explain the below code details, these are the key coding used in the high-low game

  • Session Storage – Set and retrieval
  • Database Table Creation
  • Table Data –  Set and retrieval

Thanks for reading, Happy coding. !!!!!!!!!!!!!!!!!!!

 

 

 

 

 

 

Advertisements

Sitecore 9.0.0 Habitat Installation – Hiccups & Issues

Here I’m documenting the issues occurred during the Sitecore 9 Habitat installation.

HB1.2.jpg

  • Inside settings.ps1. Make sure to update your Sitecore version and Solr Folder.  update the other settings as per your local environment.
    • HB7
    • HB8
  • After Configuring everything, During executing Install.ps1 if you’re getting the below Error ,

Error: Get-LocalGroupMember : Principal IIS APPPOOL\DefaultAppPool was not found

HB1.jpg

then comment the following lines(82 to 89) then execute the Powershell script.

HB2.jpg

  • Install Node.js Software, If you’re not installed already, otherwise you will get the below error. https://nodejs.org/en/

Error:’npm’ is not recognized as an internal or external command,
operable program or batch file.

HB3.1.jpg

Install Node.js

HB3.jpg

After installing node.js. execute the command as per the Getting started instructions. then it will take around 15 minute to complete the Building,Restoring Packages ,Unicorn Sync and Publish.

  • You can either execute the gulp command through CMD Prompt or in visual studio 2017.

HB5.jpg

HB6.jpg

 

Sitecore 9 XConnect 403.16 certificate Installation Issues

Recently did the Sitecore 9 Installation. Post-installation faced the below error Browsing XConnect: Experience Analytics: Sitecore Logs: Sitecore.XConnect.XdbCollectionUnavailableException The issue is because of Sitecore 9 – Untrusted certificates are installed under the Trusted folder, So we have to manually execute the below PowerShell script after Sitecore 9 installation and then restart the machine. Use Powershell […]

Asp.net MVC Ajax File Upload in Sitecore Programmatically using API calls

here I’m going to explain about uploading the file directly into Sitecore media library programmatically. below is the list of steps will be following to Upload the file to Sitecore

  • Coding cshtml & Ajax API calls
  • Coding to Create the Month & Year Wise Folders to store the uploading images
  • code to publish the created folders.

Code cshtml & Ajax API calls

Create a cshtml and add the following list of Code

<input type=”file” id=”FileUpload1″ />
<input type=”button” id=”btnUpload” value=”Upload Files” />

and then create a separate javascript file and add the following ajax API call functionality, it will help to pass the attached file to the form and it can also send the other input data

$(document).ready(function () {
$(‘#btnUpload’).click(function () {

// Checking whether FormData is available in browser
if (window.FormData !== undefined) {

var fileUpload = $(“#FileUpload1”).get(0);
var files = fileUpload.files;

// Create FormData object
var fileData = new FormData();

// Looping over all files and add it to FormData object
for (var i = 0; i < files.length; i++) {
fileData.append(files[i].name, files[i]);
}

// Adding one more key to FormData object
fileData.append(‘username’, ‘Manas’);

$.ajax({
url: ‘/Home/UploadImage’,
type: “POST”,
contentType: false, // Not to set any content header
processData: false, // Not to process data
data: fileData,
success: function (result) {
alert(result);
},
error: function (err) {
alert(err.statusText);
}
});
} else {
alert(“FormData is not supported.”);
}
});
});

Create the Action Result and add the below code to Upload an Image,

1

Code to create Sitecore Folder programmatically

2.1

Code to attach the File to Sitecore Media Library

2

3

Code to Publish the newly Inserted media items 

4

Final View of the uploaded Images 

5

TDS Auto Code Generation Issues

As part of my development activity, I have created one WFFM form under the Global Section under the home node.

I need to access the WFFM fields to access the data entered into the text box field. So synced the tds items but the respective code is not generated. Tried more than 10 times but the automatic code is not generated.

Then checked with my colleague, he gave the clue.

Solution: During the initial configuration, by default Other than templates all the other items code generation is disabled, In my case its Global item, to generate the Code follow the below steps

  1. Right-click on the Sitecore Item and select properties
  2. Select the Code generation template drop-down and select the respective template
  3. In my case it’s itempaths.tt, After selecting itempaths.tt, TDS code is generated automatically.

Glass Mapper – Initial Setup issues

After installing glass mapper, If your getting warnings on RenderImage, IsEditable ,RenderLink or any other glassmapper objects.

Error:

The Type ‘Expression<>’ is defined in an assembly that is not referenced. You must add a reference to assembly “System.Core, Version=4.0.0.0, Culturalneutral,PublicKeyToken”

Then make sure to add the below line Under <System.WebServer> <assemblies>

<add assembly=”System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089″/>

After that close and re-open the solution, it will resolve the warnings now. Make sure to use the appropriate assembly version for system.core

Bundling with Sitecore 6.5 to 8.2 + versions of Sitecore

Asp.net MVC4 bundling and minification it helps to avoid the repeated request to Servers and enables caching the data into server Memory.

I have got a chance to implement bundling in two Sitecore Versions

  • Sitecore 6.5 (Web Forms)
  • Sitecore 8.1 (MVC)

Let’s See how to implement bundling in Sitecore 6.5

Bundling in Sitecore 6.5 to  8.1 version

1)Open NuGet packet manager and execute the below command

2)Create a Class and add the .css file and .js file path as like below

3)Open Global.asax.cs file and open Application Start Event and add your bundling class

4)add the Script bundle and style bundle into the IgnoreUrlPrefixes as like below

5) Now remove the actual reference of your css &js files inside the code and add the below code to refer the files

Below is the reference in case of Web forms

 Bundling in Sitecore 8.2 and greater version

Sitecore removed the functionality of Global.asax.cs Application_Start event from Sitecore 8.2 onwards because its Inheriting Sitecore.Web.Application.  So we need to use the sitecore pipeline approach as per the blog post as below.

I already implemented asp.net bundling using Sitecore Pipeline as per the below blog post , its working absolutely fine

http://jockstothecore.com/bundling-with-sitecore-mvc/