Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
Being an AWS Certified can boost your career (increasing your salary, finding better job or getting a promotion) and make your expertise and skills relevant. Hence, thereâs no better way to prepare for your AWS Certified Developer Associate exam than getting your hands dirty and build a Serverless Quiz game with Alexa Skill and AWSÂ Lambda.
Note: all the code is available in my GitHub.
1 -Â DynamoDB
To get started, create a DynamoDB Table using the AWSÂ CLI:
I prepared in advance a list of questions for the following AWS services:
Next, import the JSON file to the DynamoDBÂ table:
The insertToDynamoDB function uses the AWS DynamoDB SDK and PutItemRequest method to insert an item into the table:
Execute the following command to import the questions:
If you navigate to DynamoDB Dashboard, you should see that the list of questions has been successfully inserted:
2âââAlexa Skill
This is what ties it all together, by linking the phrases the user says to interact with the quiz to the intents.
For people who are not familiar with NLP. Alexa is based on an NLP Engine which is a system that analyses phrases (users messages) and returns an intent. Intents describe what a user want or want to do. It is the intention behind his message. Alexa can learn new intents by attributing examples of messages to an intent. Behind the scenes, the Engine will be able to predict the intent even if he had never seen it before.
So, sign up to Amazon Developer Console, and create a new custom Alexa Skill. Set an invocation name as follows:
Create a new Intent for starting the Quiz:
Add a new type âSlotâ to store user choice:
Then, create another intent for AWS service choice:
And for userâs answer choice:
Save your interaction model. Then, youâre ready to configure your Alexa Skill.
3âââLambda Function
The Lambda handler function is self explanatory, it maps each intent to a code snippet. To keep track of the userâs score. We use Alexa sessionAttributes property of the JSON response. The session attributes will then be passed back to you with the next request JSON inside the sessionâs object. The list of questions is retrieved from DynamoDB using AWS SDKand SSML (Speech Synthesis Markup Language) is used to make Alexaspeaks a sentence ending in a question mark as a question or add pause in the speech:
Note: Full code is available in my GitHub.
Sign in to AWS Management Console, and create a new Lambda function in Go from scratch:
Assign the following IAM role to the function:
Generate the deployment package, and upload it to the Lambda Console and set the TABLE_NAME environment variable to the table name:
4âââTesting
Now that you have created the function and put its code in place, itâs time to specify how it gets called. Weâll do this by linking the LambdaARN to Alexa Skill:
Once the information is in place, click Save Endpoints. Youâre ready to start testing your new Alexa Skill !
To test, you need to login to Alexa Developer Console, and enable the âTestâ switch on your skill from the âTestâ Tab:
Or use an Alexa enabled device like Amazon Echo, by saying âAlexa, Open AWS Developer Quizâ :
Become AWS Certified Developer with Alexa was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.