Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
![](https://cdn-images-1.medium.com/max/1024/1*-tg_C_1FM17ujdar6di_MA.png)
This post is part of âAlexaâ series. I will walk you through how to build an Amazon Alexa Skill with Node.JS and Lambda to get numbers of followers & repositories in GitHub in real-time.
Note: all the code is available in my GitHub.
Amazon Echo will captures voice commands and send them to the Alexa Skill to convert them into structured text commands. A recognized command is sent to an AWS Lambda function that will call GitHub API to get response.
To get started, sign up to Amazon Developer Console, and create a new Alexa Skill:
The invocation name is what user will say to trigger the skill. In our case it will be âgithubâ.
Click on âNextâ to bring up the Interaction Model page, use the intent schema below:
Intents will map userâs voice command to services that our Alexa skill can address. For instance, here I defined an intent called GetGithubFollowerCount, which will line up with a portion of code in my Lambda funtion that I leverage in a bit.
The programming languages are defined as a Custom Slot Type, with the following possible values:
GoJavaPythonCC++JavascriptHTMLScalaOcamlNodeJSRubyPHPCSSC#PerlShellObjective C
Now our intents are defined, we need to link them to a human request that will trigger this linkage. To do this multiple sentences (utterances) are listed to make the interaction as natural as possible.
GetGithubFollowerCount how many followers do I haveGetGithubFollowerCount current followersGetGithubFollowerCount number of followersGetGithubRepositoryCount how many repositories do I haveGetGithubRepositoryCount number of repositoriesGetGithubRepositoryCount current repositoriesGetGithubRepositoryCountByLanguage how many {Language} repositoriesGetGithubRepositoryCountByLanguage number of {Language} repositoriesGetGithubRepositoryCountByLanguage current {Language} repositories
Result:
Click on âNextâ and you will move onto a page that allows us to use an ARN (Amazon Resource Name) to link to AWSÂ Lambda.
Before that, letâs create our lambda function, login to AWS Management Console, then navigate to Lambda Dashboard and create a new function from scratch:
Select Alexa Skills Kit as trigger:
I wrote the Lambda functions in Node.JS, although that code isnât actually that interesting so I wonât go into it in much detail.
This function is fired when there is an incoming request from Alexa. The function will:
- Process the request
- Call GitHub API
- Send the response back to Alexa
Create a zip file consisting of the function above and any dependencies (node_modules). Then, specify the .zip file name as your deployment package at the time you create the Lambda function. Donât forget to set your GitHub Username as an environment variable:
Back in the Alexa Skill we need to link our Lambda function as our endpoint for the Alexa Skill:
Thatâs it, letâs test it out using a Service Simulation by clicking on âNextâ.
GetFollowerCount Intent :
GetRepositoryCount Intent:
GetGithubRepositoryCountByLanguage Intent:
You can see that the Lambda responds as expected !
Test it now with Amazon Echo, by saying âAlexa, ask GitHub for âŠâ :
Amazon Alexa GitHub Followers Counter 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.