News Process Flow
Identify the Country Name
First step to get the news is Identify the Country name from the Human Raw Speech, to do this getCountryName flow is triggered.
getCountryName uses pycountry package to get the list of countries and thereafter check this list against the rawspeech,
If there's a perfect match then country name gets identified
In case no country is identified then country name is defaulted to human's default_country parameter.
Identify the Country Code
Once Country Name is Identified, Aryan needs to get the Country Code, Example: "US" being country Code for United States, While "IN" being for India. This is needed to pass the country code for the requested news country in the News API Call.
getCountryCode flow does this work for Aryan, Attributes for a country are identified and thereafter alpha_2 attribute is used to get the countrycode.
Get News For the Country Code
API calls are made to NewsApi along with the country code and Aryan's API key to Search the News. Response is captured in JSON format. Below is the snippet which does this for Aryan and Arya.
Parse the News Title and Description
Once Aryan has the news dump in JSON format, Next step is to parse the JSON to get the title and description of the news article.
Once captured, Top 5 News Headlines are provided to the human after sleep of 2 sec between each news.
Last updated
Was this helpful?