Cov-Tell: Daily COVID-19 Updates with Alexa (made with Wolfram APIFunction)
Cov-Tell: Daily COVID-19 Updates with Alexa (made with Wolfram APIFunction)
Coronavirus updates through a voice app
Jessica Shi, Claire Morton, Aranyo Ray, Anwesha Das
Out[]=
Everyone is constantly looking up the latest statistics on the coronavirus, and specifically, they often want to know the most recent information about their county and state, which becomes a challenge due to information noise. We want to make this information easily and quickly accessible to laypeople - like through an Alexa device!
We created this voice app for the hack:now Hackathon, co-hosted by Postman and CalHacks; the tracks for hacking were productivity, health, and community regarding the COVID-19 crisis. We were in the top 30 teams out of 223.
The user can open our app from their Alexa or another voice-compatible device. Then, the device asks whether they want information at the county, state, or national level. The user can respond and input their location to receive a report on the change in confirmed cases and deaths in the user’s county or the change in state or national infection rate. This report is based on data from Wolfram. We used the Wolfram Language to build API functions that retrieve location-specific data from Wolfram on COVID-19 and format it in a speakable string format. Then, we used Voiceflow to make a voice app that provides the user with information from the API functions.
The code could definitely be simplified some more, but we were in a time crunch for submission!
Everyone is constantly looking up the latest statistics on the coronavirus, and specifically, they often want to know the most recent information about their county and state, which becomes a challenge due to information noise. We want to make this information easily and quickly accessible to laypeople - like through an Alexa device!
We created this voice app for the hack:now Hackathon, co-hosted by Postman and CalHacks; the tracks for hacking were productivity, health, and community regarding the COVID-19 crisis. We were in the top 30 teams out of 223.
The user can open our app from their Alexa or another voice-compatible device. Then, the device asks whether they want information at the county, state, or national level. The user can respond and input their location to receive a report on the change in confirmed cases and deaths in the user’s county or the change in state or national infection rate. This report is based on data from Wolfram. We used the Wolfram Language to build API functions that retrieve location-specific data from Wolfram on COVID-19 and format it in a speakable string format. Then, we used Voiceflow to make a voice app that provides the user with information from the API functions.
The code could definitely be simplified some more, but we were in a time crunch for submission!
County, State, and National Daily Update
County, State, and National Daily Update
We wanted the user to be able to get the information on the increase in confirmed cases and deaths counted from the day before.
County
County
Interpret the natural language input for county
In[]:=
interpret[county_,state_]:=Interpreter["USCounty"][StringJoin[county,", ",state]]
Retrieve the desired data
In[]:=
finddata[location_]:=First@Select[ResourceData["Epidemic Data for Novel Coronavirus COVID-19","USCounties"],MemberQ[#,location]&]//Normal
Find the most recent values of confirmed cases and deaths
In[]:=
ccdata[data_]:=Prepend[Append[MapAt[DateString[#,"Date"]&,(Transpose@data["ConfirmedCases"]["Path"][[-2;;-1]]),{1,{1,2}}],data["Deaths"]["Values"][[-2;;-1]]],TextString[data["County"]]]
Format the information in a readable string
In[]:=
ccreport[cclist_]:=StringJoin["In ",First@cclist," from ",cclist[[2,1]]," to ",cclist[[2,2]],", confirmed cases ",If[cclist[[3,2]]>cclist[[3,1]],StringJoin["increased from ",ToString@cclist[[3,1]]," to ",ToString@cclist[[3,2]]],StringJoin["remained constant at ",ToString@cclist[[3,2]]]],". Deaths have ",If[cclist[[4,2]]>cclist[[4,1]],StringJoin["increased from ",ToString@cclist[[4,1]]," to ",ToString@cclist[[4,2]]],StringJoin["remained constant at ",ToString@cclist[[4,2]]]],"."]
Example with Suffolk County, New York
ccreport[ccdata[finddata[interpret["Suffolk County","New York"]]]]
Out[]=
In Suffolk County, New York, United States from Wednesday 22 April 2020 to Thursday 23 April 2020, confirmed cases increased from 28854 to 29567. Deaths have increased from 926 to 959.
Create an API function to carry out the functions
api=APIFunction[{"county""String","state""String"},ResponseForm[ccreport[ccdata[finddata[interpret[#county,#state]]]],"JSON"]&]
Out[]=
APIFunction[{countyString,stateString},ResponseForm[ccreport[ccdata[finddata[interpret[#county,#state]]]],JSON]&]
Deploy it to the web
CloudDeploy[api,Permissions"Public"]
Out[]=
States
States
Interpret US State natural language and retrieve desired data
In[]:=
finddata3[state_]:=First@Select[ResourceData["Epidemic Data for Novel Coronavirus COVID-19","USStates"],MemberQ[#,Interpreter["USState"][state]]&]//Normal
Find the most recent values of confirmed cases and deaths
In[]:=
ccdata2[data_]:=Append[Prepend[MapAt[DateString[#,"Date"]&,(Transpose@data["ConfirmedCases"]["Path"][[-2;;-1]]),{1,{1,2}}],TextString@data["AdministrativeDivision"]],data["Deaths"]["Values"][[-2;;-1]]]
Format the information in a readable string
ccreport[ccdata2[finddata3["Virginia"]]]
Out[]=
In Virginia, United States from Thursday 23 April 2020 to Friday 24 April 2020, confirmed cases increased from 10998 to 11594. Deaths have increased from 373 to 411.
Create an API function for the state functions and deploy it to the web
apistate=APIFunction[{"state""String"},ResponseForm[ccreport[ccdata2[finddata3[#state]]],"JSON"]&]CloudDeploy[apistate,Permissions"Public"]
Out[]=
APIFunction[{stateString},ResponseForm[ccreport[ccdata2[finddata3[#state]]],JSON]&]
Out[]=
National
National
National follows the same process as state
In[]:=
finddata4[country_]:=First@Select[ResourceData["Epidemic Data for Novel Coronavirus COVID-19"],MemberQ[#,Interpreter["Country"][country]]&]//Normal
finddata4["Italy"]
Out[]=
AdministrativeDivisionMissing[NotAvailable],Country,GeoPositionGeoPosition[{42.8333,12.8333}],ConfirmedCasesTimeSeries,RecoveredCasesTimeSeries,DeathsTimeSeries
In[]:=
ccdata3[data_]:=Append[Prepend[MapAt[DateString[#,"Date"]&,(Transpose@data["ConfirmedCases"]["Path"][[-2;;-1]]),{1,{1,2}}],TextString@data["Country"]],data["Deaths"]["Values"][[-2;;-1]]]
ccreport@ccdata3[finddata4["United States"]]
Out[]=
In United States from Thursday 23 April 2020 to Friday 24 April 2020, confirmed cases increased from 263460 to 271590. Deaths have increased from 20973 to 21411.
apination=APIFunction[{"nation""String"},ResponseForm[ccreport@ccdata3[finddata4["United States"]],"JSON"]&]CloudDeploy[apination,Permissions"Public"]
Out[]=
APIFunction[{nationString},ResponseForm[ccreport[ccdata3[finddata4[United States]]],JSON]&]
Out[]=
Infection rate and flattening the curve
Infection rate and flattening the curve
We also wanted to give some indication of infection rate and what everyone calls “flattening the curve”. We used the following logistic equation to calculate infection rate: =a1-N, where N is the number of infected people, is the maximum number of people that can be infected, and a is the percentage daily infection rate. The lower the rate, the more “flat” the curve is. With the following functions, the voice bot will tell the user whether or not the “curve is flattening” in the state or the US in general. We decided not to do this with the county data because it is not as significant.
ΔN
Δt
N
N
max
N
max
State Infection Rate
State Infection Rate
Get the values of confirmed cases and deaths from three days ago
Find the population of the state
Calculate the delta value
Format the result to a readable result
Create an API Function and deploy it to the web
National Infection Rate
National Infection Rate
National Infection Rate
With these API links, we went to Voiceflow to build the rest of our app.
We’re super proud that we made a functional voice app that provides users at home with reliable updates on the spread of the coronavirus - in particular, hyperlocal information. No member of the team had previous experience with APIs or Voiceflow, so this project was an excellent opportunity to learn about how to design and implement APIs and how to create a user-friendly voice app. We hope to be able to retrieve more data from sources other than Wolfram, specifically the Johns Hopkins curated data since it is usually the most reliable and has the most recent updates. We also would like to provide data for regions and nations around the world instead of just the United States.With further work (and publicly available data), Cov - Tell will be able to provide crucial information, such as nearby hospital capacities.
We’re super proud that we made a functional voice app that provides users at home with reliable updates on the spread of the coronavirus - in particular, hyperlocal information. No member of the team had previous experience with APIs or Voiceflow, so this project was an excellent opportunity to learn about how to design and implement APIs and how to create a user-friendly voice app. We hope to be able to retrieve more data from sources other than Wolfram, specifically the Johns Hopkins curated data since it is usually the most reliable and has the most recent updates. We also would like to provide data for regions and nations around the world instead of just the United States.With further work (and publicly available data), Cov - Tell will be able to provide crucial information, such as nearby hospital capacities.
References
References
