Free #Alexa Skill for Air Quality in Northern Ireland – #OpenSource
This is a free skill available for Alexa, that you can enable here;
https://smile.amazon.co.uk/Open-Merchant-Account-Ltd-Northern/dp/B07TSRZCMT/ref=sr_1_1
It’s open source, and open to improvements and suggestions by anyone interested in collaborating.
You can ask it questions such as “Alexa, ask air quality northern Ireland what is the level of nitrous oxide in Belfast“, or ask about particulate matter, carbon monoxide, ozone, or sulfur dioxide.
The data itself is courtesty of the Northern Ireland Department of Environment. via AirQualityNI.
At a high level, this skill runs on the Alexa platform, which hooks into Amazon’s Lambda service, running NodeJS. From there, it connects to an API, which is described here; https://github.com/infiniteloopltd/airquality – Which is hosted on a Windows server, and makes the connection on to the AirQualityNI website, and dynamically converts CSV data to the more readable JSON format.
Here is a run down on the constituent parts
The Alexa interaction model is defined here; https://github.com/infiniteloopltd/AirQuality/blob/master/Alexa/interaction.json
This defines the phrases that can be used with the skill, such as
“What is the level of Nitrous oxide in {city}“
Where {city} is of type AMAZON.GB_CITY, this is interpreted as the NitrogenOxideIntent, and passed to the Lambda handler at index.js here;
https://github.com/infiniteloopltd/AirQuality/blob/master/Lambda/index.js
This, then checks the intentName, and if it’s equal to NitrogenOxideIntent, then handleNitrogenOxideIntent is called, which then calls airQuality.NitrogenOxide(..), which is defined here:
https://github.com/infiniteloopltd/AirQuality/blob/master/Lambda/airquality.js
The NitrogenOxide() function calls DescribePollutants(), passing a function to filter the data by city, and these three types of Nitrogen-Oxide pollutants; “NO“,”NO₂” and “NOₓ as NO₂“. DescribePollutants() then makes an HTTP request to http://airquality.derrycreativescollective.com/, which returns yesterday’s mean values of air pollutants in Northen Ireland. – It then formats the response into a spoken string, for example, using NamePollutant() to convert chemical formulae like “NO₂” to “Nitrogen Dioxide”.
Please, feel free to enable the skill on your alexa device, and give it a good rating, also feel free to contact me if you’d like to build upon this skill or API.