Chapter 5. Making Alexa Talk About CryptoCurrencies
"The future is here. It's just not widely distributed yet."
We designed a trivia game, called Factly, with Alexa in the last chapter. In this chapter, as promised, we are going to work on something that, at the time of writing this book, has taken the whole world by storm and, as you may have guessed from the chapter's title, it is cryptocurrencies.
In this chapter, we will be building a Skill called CryptoOracle
(yes, we do understand it is a bad naming choice both in terms of syntax, semantics, and Alexa Skill-naming rules, but since we are not going to publish it yet, we are going to stick with this name) that can make Alexa talk about the latest prices of various cryptocurrencies. We will cover the following topics in this chapter:
- A Brief Introduction to Cryptocurrencies
- Designing the CryptoOracle skill
- Building the CryptoOracle skill
Let's begin.
A Brief Introduction to Cryptocurrencies
For those who came late and missed the massive hype that Bitcoin and other similar cryptocurrencies, generated especially during 2017 and onward: cryptocurrencies are digital/virtual currencies, that is, unlike physical currencies, such as the dollar, euro or rupee, cryptocurrencies exist just as entries in a distributed database (usually). Various cryptographic techniques are deployed to record cryptocurrency transactions and their generation, and so these digital currencies are generically known as cryptocurrencies.
Note
Since cryptographic techniques are beyond the scope of this book, we won't be covering them here.
As of the time of writing this chapter, there are more than 1,500 cryptocurrencies available, and thebettercryptocurrencies out of those 1,500 cryptocurrencies serve a unique purpose.
Some cryptocurrencies are used...
Designing the CryptoOracle skill
Now that we know what cryptocurrencies are and why are they are getting all the attention lately, we can design the CryptoOracle
skill.
CryptoOracle
will work via the following steps:
- A user launches the skill:
Figure 5.1: Launching the CryptoOracle skill
The launch response is fetched from the Lambda and played to the user, as shown in the preceding diagram.
- A user asks Alexa about the price of any cryptocurrency:
Figure 5.2: Querying the cryptocurrency price via the CryptoOracle skill
This request will do in the following:
- Launch an intent to fetch the price with the cryptocurrency name as a parameter
- The Lambda receives the intent and extracts the cryptocurrency name
- The Lambda fetches the cryptocurrency price via the coinmarketcap API using the currency name
Finally, the response from the Lambda, which contains the cryptocurrency price, is played to the user.
Building the CryptoOracle skill
As of the time of writing this chapter, Amazon has recently updated its Alexa Skills Kit (ASK) developer console. We will be making use of the updated developer console for the purpose of developing our CryptoOracle
skill:
- Navigate to the ASK console at https://developer.amazon.com/alexa,
Sign In
to the portal, and go to the Skills
creation page (we have already done this exercise in the previous chapters, hence we won't be repeating those steps):
Figure 5.6: Alexa Skills Portal – ASK Console
Click on the Create Skill
button located at the bottom of the screen.
- The
Create a new skill
screen requires a SkillName
to proceed further, as shown in the following screenshot:
Figure 5.7: Naming the CryptoOracle skill
Name our skill CryptoOracle
and click on the Next
button.
- The next page will display the types of pre-built interaction models that can be added to the skill. Click on the
Select
button under the Custom
model to select it, and click on theCreate Skill
button in...
We hope you enjoyed creating the Crypto skill. As with the skills from the previous chapters, the CryptoOracle
skill still has room for a lot of improvement. For example, currently it just fetches the price of a cryptocurrency, but you could easily modify it to fetch a lot of other parameters too. Hence we urge you to please take a closer look at the CoinMarketCap API to find out what all other parameters(for example, market cap, total supply, max supply, and so on) for a cryptocurrency it can be fetched so that you can augment the skill with more information.
Also, we are only handling two intents; we could extend the skill to handle even more intents that could deal with other user interactions.
We have left these improvements as an exercise for the user to hone their skill even further.
In the next chapter, we will extend our Alexa knowledge even further by creating an Alexa Skill that is oriented toward integrating Alexa with other smarthome devices.