martedì 4 gennaio 2022

Create an Alexa Skill that will report the daily numbers of the covid in Italy

 


After the creation of the python script i decided to create an Alexa skill that can read to me the small report with the numers of the covid in Italy. The skill returns:   

  • the number of new positives,
  • the total number of swab test of the day,
  • the rate of positivity,
  •  new entrants to the hospital and
  • the numbers of deaths.

I haven't find any good skill that can do it so I decided to create it by myself. Like with the python script the data are those officials provided by the repository of Dipartimento della Protezione civile. The skill will update the data according to the data update of this department.

For the creation of the skill I used this tutorial youtube and I used the inventiveness to compile the rest.

To activate the skill you should say (the instruction are in Italy in my case):
Alexa, bollettino covid
or
Alexa, apri bollettino covid
or
Alexa, chiedi a bollettino covid il numero di tamponi

These are the main step to create the skill:

01. Open the website developer Amazon
02. Skill Builders
03. Develop your Skill
04. Create Skill
05. Custom


06. Alexa-hosted (Python)

07. Start from Scratch

08. Continue with template
09. Interaction Model -> Intents
10. Add Intent
11. Add all the Intents you need. Save Models

12. Repeat the process for the new positives, swab tests, decease, new entrants at the hospital and the rate of positivity
 

13. Build Model
14. Go to the "code" sheet

15. To insert the Intent we should copy and paste those already present in the pre build model (for example copy the "HelpIntentHandler" and edit it with the intent created by us in the "Build" sheet. I activated the ask function that will ask to the user if he want to know other data. If he will not respond the skill will terminate.


16. Add the "intenthandler" at the bottom of the page with the others "SkillBuilder" like in the image below


17. I pasted the python code of my script edited deleting all the prints (you can find the code on github Pymay73) and I have lightened the code

18. I competed the file "requirements.txt" inserting only pandas  because I discovered that all the other library used in my python code were natively included in the lambda function. For any libraries that aren't natively included in lambda you will need to populate "requirements.txt". For a list of libraries that are natively included please see: here

19. Test the code in the "Test" sheet

20. To make other changes you have to turn back to "Code" e "Build" sheets if you want to edit the Intents, the Slots or the Invocation phrase.

When you will switch from "Test" to "Code", for example, you will receive many times the "Scheduled Manteinance" message and you have to wait patiently for one minute before the page to be refreshable and to be able to edit the code again. I think this is a bug of the developer Amazon website. You will need a lot of patience.

These are the main steps. If you have more questions you can study the source code at my page on github Pymai73

This is a first version so it can be unstable and can not respond like you want sometimes. I accept advice in case of discovery of bugs.

 

 

Nessun commento:

Posta un commento