Industrial Training Report: " Twitter Bot "

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

INDUSTRIAL TRAINING REPORT

“ TWITTER BOT ”

Submitted in partial fulfillment of the


Requirements for the award of

Degree of Bachelor of Technology in Computer Science Engineering

Submitted by:
SOURAB SHARMA
1602230019

SUBMITTED TO:

Department of Computer Science & Engineering


HIMALAYAN INSTITUTE OF ENGINEERING AND TECHNOLOGY

Himachal Pradesh Technical University, Hamirpur (HP)


CANDIDATE’S DECLARATION

I hereby declare that the Industrial Training Report entitled ("Twitter Bot") is an authentic record of
my own work as requirements of 6-weeks Industrial Training during the period from 17th of june to
1st of August 2019 for the award of degree of B.Tech. (Computer Science & Engineering),
Himalayan Institute of Engineering Technology, under the guidance of Mr. Abinav Sharma.

(Signature of student)
SOURAB SHARMA
Date:
1602230019

Certified that the above statement made by the student is correct to the best of our knowledge and
belief.

Signatures Examined

by:

1. 2. 3. 4.

Head of Department (Signature and Seal)


ACKNOWLEDGEMENT

The present Industrial Training Report is the several days study of the various aspects of the project
development. During this the effort in the present study, we have received a great amount of help
from our Chairman Mr. Rajnish Bansal, HIMALAYAN INSTITUTE OF ENGINEERING &
TECHNOLOGY,KALA AMB,HP, which we wish to acknowledge and thank from depth of our
hearts.
I express my sincere thanks to our Academic Dean Mr Vikas Solanki , for encouragement and
suggestions to the successful completion of my Industrial Training.
My sincere thanks to Mr. Praveen Rajput Asst. Professor, Head of the Department in CSE whose
motivation and constant encouragement has led to pursue training in the field of software
development.
My Parents have put myself ahead of themselves. Because of their hard work and dedication, I have
had opportunities beyond my wildest dreams. My heartfelt thanks to them for giving me all I ever
needed to be successful student and individual.
Finally I express my thanks to all my other professors, classmates, friends, neighbors and my family
members who helped me for the completion of my project and without infinite love and patience this
would never have been possible.

SOURAB SHARMA

1602230019

COMPANY PROFILE
About Window-IT:
WindowIT is an ISO 9001-2008 certified IT Training Organization run by CEO/Founder MR.
GUPTA and highly technical qualified professionals associated with various Top Level MNCs having
experience in various kinds of technologies. WindowIT is a Best IT Company and Training providers
in Chandigarh Mohali, established on 07 June and approved from Government of India Ministry of
Corporate Affairs. We are counted as top leading IT and web Solutions Company in Mohali and
Chandigarh.
Services Division:
We also provide gamut of powerful, highly usable services to solve business problems, attract users,
and reinforce your brand. Our wide range of services encompasses Web Design, Web Development,
Graphic Design, Digital Marketing and Mobile App Development. WindowIT have an exclusive,
adept and skilled team for mobile application development, web development and designing.From
logo development, packaging, environmental design, annual reports to national campaigns- our focus
is to ensure the audience is listening. Our skilled personnel craft innovative visual stories that attract
your viewers& create long term success. We also have wealth of experience in Content Management
System, Website Development, Web Portal Development, Website Maintenance, PHP Web
Development, .NET Web Development, Joomla Web Development, WordPress Web Development,
Website Migration & Porting, Website Reengineering, also including e-Learning, e-Commerce,
Entertainment, Finance, and many more Websites.

Industrial Training Division:

We are specialized in providing best-in-class industrial training and certifications on all popular fields
like Android, Python, PHP, SEO, Online bidding, PPC, Web Designing, CMS, C/ C ++, Networking,
Software Testing, Cloud Computing and MBA training. Our customized training courses and
programs are for both the individuals as well as for corporate. We also undertake customization of the
courses as per client requirement.We have a team of Certified Trainers with minimum 08+ years of
Industry background. WindowIT provide short term as well as long term training courses. We have a
three dimensions training, development & consultancy.

ⅰⅰ
LIST OF FIGURES

Figure 1.a: Bot tweepy ----------------------------------------------- 02


Figure 2.a: Python Download--------------------------------------- 08
Figure 2.b: Processor Selection(32/64 bit)-------------------------08
Figure 2.c: Finished installation------------------------------------- 09
Figure 2.d: Python Code Execution-------------------------------- 10
Figure 2.e: Python File Conversion---------------------------------10
Figure 2.f: Tkinter GUI---------------------------------------------- 11
Figure 2.g: Tkinter Dialog Box-------------------------------------12
Figure 3.a: Bak-Bak Twitter bot------------------------------------18
Figure 3.b: Twitter API Codes--------------------------------------19
Figure 3.c: Internal IDE command GUI of Twitter Bot---------19
Figure 3.d: Python IDE successful execution---------------------20


LIST OF TABLES

Table 2.1 Operator & Descriptions------------------------------------------------------------12


CONTENTS
Chapter No. TITLE Page no.

 Acknowledgement ⅰ
 Company Profile ⅰⅰ

 List Of Figures ⅲ

 List Of Tables ⅳ

1] Introduction 01

1.1] Chatbot and Machine learning 01

1.2] Artificial Intelligence 03

1.3] AI applications 05

2] Tools & Technology Used 06

2.1] Python 06

2.2] History 07

2.3] Running Python 09

2.4]Tkinter GUI 11

3] Snapshots / End User View 18

4] Results and Discussion 21

4.1] Introduction 21

4.2] Bot Detection 22

4.3] 2016 U.S. General Election and Twitter Bots 24

4.4] Current State Of the Art Bots 24


4.5] Experimenting with a Bot 25

5] Conclusion and Future Scope


5.1] Bots are taking over 27

5.2] Bots vs Apps 27

5.3] Microsoft 28

5.4] The Pitfall 29




6] References 31
CHAPTER-1

INTRODUCTION

A chatbot is a computer program that can converse with humans using artificial intelligence in
messaging platforms. The goal of the project is to add a chatbot feature and API for Yioop.
discussion groups, blogs, wikis etc. Yioop provides all the basic features of web search portal. It has
its own account management system with the ability to set up groups that have discussions boards.
Groups are collections of users that have access to a group feed. The user who creates a group is set
as the initial group owner. Posts are grouped by thread in a group containing the most recent activity
at the top. The chatbot API for Yioop will allow developers to create new chatbots, powered by rules
or artificial intelligence, that can interact like a human with users in a groups feed page. Example
chatbots that can be developed with this API is weather chatbots or book flight chatbots. Over past
few years, messaging applications have become more popular than Social networking sites. People
are using messaging applications these days such as Facebook Messenger, Skype, Viber, Telegram,
Slack etc. This is making other businesses available on messaging platforms leads to proactive
interaction with users about their products. To interact on such messaging platforms with many
users, the businesses can write a computer program that can converse like a human which is called a
chatbot.
Chatbots come in two kinds:
• Limited set of rules

• Machine learning

Chatbot that uses limited set of rules This kind of bots are very limited to set of texts or commands.
They have ability to respond only to those texts or commands. If user asks something different or
other than the set of texts or commands which are defined to the bot, it would not respond as desired
since it does not understand or it has not trained what user asked. These bots are not very smart when
compared to other kind of bots.

1.1 Chatbot and Machine learning


Machine learning chatbots works using artificial intelligence. User need not to be more specific
while talking with a bot because it can understand the natural language, not only commands. This
kind of bots get continuously better or smarter as it learns from past conversations it had with people.
Here is a simple example which illustrate how they work. The following is a conversation between a
human and a chatbot: Human: “I need a flight from San Jose to New York.” Bot: “Sure! When would
you

Figure 1.a Bot tweepy


like to travel?” Human: “From Dec 20, 2016 to Jan 28, 2017.” Bot: “Great! Looking for flights.” In
order to achieve the ultimate goal, I have taken an iterative approach and divided my work into four
major deliverables. These deliverables not only helped me in understanding the code structure of
Yioop but also enhances Yioop’s functionality. In the rest of the report, I will be discussing about the
four deliverables. To understand more on chatbot service, I had implemented a Facebook Messenger
Weather Bot in deliverable 1, which is discussed in next section. The purpose of deliverable 2 is to
introduce chatbots to the Yioop. I have added Bot Configuration settings which is used to add bot
users in Yioop. In the next deliverable, I have added a functionality where the user will be able to
call bots in a group thread. Activation of bots will happen by calling respective callback URL which
is already configured .
I have implemented a Twitter Messenger Bot to get an overview of how chatbot is build. During this
implementation, I understood the flow of control for a chatbot service with other services which is
explained below. In order to create a Twitter Messenger Bot, a developer needs to be authenticated
and approved by Twitter to converse with the public and the web server for security reasons. For a
Twitter Messenger Bot, I have created a simple web application using Pythin IDE by installing the
necessary dependencies using pip. I ran this locally.
2
This launched a Forwarding URL to the local running server, that means any requests to Forwarding
URL will hit the locally running server. This url is used as a Callback URL in Facebook App which
will be explained further. To set up the Facebook App, I have created a Twitter Page and Twitter
App using my Twitter account. While setting up a Webhook in the app settings, I have given the
Forwarding URL as Callback URL and added code for verification.The access token in page settings
is stored as environment variable as it will be used in integration. It directly take my instructions
using a GUI implemented through Tkinter and changes are reflected online, everytime I run the code.

1.2 Artificial Intelligence


AI was coined by John McCarthy, an American computer scientist, in 1956 at The Dartmouth
Conference where the discipline was born. Today, it is an umbrella term that encompasses everything
from robotic process automation to actual robotics.
It has gained prominence recently due, in part, to big data, or the increase in speed, size and variety
of data businesses are now collecting. AI can perform tasks such as identifying patterns in the data
more efficiently than humans, enabling businesses to gain more insight out of their data.

Types of artificial intelligence


AI can be categorized in any number of ways, but here are two examples. The first classifies AI
systems as either weak AI or strong AI. Weak AI, also known as narrow AI, is an AI system that is
designed and trained for a particular task. Virtual personal assistants, such as Apple's Siri, are a form
of weak AI. Strong AI, also known as artificial general intelligence, is an AI system with generalized
human cognitive abilities so that when presented with an unfamiliar task, it has enough intelligence
to find a solution. The Turing Test, developed by mathematician Alan Turing in 1950, is a method
used to determine if a computer can actually think like a human, although the method is
controversial.He categorizes AI into four types, from the kind of AI systems that exist today to
sentient systems, which do not yet exist. His categories are as follows:
Type 1: Reactive machines. An example is Deep Blue, the IBM chess program that beat Garry
Kasparov in the 1990s. Deep Blue can identify pieces on the chess board and make predictions, but it
has no memory and cannot use past experiences to inform future ones. It analyzes possible moves --
its own and its opponent -- and chooses the most strategic move. Deep Blue and Google's AlphaGO
were designed for narrow purposes and cannot easily be applied to another situation.

3
Type 2: Limited memory. These AI systems can use past experiences to inform future decisions.
Some of the decisionmaking functions in autonomous vehicles have been designed this way.
Observations used to inform actions happening in the not-so-distant future, such as a car that has
changed lanes. These observations are not stored permanently.

Type 3: Theory of mind. This is a psychology term. It refers to the understanding that others have
their own beliefs, desires and intentions that impact the decisions they make. This kind of AI does
not yet exist.

Type 4: Self-awareness. In this category, AI systems have a sense of self, have consciousness.
Machines with self-awareness understand their current state and can use the information to infer what
others are feeling.
This type of AI does not yet exist.

Examples of AI technology Automation is the process of making a system or process function


automatically. Robotic process automation, for example, can be programmed to perform high-
volume, repeatable tasks normally performed by humans. RPA is different from IT automation in
that it can adapt to changing circumstances. Machine learning is the science of getting a computer
to act without programming. Deep learning is a subset of machine learning that, in very simple terms,
can be thought of as the automation of predictive analytics. There are three types of machine learning
algorithms: supervised learning, in which data sets are labeled so that patterns can be detected and
used to label new data sets; unsupervised learning, in which data sets aren't labeled and are sorted
according to similarities or differences; and reinforcement learning, in which data sets aren't labeled
but, after performing an action or several actions, the AI system is given feedback.It is used in a
range of applications from signature identification to medical image analysis. Computer vision,
which is focused on machine-based image processing, is often conflated with machine vision.
Natural language processing (NLP) is the processing of human -- and not computer -- language by a
computer program. . Automation of job positions has also become a talking point among academics
and IT consultancies such as Gartner and Forrester. Current approaches to NLP are based on machine
learning. NLP tasks include text translation, sentiment analysis and speech recognition. Pattern
recognition is a branch of machine learning that focuses on identifying patterns in data. The term,
Robotics is a field of engineering focused on the design and manufacturing of robots. Robots are
4
often used to perform tasks that are difficult for humans to perform or perform consistently. They are
used in assembly lines for car production or by NASA to move large objects in space. More recently,
researchers are using machine learning to build robots that can interact in social settings.

1.3 AI applications
AI in healthcare. The biggest bets are on improving patient outcomes and reducing costs. Companies
are applying machine learning to make better and faster diagnoses than humans. One of the best
known healthcare technologies is IBM Watson. It understands natural language and is capable of
responding to questions asked of it. The system mines patient data and other available data sources to
form a hypothesis, which it then presents with a confidence scoring schema. Other AI applications
include chatbots, a computer program used online to answer questions and assist customers, to help
schedule follow-up appointments or aiding patients through the billing process, and virtual health
assistants that provide basic medical feedback. AI in business. Robotic process automation is being
applied to highly repetitive tasks normally performed by humans. Machine learning algorithms are
being integrated into analytics and CRM platforms to uncover information on how to better serve
customers. Chatbots have been incorporated into websites to provide immediate service to customers.
Automation of job positions has also become a talking point among academics and IT consultancies
such as Gartner and Forrester. AI in education. AI can automate grading, giving educators more time.
AI can assess students and adapt to their needs, helping them work at their own pace. AI tutors can
provide additional support to students, ensuring they stay on track. AI could change where and how
students learn, perhaps even replacing some teachers. AI in finance. AI applied to personal finance
applications, such as Mint or Turbo Tax, is upending financial institutions. Applications such as
these could collect personal data and provide financial advice. Other programs, IBM Watson being
one, have been applied to the process of buying a home. Today, software performs much of the
trading on Wall Street. AI in law. The discovery process, sifting through of documents, in law is
often overwhelming for humans. Automating this process is a better use of time and a more efficient
process. Startups are also building question-and-answer computer assistants that can sift
programmed-to-answer questions by examining the taxonomy and ontology associated with a
database. AI in manufacturing. This is an area that has been at the forefront of incorporating robots
into the workflow. Industrial robots used to perform single tasks and were separated from human
workers, but as the technology advanced that changed.

5
CHAPTER-2

TOOLS & TECHNOLOGY USED

2.1 Python
Python is a widely used high-level, general-purpose, interpreted, dynamic programming language. Its
design philosophy emphasizes code readability, and its syntax allows programmers to express
concepts in fewer lines of code than would be possible in languages such as C++ or Java. The
language provides constructs intended to enable clear programs on both a small and large scale.

Python supports multiple programming paradigms, including object-oriented, imperative and


functional programming or procedural styles. It features a dynamic type system and automatic
memory management and has a large and comprehensive standard library. Python interpreters are
available for installation on many operating systems, allowing Python code execution on a wide
variety of systems.

Scripting Language
A scripting or script language is a programming language that supports scripts, programs written for
a special run-time environment that automate the execution of tasks that could alternatively be
executed one-by-one by a human operator.

Scripting languages are often interpreted (rather than compiled). Primitives are usually the
elementary tasks or API calls, and the language allows them to be combined into more complex
programs. Environments that can be automated through scripting include software applications, web
pages within a web browser, the shells of operating systems (OS), embedded systems, as well as
numerous games.

A scripting language can be viewed as a domain-specific language for a particular environment; in


the case of scripting an application, this is also known as an extension language. Scripting languages
are also sometimes referred to as very high-level programming languages, as they operate at a high
level of abstraction, or as control languages.

Object Oriented Programming Language


Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects",
which may contain data, in the form of fields, often known as attributes; and code, in the form of
procedures, often known as methods. A distinguishing feature of objects is that an object's
procedures can access and often modify the data fields of the object with which they are associated
In OO programming, computer programs are designed by making them out of objects that interact
with one another. There is significant diversity in objectoriented programming, but most popular
languages are class-based, meaning that objects are instances of classes, which typically also
determines their type.

2.2 History
Python was conceived in the late 1980s, and its implementation was started in December 1989 by
Guido van Rossum at CWI in the Netherlands as a successor to the ABC language (itself inspired by
SETL) capable of exception handling and interfacing with the Amoeba operating system. Van
Rossum is Python's principal author, and his continuing central role in deciding the direction of
Python is reflected in the title given to him by the Python community, benevolent dictator for life
(BDFL).

“Python is an experiment in how much freedom programmers need. Too much freedom and nobody
can read another's code; too little and expressiveness is endangered.”

- Guido van Rossum

Behind The Scene of Python

About the origin of Python, Van Rossum wrote in 1996:

Over six years ago, in December 1989, I was looking for a "hobby" programming project that would
keep me occupied during the week around Christmas. My office ... would be closed, but I had a
home Computer, and not much else on my hands. I decided to write an interpreter for the new
scripting language I had been thinking about lately: a descendant of ABC that would appeal to
Unix/C hackers. I chose Python as a working title for the project, being in a slightly irreverent mood
(and a big fan of Monty Python's Flying Circus).

Downloading Python
If you don’t already have a copy of Python installed on your computer, you will need to open up
your Internet browser and go to the Python download page (http://www.python.org/download/).

Now that you are on the download page, select which of the software builds you would like to
download. For the purposes of this article we will use the most up to date version available (Python
3.4.1).

7
Figure 2.a Python Download
Once you have clicked on that, you will be taken to a page with a description of all the new updates
and features of 3.4.1, however, you can always read that while the download is in process. Scroll to
the bottom of the page till you find the “Download” section and click on the link that says
“download page.”

Now you will scroll all the way to the bottom of the page and find the “Windows x86 MSI installer.”
If you want to download the 86-64 bit MSI, feel free to do so. We believe that even if you have a 64-
bit operating system installed on your computer, the 86-bit MSI is preferable. We say this because it
will still run well and sometimes, with the 64-bit architectures, some of the compiled binaries and
Python libraries don’t work well.

Figure 2.b Processor selection(32/64 bit)

8
2.3 Running Python
Once you have downloaded the Python MSI, simply navigate to the download location on your
computer, double clicking the file and pressing Run when the dialog box pops up. Now that you
have completed the installation process, click on “Finish.

Figure 2.c Finished Installation


Once the GUI is open, we will begin by using the simplest directive possible. This is the “print”
directive which simply prints whatever you tell it to, into a new line. Start by typing a print directive
like the one shown in the image below or copy and paste this text then press

“Enter”: print (“Congratulations on executing your first print directive!”)

With Python, you can build just about anything, from simple scripts to full applications. The Python
language, however, doesn’t come pre-installed with all of the fancy features you might want (or
require). When you need particular functionality, you can look toward Python packages. A package
structures Python modules, which contain pre-written code that other developers have created for
you. Modules are handy when you are looking for specific functionality.

You can use pip, Python’s package manager, to install and manage Python packages.

If your Python 2 version is greater than or equal to 2.7.9, no need to worry, you have pip pre-
installed!

9
You can use pip to install packages, like so:

pip install scrapy

Figure 2.d Python Code Execution

Python Code Execution

Python’s traditional runtime execution model: source code you type is translated to byte code, which
is then run by the Python Virtual Machine. Your code is automatically compiled, but then it is
interpreted.

Figure 2.e Python File Conversion

Byte code extension is .pyc (compiled python code)

10
2.4 Python Tkinter GUI

Fig2.f Tkinter GUI

Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast
and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the
Tk GUI toolkit.
Creating a GUI application using Tkinter is an easy task. All you need to do is perform the following
steps −
 Import the Tkinter module.
 Create the GUI application main window.
 Add one or more of the above-mentioned widgets to the GUI application.
 Enter the main event loop to take action against each event triggered by the user.
Example

#!/usr/bin/python

import tkinter
top = tkinter.Tk()
# Code to add widgets will go here...
top.mainloop()

11
This would create a following window −

Fig 2.g Tkinter Dialog Box


Tkinter Widgets
Tkinter provides various controls, such as buttons, labels and text boxes used in a GUI application.
These controls are commonly called widgets.
There are currently 15 types of widgets in Tkinter. We present these widgets as well as a brief
description in the following table –

Table 2.1 Operator & Descriptions

Operator & Description

Button
The Button widget is used to display buttons in your application.

Canvas
The Canvas widget is used to draw shapes, such as lines, ovals, polygons and
rectangles, in your application.

Checkbutton
The Checkbutton widget is used to display a number of options as checkboxes. The
user can select multiple options at a time.

12
Entry
The Entry widget is used to display a single-line text field for accepting values from a
user.

Frame
The Frame widget is used as a container widget to organize other widgets.

Label
The Label widget is used to provide a single-line caption for other widgets. It can
also contain images.

Listbox
The Listbox widget is used to provide a list of options to a user.

Menubutton
The Menubutton widget is used to display menus in your application.

Menu
The Menu widget is used to provide various commands to a user. These
commands are contained inside Menubutton.

Message
The Message widget is used to display multiline text fields for accepting values
from a user.

Radiobutton
The Radiobutton widget is used to display a number of options as radio buttons. The
user can select only one option at a time.

Scale
The Scale widget is used to provide a slider widget.

13
Scrollbar
The Scrollbar widget is used to add scrolling capability to various widgets, such as list
boxes.

Text
The Text widget is used to display text in multiple lines.

Toplevel
The Toplevel widget is used to provide a separate window container.

Spinbox
The Spinbox widget is a variant of the standard Tkinter Entry widget, which can be
used to select from a fixed number of values.

PanedWindow
A PanedWindow is a container widget that may contain any number of panes, arranged
horizontally or vertically.

LabelFrame
A labelframe is a simple container widget. Its primary purpose is to act as a spacer or
container for complex window layouts.

tkMessageBox
This module is used to display message boxes in your applications.

Geometry Management
All Tkinter widgets have access to specific geometry management methods, which have the purpose
of organizing widgets throughout the parent widget area. Tkinter exposes the following geometry
manager classes: pack, grid, and place.
 The pack() Method − This geometry manager organizes widgets in blocks before placing
them in the parent widget.

14
 The grid() Method − This geometry manager organizes widgets in a table-like structure in the
parent widget.
 The place() Method − This geometry manager organizes widgets by placing them in a
specific position in the parent widget.
2.5 Tweepy

Python is great language for all sorts of things. Very active developer community creates many
libraries which extend the language and make it easier to use various services. One of those libraries
is tweepy. Tweepy is open-sourced, hosted on GitHub and enables Python to communicate with
Twitter platform and use its API.

At the time of writing, the current version of tweepy is 1.13. It was released on January 17, and
offers various bug fixes and new functionality compared to the previous version. The 2.x version is
being developed but it is currently unstable so a huge majority of the users should use the regular
version.

Tweepy supports accessing Twitter via Basic Authentication and the newer method, OAuth. Twitter
has stopped accepting Basic Authentication so OAuth is now the only way to use the Twitter API.

Here is a sample of how to access the Twitter API using tweepy with OAuth:

import tweepy
# Consumer keys and access tokens, used for OAuth
consumer_key = '7EyzTcAkINVS3T2pb165'
consumer_secret = 'a44R7WvbMW7L8I656Y4l'
access_token = 'z00Xy9AkHwp8vSTJ04L0'
access_token_secret = 'A1cK98w2NXXaCWMqMW6p'

# OAuth process, using the keys and tokens


auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
# Creation of the actual interface, using authentication
15
api = tweepy.API(auth)

# Sample method, used to update a status


api.update_status('Hello Python Central!')

Tweepy provides access to the well documented Twitter API. With tweepy, it's possible to get any
object and use any method that the official Twitter API offers.

Main Model classes in the Twitter API are Tweets, Users, Entities and Places. Access to each returns
a JSON-formatted response and traversing through information is very easy in Python.

# Creates the user object. The me() method returns the user whose authentication keys were used.

user = api.me()

print('Name: ' + user.name)

print('Location: ' + user.location)

print('Friends: ' + str(user.friends_count))

Gives us the following output:

Name: Ahmet Novalic

Location: Gradacac,Bih

Friends: 59

To sum up, tweepy is a great open-source library which provides access to the Twitter API for
Python. Although the documentation for tweepy is a bit scarce and doesn't have many examples, the
fact that it heavily relies on the Twitter API, which has excellent documentation, makes it probably

16
the best Twitter library for Python, especially when considering the Streaming API support, which is
where tweepy excels. Other libraries like python-twitter provide many functions too, but the tweepy
has most active community and most commits to the code in the last year.

17
CHAPTER-3

SNAPSHOTS/END USER VIEW


With about 15% of Twitter being composed of bots, I wanted to try my hand at it. I googled how to
create a Twitter bot and was brought to a cleanly laid out web app. It allowed you to create a bot that
would like, follow, or retweet a tweet based on a keyword. The problem was that you could only
create one bot for one function.

Fig 3.a Bak Bak Twitter Bot

Twitter employs significant measures to aunthenticate and verify the login of it’s users by
Using 4 types of secret login codes.

Secrecy of these Login Credentials should be maintained and so are:

1. Consumer_key = 'consumer key'


2. Consumer_secret = 'consumer secrets'
3. Access_token = 'access token'
4. Access_token_secret = 'access token secret'
These login credentials can be generated only after Twitter provides Developer’s Access to the user
account.

Fig 3.b Twitter API codes

And the internal IDE terminal would be a simple Tkinter made GUI which looks like

Fig 3.c Internal IDE command GUI of Twitter Bot


19
Fig 3.d Python IDE successful execution

As soon as the above shown output is generated, the changes can be noticed instantly on Twitter
server.
At the time of execution at internal terminal a Subject Search Matter is chosen first on basis of which
a specific community or group of peoples are targeted with the Entered quantity,
The response field carries the Reply Quotes which needs to be forwarded to all the people concerned
with the principal subject matter.
After that all the four fields takes input either in ‘yes’ or ‘no’.
Each yes can trigger the Reply,Retweet or Favorite a specific content.

20
CHAPTER-4

RESULTS AND DISCUSSION


Enthusiasm for using Twitter as a source of data in the social sciences extends to measuring the
impact of research with Twitter data being a key component in the new altmetrics approach. In this
paper, we examine tweets containing links to research articles in the field of dentistry to assess the
extent to which tweeting about scientific papers signifies engagement with, attention to, or
consumption of scientific literature. The main goal is to better comprehend the role Twitter plays in
scholarly communication and the potential value of tweet counts as traces of broader engagement
with scientific literature. In particular, the pattern of tweeting to the top ten most tweeted scientific
dental articles and of tweeting by accounts is examined. The ideal that tweeting about scholarly
articles represents curating and informing about state-of-the-art appears not to be realized in practice.
We see much presumably human tweeting almost entirely mechanical and devoid of original
thought, no evidence of conversation, tweets generated by monomania, duplicate tweeting from
many accounts under centralized professional management and tweets generated by bots. Some
accounts exemplify the ideal, but they represent less than 10% of tweets. Therefore, any conclusions
drawn from twitter data is swamped by the mechanical nature of the bulk of tweeting behavior. In
light of these results, we discuss the compatibility of Twitter with the research enterprise as well as
some of the financial incentives behind these patterns.

4.1 Introduction

Twitter, though not the most successful social media company, has seen unique success in enabling
several public movements—the Arab spring, the Spanish 15M, Black Lives Matter and various mass
expressions of consumer anger over corporate missteps. Such high visibility social media activity
over the past decade combined with younger generations’ social media uptake has left more senior
professionals worried about being left behind. The professional literature has therefore seen a steady
stream of exhortations to join social media accompanied by suggested professional use cases.

The health professions have shown a genuine interest in the use of information technology to
improve health care . So it was not surprising to find doctors exhorting other doctors to join Twitter .
While voicing concerns with maintaining privacy and professionalism on social media, proponents
described largely idyllic scenarios emphasizing Twitter’s potential for aiding career development,
connectingwith colleagues, building relationships with patients , enabling virtual journal clubs and
scientific conferences, complementing traditional teaching methods, critically appraising and
reviewing research, or all of the above. Some have argued that Twitter promised to speed knowledge
transfer and bridge the communication gap between researchers and stakeholders leading others to
suggest strategies and tips to improve the dissemination of research findings, and to engage readers
to follow journals’ Twitter accounts.

4.2 Bot Detection


Recent research has shown significant success in the detection of social bots. While there are tools to
distinguish automated bots from regular user accounts, information about their strategies, biases and
influence on their target audience remains harder to obtain. To uncover such details, e.g., to
understand the role of bots in political campaigns, we address three questions: Can we describe the
behaviour of a bot (when and how a bot takes actions) by a set of understandable rules? How can we
express bias and influence? Can we extract such information automatically, from observations of a
bot? In this paper, we present an approach to reverse engineering the behaviour of Twitter bots to
create a visual model explaining their actions. We use machine learning to infer a set of simple and
general rules governing the behaviour of a bot. We propose the notion of differential sentiment
analysis to provide means of understanding the behaviour with respect to the topics on its network in
relation to both its sources of information (friends) and its target audience (followers). Respectively,
this provides insights into their bias and the influence aimed at their target audience. We evaluate our
approach using prototype bots we created and selected real Twitter bots. The results show that we are
successful in correctly describing the behaviour of the bots and potentially useful in understanding
their impact.

A new landscape of human communication is evolving. The Gutenberg press, where books could be
copied and printed more easily than previously, by monks hand-writing copies, changed society
drastically. Since this time, fax machines, computer and the internet have allowed rapid distribution
of communication and information. Social Media, including sites such as Twitter and Facebook, has
become a large part of many American’s lives with 67% of Americans stating they get news from
online social media sources. A fundamental idea behind social media is essentially
‘democratization’/decentralization of media where anyone can have an account and share their

22
opinions with friends, family or a wider audience of anyone who is interested. Websites such as
YouTube allow anyone to produce and widely disperse their content, removing some of the power of
traditional television networks. In October 2017, Twitter had nearly 330 million Active Users, and
Facebook has over 2 Billion Monthly active users. Facebook itself has recently had to grapple with
the issue of their effect on society, even asking themselves “Is Spending Time on Social Media Bad
for Us?” in December 2017.

The purpose of this discussion is to detail the phenomenon of ‘Twitter Bots’, so you can be aware of
how they manipulate the conversation on twitter, including promoting radical ideology and
undermining the democratic process and rational thoughts and arguments. Armed with this
information, you will be less susceptible to manipulation, and if you so desire, learn to implement
your own Twitter Bot to promote your own viewpoint.

A very interesting confluence of technology and social influence is through automated software
being implemented on social networks by mimicking, impersonating and/or influencing real-world
personalities or groups. Recent research conducted by the Pew Research Center founded that 66% of
all tweeted links came from the use of automated software, known as Twitter Bots.

A TwitterBot (or Twitter Bot) is a twitter account whose actions are automated through an exterior
software program. These automated actions include posting, liking, retweeting, following, messaging
or any combination of these actions specified by the user and on a user-defined schedule, with the
intent of engaging real twitter users and/or other bots to raise awareness around a brand, political
cause, or business. A New York Times article describes the prevalence of twitter Bots and famous
artists, musicians and business people and the effect that ‘purchasing followers’ can have on real
world careers and events.

Due to their outsized impact and ability to effect real-world events, such as their role in the 2016
U.S. Presidential election, significant research has been performed to aid in the identification of bots
and cyborgs on twitter, such as the Bot or Not/Botometer tool by researchers at Indiana University.
This research began in 2011, and at that time, bots were relatively easy to identify. Since these early
twitter bots, they have become more advanced and even use artificial intelligence to interact with
other twitter users.

23
4.3 2016 U.S. General Election and Twitter Bots

Since the election of 2016 which decided the U.S. Presidency for Donald Trump, significant research
and analysis has uncovered a coordinated effort by Russian-linked Twitter Bots to shaping public
opinion, and that 1 in 5 election-related tweets during this time are linked to bots, with pro-Trump
accounts outnumbering pro-Clinton accounts by 3-to-1. Findings from this analysis concluded:

“Our findings suggest that the presence of social media bots can indeed negatively affect democratic
political discussion rather than improving it.

An article by NPR.com titled ‘Facebook Says Social Media Can Be Negative for Democracy’
describes ‘Fake News’ composing 80,000 posts reaching 126 million Americans affecting the 2016
U.S. election, which was originally dismissed by founder Mark Zuckerberg as ‘a crazy idea’. There
is no doubt that Twitter Bots and other methods of automating interaction on social networks is
beginning to affect real world events in many ways.

4.4 Current State of The Art Twitter Bots

Twitter itself estimates that up to 25% of the tweets on Twitter are from bots, and that 5% of
accounts generate 75% of tweets. Additionally, CNBC estimates that nearly 48 million twitter
accounts (15% of all accounts) are Bots based on research performed at USC.

An article by TechCrunch in September 2017 described Twitter’s ‘Bot Problem’ and the increasing
sophistication of bots (and bot strategy) on Twitter. For example, the writer of the Tech Crunch
article, who were critical of bots role in the 2016 U.S. Presidential election, were ‘targeted’ by bots
following and retweeting their content to ultimately trigger Twitter’s own anti-spam measures.

Examples of Twitter Bots

Ten of the best twitter bots in 2017 include ‘@DearAssistant’ which is a Twitter Bot similar to Siri
or Google Assistant

 A Quartz Article describes 15 of the best bots from 2015, including a bot which tweets out
full games of ‘Boggle’ which can then be solved by twitter users.

24
4.5 Experimenting with a Twitter Bot

After exploring and documenting about the power of Twitter bots, I began using the Tweepy python
library to create and implement a bot on my own, personal twitter account to promote high-quality
news around two of my passions and interests: Cryptocurrency and Blockchain technologies.

The twitter bot I use for my own account (@codekid5) does the following:

 Favorites posts on twitter of users that I am following directly from the twitter home timeline.
This activity engages the accounts I follow, and allows similar interested users to find my
account.
 Originally, I followed new accounts, discovered by going to high-quality accounts and
following the accounts they follow. I stopped this shortly because the accounts were less and
less interesting to my own interests, and sometimes I followed an account I wouldn’t
normally agree with their ideas or viewpoint. Additionally, this activity (mass following)
seems to be one of the FEW activities actually monitored and frowned upon by Twitter.

When designing a twitter bot, the following questions are important to consider:

 What viewpoint, movement or ideology are you looking to promote? Twitter bots can be very
effective in promoting a particular candidate or ideology.
 Who agrees with, and is actively promoting, your cause? What are some of the main accounts
(or subreddits) posting this type of material?
 Are you looking to support your cause, promote your cause among those who may be
uninformed, or challenge another ideology?

In conclusion, twitter bots can have a significant effect on public opinion on a certain subject
and this can be used when promoting you ideology, cause, or business due to the power and
reach of twitter, as well as a very low-cost implementation.

However, successful and effective implementation of a Twitter Bot can be challenging because if the
bot posts low quality content, unrelated content or spam is easily ignored and will ultimately cause
the opposite of the intended effect, up to and including a ban from Twitter.

25
Keeping the potential negative effects of the bot in mind can help to mitigate them, and always be
sure to add value to the conversation.

26
CHAPTER-5

CONCLUSION AND FUTURE SCOPE


Twitter is key for consumers looking to contact brands. This is backed up by Doan, who says Twitter
chatbots are “a brilliant way of managing common queries, and means we can get to people
instantaneously.”

And while you can't beat having a real person, chatbots can help perform a key role in everything
from answering questions to ordering products.

According to Sprout Social, consumers expect a response in less than four hours from a brand.
However, the actual response can take as much as 10 hours. In many cases, a chatbot could
adequately handle many of these requests.

Keeping the potential negative effects of the bot in mind can help to mitigate them, and always be
sure to add value to the conversation.

However, successful and effective implementation of a Twitter Bot can be challenging because if the
bot posts low quality content, unrelated content or spam is easily ignored and will ultimately cause
the opposite of the intended effect, up to and including a ban from Twitter.

In conclusion, twitter bots can have a significant effect on public opinion on a certain subject and
this can be used when promoting you ideology, cause, or business due to the power and reach of
twitter, as well as a very low-cost implementation.

Many of the biggest tech companies are busy building bots, most notably Microsoft and Facebook.
So what exactly are bots?

Bots are all the rage in 2016, with Microsoft and Facebook recently revealing bold plans in the field.

But just what is that field, exactly? The following answer has been compiled by humans.

A bot, in the modern context, is a piece of software that can execute a digital task that would
traditionally require human interaction.
We’re not talking about mere automation here. Rather, bots are typically designed to mimic or
simulate human behaviour, engaging in realistic conversations or providing information in a
naturalistic, context-sensitive fashion.

They’re tiny AI applications put to very specific uses, often within existing apps.

You’ll often see the term ‘chatbot’ used, which refers to those bots that have been designed to be
able to engage in back and forth communications with real humans. If a chatbot has been successful,
you’ll never know (or at least care) that you weren’t ‘talking’ to a real human.

Bots are actually nothing new. Most notably, Twitter has had bots for years in the form of
Twitterbots that can send automated responses and retweets, or automatically follow users.Bots can
also be found working in chat apps like Slack and Kik.

But the fresh attention of two of the world’s biggest tech companies, along with recent massive
advances in AI, means that bots are now firmly in the limelight like never before.

5.2 Bots vs. Apps

Bots might be subservient to apps right now, essentially living within and enhancing them, but that
might not always be the case.

Part of that is down to widely perceived dissatisfaction with the way apps operate. After a bold start
back in 2008 with the launch of Apple’s App Store, it has emerged that most people only use a small
handful of apps on a consistent basis.

According to a comScore report from September 2015, the average American smartphone user only
uses three apps for 80 percent of the time.

It seems obvious now, but people simply don’t have the time or inclination to juggle dozens of
separate interfaces and accounts – particularly when the tasks they achieve are often relatively
simple and repetitive.

Bots seem one likely way to simplify such a convoluted set-up.

28
Opinion varies on whether these bots will eventually replace apps altogether as our primary means of
getting things done online, or whether they’ll continue to complement the app experience.

The case for bots being the new apps is a compelling one, though.

Why boot up a takeaway app and click through multiple options to secure your order; open a media
app to select, purchase, and download a film; and open a another app to check the weather when you
can simply have a series of intelligent bots working to bring you the relevant information in a single
location?

Of course, right now that single location would need to be an app, and a couple of the world’s
leading tech companies want to play host.

5.3 Microsoft

Just a couple of weeks before Facebook rolled out its bot platform, Microsoft was announcing its
own chatbots at its annual Build conference.

The Microsoft Bot Framework enables developers to build bots that work with Cortana inside Skype.
These bots could let you book hotels, order food, manage your calendar and more. Tell Cortana that
you’re attending an event, and it could reach out to a local hotel’s chatbot to proceed with booking a
room.

Like Facebook, Microsoft is essentially enabling companies to create AI-driven customer service
systems to help you with simple tasks, but it has other interesting applications.

One lightweight but interesting demonstration of the scope of Microsoft’s bot ambitions is
CaptionBot, which shows how the company’s Vision and Bing Search APIs can work with the Bot
Framework. It can take any image you like and assign a coherent and accurate description of it using
natural language. If CaptionBot realises that you’ve taken a selfie, it might even inform your of
which celebrity you resemble.

5.4 The Pitfalls


Of course, it’s early days for bots, and there are plenty of potential pitfalls to overcome. Take our last
example, Microsoft.

29
The company recently made the news for the way its experimental Tay chatbot went badly awry.

This teen-focused Twitter bot was intended to mimic the behaviour and tone of a teenage girl, and to
learn and adapt its output according to other tweeters.

Thanks to the input of some mischievous users, Tay was essentially turned into a racist, misogynist,
foul-mouthed imbecile. Microsoft duly took its errant AI offline and issued a sheepish apology.

The wayward Tay chatbot may have merely offended a few sensitive or unwitting people, but it
raised questions about the readiness of bot technology to be employed in more exactly fields. When
business reputations and financial security are on the line, can they afford to hand over their
operations to a rudimentary AI program?

Beyond the matter of the technology itself, there’s the question of whether humans will take to their
new AI servants. Would you be comfortable discussing financial matters with a program, even if it’s
just to pay for a pizza? Are you happy giving over personal details to a faceless machine? The rise of
the bots will inevitably mean a reduced reliance on call centres and support staff, which means
millions of jobs will be at risk – particularly in developing countries.

One thing’s for sure – while bots appear to have a future, their implementation right now seems
fairly rudimentary, and it seems easy to overstate their capabilities. You can expect most bots to
continue handing off to human operators for the really advanced stuff. Bots can’t yet engage in
protracted, complex conversations, which means they won’t be replacing call centres just yet.

30
REFERENCES

 https://www.sans.org/reading-room/whitepapers/covert/ocean-internet-deep-
web-37012
 https://media.scmagazine.com/documents/224/deeplight_55856.pdf
 https://www.trendmicro.com/cloud-content/us/pdfs/security-
 http://www.batblue.com/
 http://celarc.ca/cppc/247/247804.pdf•http://www.cs.princeton.edu/courses/arc
hive/spr09/cos423/Lectures/mtf.pdf
 https://www.quora.com/
 https://www.deepdotweb.com
 http://fieldguide.gizmodo.com/
 http://www.guidingtech.com/50281/dos-donts-deep-web-surfing16
 https://www.deepdotweb.com/2016/05/09/ https://tails.boum.org/
 https://www.TORproject.org/projects/
 https://geti2p.net/en/about/intro
 http://motherboard.vice.com/read/

31

You might also like