Skip to content

HAC-2020/X-A-4

Repository files navigation

Linux Live Dashboard Twitter Bot

Covid MentAid logo

Covid MentAid uses various IBM Technologies to analyze sentiment of the tweets of the public from all over the world during the covid19 Pandemic. The resulting analysis is presented in a Live web-framework (dashboard) as a series of graphs and charts and a Twitter bot which replies to people’s tweet which indicates fear, sadness, scared with funny memes/gifs/motivating pics from Reddit.

Team Name: - X Æ A-4

Get Started

  1. Short description
  2. Youtube video
  3. PPT
  4. Live App Link
  5. Flow of the Project
  6. Included components
  7. Featured technologies
  8. Steps to run the Dashboard (UBUNTU-Angular)
  9. Steps to run the Twitter Reddit Bot (Python)
  10. Results
  11. Contributors

Short description

What's the problem?

COVID-19 outbreak was first reported in Wuhan, China, and has spread to more than 50 countries. WHO declared COVID-19 as a Public Health Emergency of International Concern (PHEIC) on 30 January 2020. Currently, people are staying inside their homes for 4 months for self-quarantine purposes. This has led to a sharp increase in mental health problems and suicide rates all across the globe.

Blog

The idea

In this project, our server application subscribes to a LIVE Twitter feed with hashtags of "Covid19". Each tweet received will be analyzed for emotional tone and sentiment, and the intent of the tweet will be determined by the Watson Assistant service. All data is stored in a Cloudant database. The resulting analysis is presented in a web-framework (dashboard) as a series of graphs and charts.

In addition to this, we have a Twitter Bot which replies to people’s tweets which indicates fear, sadness, scared with funny memes/gifs/motivating lines and a hotline for suicide help based on their geo-location supplied by twitter API.

Youtube

Watch the video

Power Point Presentation

PPT

Live app link

Note: - The link may or may not be active. We are using the free plan of IBM cloud service and as this project takes LIVE tweets this requires us to change the api credentials after certain period of time based on the number of tweets stored in the cloudant.

If you want to see the live demo, refer the youtube link given above or contact us to on the website at 2018.abhay.gupta@ves.ac.in

Dashboard Link

Flow

  1. Tweets are pushed out by Twitter.
  2. The Sentiment Analysis of COVID-19 Tweets app processes the tweet.
  3. The Watson Tone Analyzer Service performs analysis of sentiment and emotional tone.
  4. The Watson Natural Language Understanding Service pulls out keywords and entities.
  5. The Watson Assistant Service extracts the intents (verbs) from the tweets.
  6. Tweets and metadata are stored in Cloudant
  7. The dashboard displays charts and graphs as well as the tweets.

Included components

  • Watson Assistant: Watson Assistant is a robust platform that allows developers and non-technical users to collaborate on building conversational AI solution.
  • Watson Tone Analyzer: Uses linguistic analysis to detect communication tones in written text.
  • Watson Natural Language Understanding: Natural language processing for advanced text analysis.
  • IBM Cloudant: A managed NoSQL database service that moves application data closer to all the places it needs to be — for uninterrupted data access, offline or on.
  • Cloud Foundry: Build, deploy, and run applications on an open source cloud platform.

Featured technologies

  • Artificial Intelligence: Artificial intelligence can be applied to disparate solution spaces to deliver disruptive technologies.
  • Databases: Repository for storing and managing collections of data.
  • Angular: A framework to build UI for mobile and desktop application.
  • Node.js: An open-source JavaScript run-time environment for executing server-side JavaScript code.
  • Express: Fast, unopinionated, minimalist web framework for Node.js

Steps for dashboard

We can deploy the code to IBM Cloud (or run the code locally, there will be one more step to configure the credentials locally.)

  1. Install Dependencies
  2. Twitter Requirements
  3. Create Watson services with IBM Cloud
  4. Import the Assistant workspace
  5. Configure credentials
  6. Run the application

1. Install dependencies

The application requires the following software to be installed locally.

  1. Node (6.9+): Application runtime environment, download and install the package.
  2. Angular CLI (6.1.1): A CLI for Angular applications, installed with: npm install -g @angular/cli.
  3. Angular (6.1.0): Angular will be added as a dependency of client in package.json when setting up client using Angular cli.
  4. Express (4.16.3): Express will be added as a dependency in package.json for server.

If you have Angular CLI already installed. Please read the upgrade instructions for Angular CLI when you upgrade the software.

Run the following command, from the application folder, to install both the client and server dependencies.

$ npm run app-install

2. Twitter requirements

To subscribe to Tweets from a specific handle or hashtag in this application, it is required to create a Twitter account and a Twitter application. The Twitter account will be used as the account that receives the messages from other Twitter users as well as the owner of the application, required by Twitter, to receive Tweets.

  • You can create a normal Twitter account on Twitter or use an existing account. It is required to provide a unique email id that isn't already associated with an existing Twitter account as well as a phone number to verify the account.
  • Once you have the Twitter account created and verified, log in to Twitter Dev and create an application.
  • Select the Keys and Access Tokens tab and generate a Consumer Key and Secret. Keep this page open as you will need to use these tokens into setup procedure in the application later on.

3. Create Watson services with IBM Cloud

Either Setup the IBM Cloud Deployment or Setup Local Deployment.

Setup local Deployment

Create the IBM Cloud services and configure them to use on a locally running server app.

If you do not already have a IBM Cloud account, signup for IBM Cloud. Create the following services:

NOTE: When provisioning Cloudant, for Available authentication methods choose Use both legacy credentials and IAM

4. Import the Watson Assistant skill

  • Find the Assistant service in your IBM Cloud Dashboard.
  • Click on the service and then click on Launch tool.
  • Go to the Skills tab.
  • Click Create new
  • Click the Import skill tab.
  • Click Choose JSON file, and upload this. the workspace.json file in
  • Select Everything and click Import.

To find the WORKSPACE_ID for Watson Assistant:

  • Go back to the Skills tab.
  • Click on the three dots in the upper right-hand corner of the app and select View API Details.
  • Copy the Workspace ID GUID.

5. Configure credentials

Fill in the requried details needed in the server/env.sample

Change it's name to ".env"

This is to be done before executing on the IBM server.

The .env file is where all the parameters like credentials, log settings and other constants required by this application is kept.

Configure service credentials

The credentials for IBM Cloud services (Tone Analyzer, Natural Language Understanding, and Cloudant), can be found in the Services menu in IBM Cloud, by selecting the Service Credentials option for each service.

NOTE: When provisioning Cloudant, for Available authentication methods choose Use both legacy credentials and IAM

From the root of the project, go to server folder (cd server) and

Add all the credentials that you have saved from creating the services, as explained earlier, in the .env file.

6. Run the application

Either Run the app on IBM Cloud or Run the app locally.

Running the app on IBM Cloud

  1. Compile the Angular client code and Express server code using the following command. This creates a dist folder in your project root directory and copies the compile code and necessary files to be deployed to IBM cloud.
$ npm run build
  1. Connect to IBM Cloud in the command line tool and follow the prompts to log in
$ ibmcloud cf login -a https://api.ng.bluemix.net

Make sure you set the target and space correctly using ibmcloud target -o <target> -s <space>

  1. Push the app to IBM Cloud.
$ ibmcloud app push
  1. The application should now be running on IBM Cloud and listening to Tweets. You can get the application URL by going to Cloud Foundry Applications section of IBM cloud dashboard. Click the name of the application you just pushed and clikc Visit App URL to access the application.

Running the app locally

Once all the credentials are in place, the application can be started with:

$ npm run start

The server runs on port 3000 and the client runs on port 4200. You can access the UI by accessing the following URL in the browser:

http://localhost:4200

Steps to run the twitter Bot

What our bot actually does?

  • Our bot replies to original tweets of user using a particular hashtag(eg: #Covid19) which it detects sad using the IBM watson tone analyzer with a motivation pic using the reddit api from the subreddit MotivationalPics.
  • Twitter Handle of the bot: - profile

Note: - Navigate to the TwitterBot-final folder.

Note: - Python 3 is used here.

1. Adding the required Keys to keys.py file

  • Twitter Keys: Use the previously created twitter dev acc's keys or make new one and use them to fill the consumer_ket, consumer_secret, access_token, access_token_secret fields.
  • Ibm Keys: Create a new tone analyzer service using a new IBM cloud account and use these to fill ibm_key, ibm_url fields.
  • Reddit Keys: Create a reddit api and use the given keys to fill the C_id, C_secret, User_agent, Uname, Password. Note: User_agent: can be any string, it's a description of ur app,, Uname: username use to login on reddit,, Password: main password of your reddit account, C_id is the first yellow box and C_secret is the second yellow box as shown: -

2. Running the py files: -

  • Use pip install -r requirements.txt to install all the dependecies.
  • run the tempBot.py program to start the bot.

Note: - To change the hashtag it follows, change the hashtag on line number 46 in tempBot.py

Note: - To change subreddit from which the reddit bot gives posts, change the name on line number 20 in reddit_twitter_bot.py

Note: - To host the bot to run 24/7 we reccomend python anywhere (use pip3 to install and python3 on it's console to run the files.

Results

You will see informations about Tweets:

as well as Classification of live tweets, Sentiment over time, Emotional Tone over time, and Keywords mentioned:

Twitter bot replying to sad/depressed tweets with motivational pics/quotes:

Contributors

Jay Jhaveri: https://github.com/JayJhaveri1906

Prem Chhabria: https://github.com/premchhabria

Abhay Gupta: https://github.com/abhay8463

Neeraj Ochani: https://github.com/neeraj0008

Prasad Govekar: https://github.com/govekarmohit