Name: watson-discovery-news
Owner: International Business Machines
Description: A Node.js web app that uses the Watson Discovery News service to query and view the latest trending news items.
Created: 2017-06-15 23:00:02.0
Updated: 2018-05-14 02:19:49.0
Pushed: 2018-04-27 15:05:11.0
Homepage: https://developer.ibm.com/code/patterns/create-a-cognitive-news-search-app/
Size: 77067
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
In this Code Pattern, we will build a Node.js web application that will use the Watson Discovery Service to access Watson Discovery News.
Watson Discovery News is a default data collection that is associated with the Watson Discovery Service. It is a dataset of primarily English language news sources that is updated continuously, with approximately 300,000 new articles and blogs added daily.
This Code Pattern will demonstrate two use cases for accessing Watson Discovery News:
Trending Topics in the News - Identify popular topics over the past 24 hours. Topics can be general, or for a specific industry or category.
Search - Query for the most relevant new articles about a specific topic or subject. Results will include enrichment data, such as article summary text and sentiment analysis.
Optionally included will be examples of how to:
Build a RSS News Feed generator to push Trending Topic news to your favorite RSS reader.
Build a SlackBot to access the Search feature from Slack.
Use the Deploy to IBM Cloud
button OR create the services and run locally.
Press the above Deploy to IBM Cloud
button and then click on Deploy
.
In Toolchains, click on Delivery Pipeline to watch while the app is deployed. Once deployed, the app can be viewed by clicking 'View app'.
watson-discovery-news
with a unique suffix. The following services are created:NOTE: These steps are only needed when running locally instead of using the
Deploy to IBM Cloud
button.
Clone the watson-discovery-news
locally. In a terminal, run:
t clone https://github.com/ibm/watson-discovery-news
Create the following service:
Fill in name you want to give to your service and click Create.
After the service is created, click on Service credentials and then click on View Credentials. Save these credentials as they will be needed when configuring the app.
To integrate a new Slack Bot into your existing Slack team, navigate to https://my.slack.com/services/new/bot. Enter a username for the bot and click Add bot integration.
Once created, save the API Token that is generated.
If you used Deploy to IBM Cloud
, most of the setup is automatic, but not quite all of it. We have to update a few environment variables.
In the IBM Cloud dashboard find the App that was created. Click on Runtime
on the menu and navigate to the Environment variables
tab.
Update the following environment variable:
SLACK_BOT_TOKEN
to the token you saved previouslySave the new value and restart the application, watch the logs for errors.
yarn
. This will install of the node modules specified in package.json
rn
yarn bootstrap
to copy the .env.sample
to .env
rn bootstrap
.env
file and enter the Watson Discovery credentials and Slack Bot Token saved in previous stepsyarn start
. If you are developing and making changes to the app and would like the server to restart every time then run yarn start:watch
rn start
http://localhost:{PORT}
, where PORT is the value specified in .env
(default is 3000)On the Trending News Panel, click the RSS Feed button to launch a new tab in your browser. Cut and paste the tab URL into your favorite RSS Reader. If your RSS Feed Reader supports push notifications you can get alerted when trending topics change along with a news article for that topic.
Since RSS feed is a standard way to consume constantly changing data such as news, we can use the RSS feeds we generated to also post news articles to your organizations slack channel to track trends in your industry, or consume the feed to generate a daily digest of news and email in the morning. Other uses may include automatically posting tweets to a Twitter account on news articles on trending topics using a service called IFTTT.
NOTE: This only needs to be set if the application is running locally.
The credentials for the IBM Cloud services (Discovery), can be found in the Services
menu in IBM Cloud, and selecting the Service Credentials
option.
tson Discovery
OVERY_USERNAME=<add_discovery_username>
OVERY_PASSWORD=<add_discovery_password>
ack
K_BOT_TOKEN=<add_slack_bot_token>
If the port is unavailable, you will see the following error:
r: listen EADDRINUSE :::{port}