Hello guys. Welcome to the 34th session of using Microsoft mood framework and cognitive services tutorials for beginners. In this session we will learn how to use news api.js API to retrieve news as per user entity in a trance and create a car. Let us switch to the studio. Here I have already created a new helper class using which will retrieve data and create a hero card. Here are model classes that require to retrieve data from API's.
I have created it from response generated by this API. Each response contains multiple articles. And each article has a source author, title, description, URL, image URL, publisher. And here is a method in which I'm generating attachment from New Article, which includes title, subtitle, image and button and create a method which takes contacts key and an integer value that indicates maximum cost to be displayed in this message. Use make message method to create a new message from context. Change Layout to carousel, generate URL for APA and describe it using the client and then deserialize it to news response.
After this, we are a look through and add each attachment to this message. In case of exception second error message to text and return this message. This record is same as above one, just add source name in the parameter and based on these generate URL for APA again same for this method to here I'm retrieving news based on the query that you sent us. Let's update our Lewis dialogue. So that integrates a result of this hyper First of all, add this hyper namespace. Create a static variable that holds a PhD in displaying data, use get headlines method, pass context T and number of cards.
In sources intend to use get news from source method. Past context key and Sozzani saving topical intent you use get news for topic method. Here pass query that uses under let's say we can run it create a new conversation, let Assange display only 10 cards. Here we got a look at containing 10 attachments. Each of them includes an image and link to the page. Letter sign display only two cards.
Here we got only two attachments. So it works as per our expectations. Now, I am going to return data based on the sources. So right show news from DC that all news is retrieved from TechCrunch that is try query based on topic to some recent news of Microsoft Hear all news are related to Microsoft. And now saying trading off Facebook. It includes all research related to Facebook.
Here is a first note that we have created which performs some real life operation. Let's see what we have learned in this session. Here we have used news API helper and obtain a car from it. We have passed contracts to static methods of this class, in which we have created a new message from context and we retrieve data from APA. And we also created attachments based on the response we caught and we return it at the end. Thanks for watching this video.
If you have any doubts, feel free to contact me Have a nice day.