The air quality around us is vital for our health and the overall environmental quality. Lots of people do not pay attention to the this fact because they believe it is out of their reach to make a difference. However, it is not. There are organisations that regulate the air pollution around that you can contact in case it is very bad for breathing it into our lungs. The least we can do is stay at home instead of going out for a walking or jogging.
Idea - the what?My Alexa skill allows you to get air quality information and some recommendations what to do. You just need to provide it with a location and if that location is recognised and supported, you will get the quality of the air.
Implementatio - the how?Uses Amazon Lambda , API Gateway from AWS and the Nodejs alexa-app module. The integration is a custom Amazon Alexa skill and uses the Google maps API to get longitude and latitude details of the location provided and Breezometer API to get the air quality index.
Future functionalities?In the future, I can add searching for air quality predictions for a specific date in the future. For example, before visiting a city or a place you can check if it healthy for you being there, and then plan your trip.
More detailsLet's start off with Intent Schema.
We really only need one thing from the user, which is the location. We can do this by defining an intent "GetAirQuality" with slot of GB_CITY (however it recognises cities and places all over the world)
Intent Schema:
{
"intents": [
{
"intent": "GetAirQuality",
"slots": [
{
"name": "location",
"type": "AMAZON.GB_CITY"
}
]
},
{
"intent": "AMAZON.HelpIntent"
},
{
"intent": "AMAZON.StopIntent"
},
{
"intent": "AMAZON.CancelIntent"
}
]
}
Moving on to the Sample Utterances. I generated various ways of asking for air quality, and we replace the location with the slot name {location}
.
Sample Utterances
GetAirQuality get me the air quality in {location}
GetAirQuality get me the air quality around {location}
GetAirQuality show me the air measures in {location}
GetAirQuality {location}
GetAirQuality how is the air in {location}
GetAirQuality how is the situation like in {location}
GetAirQuality what is the air like at {location}
GetAirQuality get me pollution information in {location}
GetAirQuality give me the pollution data in {location}
GetAirQuality is the air quality bad in {location}
GetAirQuality is the air quality good in {location}
GetAirQuality should i go to {location}
GetAirQuality is it worth being in {location}
GetAirQuality what contaminants are there in {location}
GetAirQuality get me the air details around {location}
GetAirQuality tell me what is the air quality near {location}
GetAirQuality show me the air measures around {location}
GetAirQuality how is the air around {location}
GetAirQuality should i go out in {location}
GetAirQuality how is it outside in {location}
GetAirQuality can i go running in {location}
GetAirQuality will i get fresh air out today in {location}
GetAirQuality what contaminants are there outside today in {location}
GetAirQuality how is the air in {location} today
GetAirQuality how is the air in {location} now
There is no need to keep track of session in this Alexa skill. Since there is only on slot, namely location, if the user has provided location, they should receive some kind of result. Otherwise, they are prompted for the location. Initially, I was planning to include another intent where no location is provided in which case I need to find the location of the Alexa device, but turns out Amazon doesn't have public API yet to do such operations.
Uploading to AWS Lambda function
Now, we need to deploy our code to AWS Lambda. It is done by zipping the source code (including the node_modules
folder if you developing on Nodejs) and uploading the archive to a Lambda function. When creating a function make sure to choose AWS N. Virginia, at the time of this writing, only AWS East has Alexa Skills Kit trigger.
Create a new Lambda function:
Create a black function:
Select Alexa Skills Kit from the trigger dropdown.
Lambda trigger selection
Name your function and give a brief description. Upload the archive.
You will be asked to set up your IAM role if you have not done so.
Copy the ARN. You'll need this to link your Alexa Skill to the AWS Lambda function.
Create the function.
Integrating with Alexa Skill Kit
Back in the Alexa Skill developer console, go to the configuration page of your skill and copy the ARN:
Click Next, and test your Skill!
Testing
Another testing tool is Echosim.io
If everything goes as expected, you can publish your skill to Alexa store.
Phrases for Air Quality
Alexa ask AirQuality what is the air quality like in London //city
Alexa ask AirQuality to get me the air quality in seventh Avenue, New York //specific address
Alexa ask AirQuality is it worth going to Eiffel Tower, Paris //place
Alexa ask AirQuality what contaminants are there in Spain //country
Video
Comments