IBM/watson-discovery-news

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

Query Watson Discovery News using the Watson Discovery Service

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:

Optionally included will be examples of how to:

Flow
  1. The user interacts with the Watson Discovery News Server via the app UI.
  2. User input is processed and routed to the Watson Discovery News Server.
  3. The Watson Discovery News Server sends user requests to the Watson Discovery Service.
  4. The Watson Discovery Service queries the Watson News Collection.
  5. The Watson Discovery Service sends news articles to the RSS Reader.
  6. The Watson Discovery Service responds to Slack search requests.

Included components

Featured technologies

Watch the Video

Steps

Use the Deploy to IBM Cloud button OR create the services and run locally.

Deploy to IBM Cloud

Deploy to IBM Cloud

  1. Press the above Deploy to IBM Cloud button and then click on Deploy.

  2. In Toolchains, click on Delivery Pipeline to watch while the app is deployed. Once deployed, the app can be viewed by clicking 'View app'.

  1. To see the app and services created and configured for this Code Pattern, use the IBM Cloud dashboard. The app is named watson-discovery-news with a unique suffix. The following services are created:
    • discovery-news-service
Run locally

NOTE: These steps are only needed when running locally instead of using the Deploy to IBM Cloud button.

  1. Clone the repo
  2. Create Watson Services with IBM Cloud
  3. Configure Watson Discovery
  4. Configure Slack
  5. Run the application
1. Clone the repo

Clone the watson-discovery-news locally. In a terminal, run:

t clone https://github.com/ibm/watson-discovery-news
2. Create Watson Services with IBM Cloud

Create the following service:

3. Configure Watson Discovery

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.

4. Configure Slack

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.

5. Run the application
If you used the Deploy to IBM Cloud button…

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:

Save the new value and restart the application, watch the logs for errors.

If you decided to run the app locally…
  1. Install Node.js and Yarn
  2. Install all of the dependencies by running yarn. This will install of the node modules specified in package.json
    rn
    
  3. Run yarn bootstrap to copy the .env.sample to .env
    rn bootstrap
    
  4. Edit the .env file and enter the Watson Discovery credentials and Slack Bot Token saved in previous steps
  5. Start the app by running yarn 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
    
  6. Open a browser and go to http://localhost:{PORT}, where PORT is the value specified in .env (default is 3000)

Sample output

Trending Topics RSS Feed

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.

 

Search from Slack

Troubleshooting

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}

Links

Learn more

License

Apache 2.0


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.