Click here for Make money Online
Tham gia kênh Telegram kiếm tiền online ==> Click
He also describes a simple use case to do with IOTA tokens that can be created thanks to it.
Integrating Amazon Alexa with IOTA
Gregersen describes a use case with an imaginary hotel owner where funds from various devices and services running on IOTA arrive in his numerous crypto wallets. To check the balances of these addresses, the owner has to become distracted with other important things; he always has a lot to do.
Therefore, integrating Amazon Alexa with IOTA helps him, since this would allow him to check his IOTA balances in his wallets merely with a voice command. To do that, it is not necessary to have an Alexa-enabled gadget—such as smart speakers, smart watches, smart TV, etc.—but you can install Alexa on your iOS or Android device.
Checking IOTA balance via Alexa
This can be done via the creation of a new Alexa Skill in the Alexa Developer Console. To do that, you need to upload the Python code containing all the functions necessary for a new Alexa Skill in the Amazon Web Services cloud.
After that, you need to specify invocation, intents and utterances—code phrases that activate Alexa to work with her newly added skill. For example, by saying aloud "get IOTA balance," you activate Alexa on this skill. If you then just say "Alexa, get iota balance," the virtual assistant will inform you how many coins you have in your wallet.
The 20th part in a series of beginner tutorials on integrating physical devices with the IOTA protocol
Alexa, Please send fifty IOTA’s to Alice
Alexa, What is my IOTA balance?
Alexa, What is the current IOTA transaction throughput?
These are some of the cool things you could teach Alexa to do after completing this tutorial…
This is the 20th part in a series of beginner tutorials where we explore integrating physical devices with the IOTA protocol. In this tutorial we will look at integrating the Amazon Alexa virtual assistant with the IOTA protocol. At the same time, we will also get an introduction to the concept of cloud computing as our Python code for this project will be hosted as an AWS Lambda function.
The Use Case
Over time our hotel owner have ended up with multiple IOTA addresses where he receives funds from various IOTA powered devices and services. Now and then he needs to check the balance for these addresses. Only problem is that opening his Trinity wallet or checking thetangle.org takes him away from other tasks he might be doing at the same time. What if he could use some type of voice activated assistant to help him out? He could then get the information he needs, while at the same time stay focused on the task at hand.
Let’s see if we can help him out..
What is Amazon Alexa?
Amazon Alexa is a virtual voice assistant app. developed by Amazon. The Alexa app. comes embedded in many different Alexa enabled devices such as smart speakers, smart TV’s, smart HI-FI systems, smart watches etc. You may even have Alexa embedded in your car in case you haven’t noticed.
Notice that you don’t need an Alexa enabled device to talk to Alexa. You can simply install the Amazon Alexa app. on your IOS or Android smartphone.
What are Alexa Skills?
Although Alexa can do a lot of things out-of-the box.., some times we need to teach her new “skills” that she does not already know how to do. And this is exactly what we will do in this tutorial.
At their simplest, Alexa skills are like voice activated smartphone apps. They are created by third party developers (like us). Some Alexa Skills work entirely on their own, while others interact with something else, such as an online service like Spotify, a smart home product like a Roomba robotic vacuum cleaner, or as in our case, the IOTA tangle.
What is AWS Lambda?
AWS Lambda is a an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services (AWS). AWS Lambda allows us to host and run the Python code required by our new Alexa Skill. The Python code (with all its dependencies/libraries) is typically packaged as a .zip file and uploaded to AWS in the form of an AWS Lambda function. We can now trigger the Lambda function (Python code) based on the response from some other AWS service, such as Alexa.
You can create and host AWS Lambda functions in the AWS Management Console for free by signing up for an AWS free tier account here
AWS Lambda functions can be written different programming languages, such as Node.js, Java and Go, in case you prefer to write your Lambda code in one of these languages. In my example, I’m decided to go with Python as you may already be familiar with the PyOTA library from my previous tutorials.
When developing a new Alexa Skill we typically start by creating a new Alexa Skill in the Alexa Developer Console. Next, we define how we will interact with Alexa so that she understands our intent during the conversation. Next, we take the Python code where we have all the functions needed for our new Alexa Skill and upload the code as a hosted AWS Lambda function in the Amazon Web Services cloud. Next, we “connect” our Alexa Skill to the Lambda function so that Alexa know what code and functions to run when we interact with her. And finally, we test our new Alexa Skill.
Let’s take them step-by-step..
Step 1 — Create a new Alexa Skill
Let’s start by creating a new Alexa Skill in the Alexa Developer Console
To create a new Alexa skill you first need to sign up for a free Alexa developer account. You will find a link to the Alexa Developer Console here.
After signing up and loging in you should now see the main page of the Alexa Developer Console.
Lets start by creating a new Alexa skill using the “Create Skill” button.
Next, we need to give our new skill a name, a default language, a model and a hosting method.
Let’s call the new skill iota_balance with default language English (US). As model, select Custom, and as hosting method, select Provision your own before pushing the “Create Skill” button
Next, we need to select a template for our new skill.
Let’s select the Hello World Skill template before pushing the “Continue with template” button.
Step 2 — Specify invocation, intents and utterances
Next, we need to teach Alexa how we will invoke and interact with her new skill during a typical conversation. This is done using Invocations, Intents and Utterances.
The Invocation let’s Alexa know what skill to perform when we call for her. In my example i decided to go with the phrase: get iota balance
So if I now want Alexa to perform this particular skill, i would simply say: Alexa, get iota balance
The Intents section specifies various “functions” within Alexa’s new skill that i might want to invoke during our conversation. In my example I have two main intents:
Get the balance of my personal IOTA address
Get the balance of the Hotel IOTA address
In my example I named these intents: PersonalBalance and HotelBalance
Notice that there are some Buildt-In Intents (CancelIntent, HelpIntent etc.) that came with the Hello World Skill template. These are typical intents you would invoke in case you want to exit the skill, get some more information about the skill etc. For now, just leave them within the list of Intents.
For each Intent you also need to specify some typical phrases you would use to call a particular Intent. These phrases are called Utterances and are associated with there respective Intent. For instance, if I want to invoke the PersonalBalance Intent, I might say something like “Get my personal balance” or “What is my personal balance”.
By using some clever machine learning algorithms, Alexa normally understands your intent even if you don’t say the sample utterances directly as spelled out. It is often enough to just include one or two key words in the sentence.
Step 3 — Creating and uploading the AWS Lambda function for our Alexa Skill
Next, we will create a new AWS lambda function in AWS and upload the Python code to be used by our new Alexa Skill.
Start by going to the AWS Management Console and find the Lambda service.
After selecting the Lambda service, select functions and push the “Create function button”
Select the “Author from Scratch” template and give your new Lambda function a name. In my example I used the name iota_balance. Finally, select Python 3.8 as your programming language and press the “Create function” button.
When the new Lambda function opens, next thing we need to do is to specify that the function will be triggered by an Alexa Skill. Go to the Designer panel and push the “Add trigger” button. Then from the “Trigger configuration” list, select “Alexa Skills Kit”. When asked for your Skill ID, paste the Skill ID for the Alexa Skill created in Step 1.
You will find the Skill ID for your Alexa Skill by selecting Endpoint in your Alexa Skill.
Now that we have created our new Lambda function we can start uploading the Python code that will be associated with the function.
As mentioned previously, when hosting Python code as a Lambda function it is important that we also include and upload any non-standard Python libraries required by our function. In our case, the PyOTA library is required so we have to make sure we also include the files from this library. The way we do this in practice is that we package all our required files in one .zip file before uploading the .zip file to the AWS Lambda function.
I have prepared a .zip file you can use in your Lambda function to give you a head start while creating your first Alexa Skill. The .zip file includes the lambda_function.py file used by Alexa together with the PyOTA library required when interacting with the IOTA tangle. You can find and download the .zip file (get_iota_balance.zip) in this Github repository.
Now that we have our .zip file, go to your new Lambda function in the AWS Management Console, select the Actions drop-down menu in the Function code panel and then select “Upload a .zip file”. You may now select and upload your .zip file.
Step 4 — Connecting your Alexa Skill with the Lambda function
Last thing we need to do before we can start testing our new Alexa Skill is to “connect” our Alexa Skill to the Lambda function so that Alexa knows what Lambda function to use when performing her new Skill.
Start by copying the ARN id you see en the upper right corner when inside the Lambda function
Next, go to your Alexa Skill, select Endpoint and paste the id in the Default Region field
The Python Code
Let’s have a quick look at the Lambda function (Python code) for this project and how it works.
When looking at the code you will see that we have some standard functions required for interacting with Alexa. The most important being the on_intent() function. Here we define the code to be executed as we call for each individual Intent as described in Step 2.
So in my example, if you say something like “Get my personal balance” or “What is my personal balance”, the Alexa Skill knows that the Intent we want to execute is the PersonalBalance intent. Next, we simply call a new custom function (get_personal_balance()) where we have all the code for interacting with the IOTA tangle together with the returning responses from Alexa.
That’s it, and here is the code..
Creating your version of the project
The simplest way to get you started with creating your own version of this project (such as changing the IOTA addresses used for checking balances) is to simply modify the lambda_function.py file inside the .zip file and upload the modified .zip file to your existing Lambda function.
If you would like to make any contributions to this tutorial you will find a Github repository here
Read more: ==> The best Place buy Sell Cryptocurrency
Tham gia kênh Telegram kiếm tiền điện tử => Click here
Sell off ==> Click