Vous êtes sur la page 1sur 48

CHAPTER-1

INTRODUCTION
1.1 Overview

Indian Railways (IR) is India's national railway system operated by the Ministry of
Railways. It manages the fourth-largest railway network in the world by size, with 121,407
kilometers (75,439 mi) of total track over a 67,368-kilometre (41,861 mi) route. Forty nine
percent of the routes are electrified with 25 KV AC electric traction while thirty three percent
of them are double or multi-tracked. IR runs more than 13,000 passenger trains daily, on
both long-distance and suburban routes, from 7,349 stations across India. The trains have a
five-digit numbering system. Mail or express trains, the most common types, run at an average
speed of 50.6 kilometers per hour (31.4 mph). In the freight segment, IR runs more than 9,200
trains daily. The average speed of freight trains is around 24 kilometers per hour (15 mph).

As of March 2017, IR's rolling stock consisted of 277,987 freight wagons,


70,937 passenger coaches and 11,452 locomotives.IR owns locomotive and coach-
production facilities at several locations in India.

The world's eighth-largest employer, it had 1.308 million employees as of March 2017. In
the year ending March 2018, IR is projected to carry 8.26 billion passengers and transport 1.16
billion tons of freight. In the fiscal year 2017-18, IR is projected to have earnings of ₹1.874
trillion (US$29 billion), consisting of ₹1.175 trillion (US$18 billion) in freight revenue and
₹501.25 billion (US$7.7 billion) in passenger revenue, with an operating ratio of 96.0
percent.

A chatbot (also known as a talkbot, chatterbot, Bot, IM bot, interactive agent, or Artificial
Conversational Entity) is a computer program which conducts a conversation via auditory or
textual methods. Such programs are often designed to convincingly simulate how a human
would behave as a conversational partner, thereby passing the Turing test. Chatbots are
typically used in dialog systems for various practical purposes including customer service or
information acquisition. Some chatterbots use sophisticated natural language processing

1
systems, but many simpler systems scan for keywords within the input, then pull a reply with
the most matching keywords, or the most similar wording pattern, from a database.

The term "ChatterBot" was originally coined by Michael Mauldin (creator of the
first Verbot, Julia) in 1994 to describe these conversational programs. Today, most chatbots are
either accessed via virtual assistants such as Google Assistant and Amazon Alexa,
via messaging apps such as Facebook Messenger or WeChat, or via individual organizations'
apps and websites. Chatbots can be classified into usage categories such as conversational
commerce (e-commerce via chat), analytics, communication, customer support, design,
developer tools, education, entertainment, finance, food, games, health, HR, marketing, news,
personal, productivity, shopping, social, sports, travel and utilities.

Chat bots are used in social media applications like Skype or Facebook messenger and
ideally for customer service purposes. IBM recently explained how easy it is to build a chat bot
for any chat or device, a simple way to add natural conversations to any rail or travel app.

IR is the fourth largest railway network in the world, transporting millions of passengers
across the length and breadth of the country. Equally mind boggling is the traffic on the web
portal for booking train tickets, fetching PNR and live train status,  Indian Railway Catering and
Tourism Corporation (IRCTC). An average of 13 lakh tickets are booked per day. Over 1
million people visit the site to check their ticket status. While there are certain other travel
aggregator sites that allow users to book train tickets, IRCTC is still the preferred method.

Despite its shabby looks, it gets the work done. Besides booking ticket, some of the most
commonly performed actions by travellers are Check the Passenger Name Record (PNR)
status also known as ticket status, check if a waitlisted ticket has been confirmed, check running
status of train, In India trains run late, passengers just want to know by how much and check
the train schedule, which waste time of the passengers. Even to get the above mentioned
information from an application using platforms like Android and iOS, the user has to
download an application which consumes internet bandwidth as well as waste time. Thus, the
passengers can save their time and internet data by using the Chatbot by just messaging using

2
app such as Facebook Messenger, Telegram, Google Assistant, Skype which is generally pre-
installed.

1.2 Problem Statement

The gathering of different travel related information is a cumbersome activity on the


IRCTC website. The user has to login to the site and fetch the information, which is a tedious
task when the server is down. Many a times, due to heavy traffic on the server it crashes and
people had to wait for the reconnection of the server. One more disadvantages with the IRCTC
site is if the user is inactive for longer period of time, the session expires and the user has to
login again. Sometimes the information is split across multiple websites, adding to the
pandemonium. Based on the user research conducted, most people side-step IRCTC and prefer
Google for quick replies. While the time taken to get the information is under 2 minutes for most
cases, there are some common complaints too much information and tables of text require more
time to parse the information and find what we were looking for.

Another huge bottleneck is in processing payments. It involves a series of menu selections


by users each causing pages to load followed by complex handshakes between IRCTC, third
party gateways, and the banks, security checks and so on. Each step is prone to failures too. On
the whole, 29% of attempted payments failed.

Indian Railways is facing scale problems almost unique to itself. While there are
improvements required at every stage, there can’t be a significant improvement in ticket
booking experience without making core changes. All these performance improvements can
reduce passenger frustration by completing the booking experience faster without many
failures, but still will not do anything to the number of people who end up not getting a
reservation.

1.3 Objective
Chatbots have the potential to deliver seamless customer service. Whether it is about
communicating urgent information or providing solutions to immediate problems, chatbots can
handle it all. Your customers will always feel your support system by their side irrespective of
their time zone. This is something travelers always need particularly during international

3
travels. By being there for your customers for every need they have you will be able to provide
an improved level of customer service.

A chatbot is one such customer touchpoint which ensures maximum engagement. It is


even more engaging than human assistants because there are no time boundaries. Travel bots
are able to solve queries, give recommendations, initiate transactions or just have casual
interactions. With so many possibilities comes the added benefit of all time availability. This
ensures improved customer's engagement with your brand even more than a mobile app or
social media.

It present a new way for individuals to interact with computer systems. Traditionally, to get
a question answered by a software program involved using a search engine, or filling out a form
but it will allow a user to simply ask questions in the same manner that they would address a
human. The technology at the core of the rise of the chatbot is natural language processing
(“NLP”). It can be improved by integrating it into the organization’s enterprise software,
allowing more personal questions to be answered. Platforms where chatbots are deployed
include Facebook Messenger, Skype, and Slack, among many others. The aim is to address the
failure of websites and applications and provide customer a simple solution to know the
information they want to. It will save the time of the user where it use to wait for the server to
load data in websites and sometimes due to heavy traffic the data could not be loaded. It will
also overcome the session expired feature in the IRCTC website while booking of tickets is
delayed.

Chatbots can have little to no ‘functionality’ beyond conversation yet still reinforce a
strong brand message, which is perfect for marketing campaigns. There’s no better way to
reinforce a brand message than conversation. With chatbots, brands can engage in 1-on-1
communication at scale. Brands have the opportunity to personalise each customer’s
experience that is unique, scalable, and automated.

1.4 Organization of the report


Chapter 1
This chapter deals on the objective and overview of the project.

4
Chapter 2
This chapter includes the Literature Survey of the project. It also contains the existing system,
issues in existing system, summary of the Literature Survey.

Chapter 3
This chapter includes the various modules involved in the project and the architecture of the
entire system. The working of various modules is explained with description.

Chapter 4
This chapter entirely deals about the system implementation on the details about the platform
used and the implementation source code and screen shots of the output produced.

Chapter 5
This chapter deals with system testing objective of identifying and correcting deviations from
standards, identifying and fixing logical bugs and fall through and recording code walk through
findings after successful completion.

Chapter 6
This chapter deals with the conclusion of the project.

Chapter 7
This chapter deals with the future enhancement of the project.

5
CHAPTER - 2
LITERATURE SURVEY
2.1 Introduction

Indian Railways (IR) is India's national railway system operated by the Ministry of
Railways. It manages the fourth-largest railway network in the world by size, with 121,407
kilometers (75,439 mi) of total track over a 67,368-kilometre (41,861 mi) route. Forty nine
percent of the routes are electrified with 25 KV AC electric traction while thirty three percent
of them are double or multi-tracked. IR runs more than 13,000 passenger trains daily, on
both long-distance and suburban routes, from 7,349 stations across India. The trains have a
five-digit numbering system. Mail or express trains, the most common types, run at an average
speed of 50.6 kilometers per hour (31.4 mph). In the freight segment, IR runs more than 9,200
trains daily. The average speed of freight trains is around 24 kilometers per hour (15 mph).

A chatbot (also known as a talkbot, chatterbot, Bot, IM bot, interactive agent,


or Artificial Conversational Entity) is a computer program which conducts a conversation via
auditory or textual methods. Such programs are often designed to convincingly simulate how a
human would behave as a conversational partner, thereby passing the Turing test. Chatbots are
typically used in dialog systems for various practical purposes including customer service or
information acquisition. Some chatterbots use sophisticated natural language
processing systems, but many simpler systems scan for keywords within the input, then pull a
reply with the most matching keywords, or the most similar wording pattern, from a database

2.2 Existing System


The data’s are available only through websites or by installing apps. The user has to
make an account and login to get the information. It takes more time to get the data from the
server and then to access the information. If the server is down due to heavy traffic the user has
to wait for sometimes to get the information required. The website doesn’t load fast or does not
have the updated information. It requires more internet usage. The current solutions available
are scattered and act more like a band-aid fix.

6
Many a times, the captcha code is not clear and by the time the user get it right, the
tickets will get booked already. There is no direct communication or conversation regarding
any services in the railways sites and apps.You need to dial certain number and then
communicate with the enquiry officer.

2.3 Issues in Existing System


One reason a conversational chatbot is needed is the fact that most of the ones available
these days are based on buttons and decision tree-models. Forcing users to choose from a set of
options presents some obvious problems. It is likely that at some point of the interaction the
option they need is not part of that set, and it is even more likely that if they try to type what
they want the bot will not understand them. Another big setback is that if the user changes her
mind during the exchange and decides to change skimmed milk for soy milk, for example, she
won’t be able to go back on that decision and will be forced to start over.

Conversational bots offer better user experience to customers, and this improved UX
leads to an increase in loyalty and sales, which in turn bring more revenue as time passes by.

Word-to-mouth is one of the oldest and more effective techniques to attract customers,
and it can be applied to bots as well. When you receive a good service somewhere, you tend to
share it and recommend it to your friends, relatives and sometimes on social networks and
forums. So, if your bot provides your clients with a positive user experience they will
recommend you to their friends and family.

New Artificial Intelligence systems are supposed to work for humans and not the other
way around. It should not be the user the one modifying the way he speaks to be understood by
chatbots and Virtual Assistants, they should be able to understand natural language.

Apps are often difficult to share on mobile devices, so getting other people to
download them takes a lot of work. Chatbots don't have that disadvantage. It is also true that
the viral nature of chatbots within the messaging app make it more likely that users will be
prompted to use the bot again if they see others on the chat platform using the bot or it is
shared with them somehow. This will potentially improve retention rates versus apps.

7
Chatbots can be easily shared between people who are already on a chat platform and
can even be used in chat groups. This makes it much easier for chatbots to grow their user
base.

The gathering of different travel related information is a cumbersome activity on the IRCTC
website. The user has to login to the site and fetch the information, which is a tedious task when
the server is down. Many a times, due to heavy traffic on the server it crashes and people had to
wait for the reconnection of the server. One more disadvantages with the IRCTC site is inactive
for longer period of time, the session expires and the user has to login again. Sometimes the
information is split across multiple websites, adding to the pandemonium. Based on the user
research conducted, most people side-step IRCTC and prefer Google for quick replies. While
the time taken to get the information is under 2 minutes for most cases, there are some common
complaints too much information and tables of text require more time to parse the information
and find what we were looking for.

2.4 Summary of Literature Survey


Below is the summary of some of the reference survey papers that has been analyzed
during the project

1. Naveen Kumar M, Linga Chandar P C,Venkatesh Prasad A,Sumangali K, ”


Android Based Educational Chatbot for Visually Impaired- People”, Issue, 2017 -
The purpose of this android application is to provide educational based Chatbot for
visually impaired people. It will give an answer to the educational based queries asked
by the visually impaired people. They can easily launch the application with the help
of google voice search. Once the application is open, it will give a voice instruction to
use an application. Output will be provided in voice form as well as in text form. So
normal people can also use this application.

2. Ravi Santosh Arvapally, Hasan Hicsasmaz, Wally Lo Faro, “ Artificial


Intelligence Applied to Challenges in the Fields of Operations and Customer
Support “,Issue,2017 - Traditionally, Mastercard has been seen as simply a payment
processor, and while that remains a others in its ecosystem around the world.
Consequently, there is a need for large operations and customer support teams. Their

8
systems accumulate data and in this paper we present four different examples of
applying Artificial Intelligence to this data to solve business problems.

3. Daniel Toniuc and Adrian Groza,” Climebot: an argumentative agent for climate
change”, Issue, 2016- While climate experts have agreed that global warming is real,
this consensus has not reached all the society levels. Our aim is to develop a
conversational agent able to explain issues related to global warming. The developed
chatbot relies on textual entailment to identify the best answer for a statement conveyed
by a human agent. To enhance the conversational capabilities we employed the
technical instrumentation provided by the API.AI framework. To exploit domain
knowledge, the agent uses climate change ontologies converted into an adequate format
for the API.AI model. Hence, we developed a Climebot, which is an argumentative
agent for climate change based on ontologies and textual entailment.

4. Sören Blom, Matthias Book, Volker Gruh ,” Executable Semantics of Recursively


Nestable Dialog Flow Specifications for Web Application”, Issue, 2010 -
Information systems for the support of complex business process are often equipped
with web-based front-ends to allow convenient user access. To produce executable
specifications of the users’ interactions with such web-based applications, we use a
visual language that enables developers to model their complex dialog structures. In
this paper, we introduce the formal semantics of the core constructs of this. Dialog Flow
Notation: We desne its syntax in terms of invariants about the permitted elements and
their relations, and show how any words of the language (i.e. any syntactically correct
dialog ƀow specifications) can be mapped to a deterministic pushdown automaton
whose behavior dense the notation’s semantics. This gives us and other tool developers
a formal basis for the design and implementation of tools and frameworks that mirror
the precise meaning of all DFN constructs.

9
5. Guo Chunfang , Wu Hao, Sun Zhongyue, Guan Zhongliang ,“ Study on the Public
Information Service Systems of Railway Industry”,Issues,2010 - As we enter the
21st century, we experience one of the most important changes in our lives—
information technology has been the important resource in the modern scientific and
technology competition. So the tide of Railway Informatization is increasingly rising.
Railway information service system is the strategic resource element in the course of
informatization. But railway information service in our country is not perfect yet,
especially the information Service for the public. This paper first focus on the current
situation of public information service in China, then proposed an information service
system for railway industry to enhance the efficiency and transparency of information
transmission. and then give some advices on how to operate the information service
system to facilitate the information transmission in railway industry.

10
CHAPTER – 3
SPECIFICATIONS

3.1 Introduction
A chatbot (also known as a talkbot, chatterbot, Bot, IM bot, interactive agent,
or Artificial Conversational Entity) is a computer program which conducts a conversation via
auditory or textual methods. Such programs are often designed to convincingly simulate how
a human would behave as a conversational partner, thereby passing the Turing test. Chatbots
are typically used in dialog systems for various practical purposes including customer service
or information acquisition. Some chatterbots use sophisticated natural language
processing systems, but many simpler systems scan for keywords within the input, then pull a
reply with the most matching keywords, or the most similar wording pattern, from a database.

3.1.1 Purpose

Chatbots can be useful in many aspects of the customer experience, including providing
customer service, presenting product recommendations and engaging customers through
targeted marketing campaigns. If a customer has an issue with a product, she can connect with
a chatbot to explain the situation and the chatbot can input that information to provide a
recommendation of how to fix the product. On the recommendation side, chatbots can be used
to share popular products with customers that they might find useful and can act as a sort of
personal shopper or concierge service to find the perfect gift, meal or night out for a customer
with just a few basic questions. Brands are also using chatbots to connect their customers with
thought leaders and add personality to their products. In all cases, brands seem to be having
great success and experiencing increased engagement and revenue.

Chatbots are easy to use and many customers prefer them over calling a representative
on the phone because it tends to be faster and less invasive. They can also save money for
companies and are easy to set up. Because most chatbots use messenger apps that are already
on billions of phones around the world, chances are your customers are already plugged in and
ready for your bot. Chatbots are the future of customer experience and have the power to
replace search windows and many apps in the not-so-distant future.

11
3.1.2 Scope

The chatbot will be fast and concise. It is dummy friendly. It gives confirmation of the
user query eliminating misunderstanding. The conversational interface of a chatbot is suited
ideally for the purpose of fetching the information of the Indian Railways and there is a lot of
scope for improving and fine tuning the services provided. It saves device memory space, time
and internet data usage. The chatbot will also enable the user to get the response of Small talks.

Business intelligence (BI) enables businesses to know more about their wider markets,
internal process performance and progress over time. AI makes it possible to get this critical
information faster and cheaper. Businesses using AI for customer-facing or employee-facing
tasks can often free up resources that would have gone to paying a human for analysis tasks   and
reinvest those resources in humans executing on the insights produced by AI.

3.2 Overall Description


The overall description includes the product features and the importance of system used. In
the features the proposed system has also been mentioned.
3.2.1 Product Feature
 365*24*7 Support - Unlike your support staff, Chatbots don’t need any breaks,
they happily work and learn 24 hours a day. They have a robust cloud architecture.
 Reduce operational and service expense
 Get a new age platform to wow your customers
 Increase engagement with customers and touchpoints
 Eliminate mobile app-fatigue
 Multiply reach, increase breadth and depth of engagement
 Rich analytics and customer interaction
 Instantaneous response without the need for human response delays
 Train your own bots
 Chatbot web widget integration on your websites

3.2.2 Importance of Chatbot


The purpose of chat bots is to support and scale business teams in their relations with
customers. Doing this helps businesses save a lot of money which is why many business owners
are adopting this technology. And given the fact that these bots can be placed in places like

12
Facebook Messenger, Slack, Telegram, SMS based or on your own website gives you the
potential to reach a bigger audience.
Chatbots may sound like a futuristic notion, but according to Global Web Index
statistics, it is said that 75% of internet users are adopting one or more messenger platforms.
Although research shows us that each user makes use of an average of 24 apps a month, wherein
80% of the time would be in just 5 apps. This means you can hardly shoot ahead with an app,
but you still have high chances to integrate your chatbot with one of these platforms.

(a). Available 24*7


I’m sure most of you have experienced listening to the boring music playing while
you’re kept on hold by a customer care agent. On an average people spend 7 minutes until they
are assigned to an agent. Gone are the days of waiting for the next available operative. Bots are
replacing live chat and other forms of contact such as emails and phone calls.

Since chat bots are basically virtual robots they never get tired and continue to obey your
command. They will continue to operate every day throughout the year without requiring to take
a break. This improves your customer satisfaction and helps you rank highly in your sector.

(b). Handling Customers


We humans are restricted to the number of things we can do at the same time. A study
suggests that humans can only concentrate on 3–4 things at the same time. If it goes beyond that
you are bound to meet errors.

Chatbots on the other hand can simultaneously have conversations with thousands of
people. No matter what time of the day it is or how many people are contacting you, every
single one of them will be answered instantly. Companies like Taco Bell and Dominos are
already using chatbots to arrange delivery of parcels.

(c). Helps you Save Money


If you are a business owner you are bound have a lot of employees who need to be paid
for the work they do. And these expenses just keep adding up as business grows. Chatbots are
a one time investment which helps businesses reduce down on staff required.

13
You could integrate a customer support chatbot in your business to cater to simple
queries of customers and pass on only the complex queries to customer support agents.

(d). Provides 100% satisfaction to customers


Humans react to others based on their mood and emotions. If a agent is having a good
attitude or is in good mood he will most probably talk to customers in a good way. In contrary
to this the customer will not be satisfied.

Whereas chatbots are bound by some rules and obey them as long as they’re
programmed to. They always treat a customer in the most polite and perfect way no matter how
rough the person is. Also, in the travel and hospitality industry where travelers do not speak the
same language, a bot can be trained to communicate in the language of the traveler.

(e). Automation of repetitive work


Let’s be honest, no one likes doing the same work again and again over brief period of
time. In the case of humans, such tasks are prone to errors. Chatbots now help automate tasks
which are to be done frequently and at the right time.

Also, now there are numerous slack bots which automate repetitive tasks. This helps
people save time and increase productivity. For example, there are new items bought from your
e-commerce site or there is a bug reported then it sends a short summary to a slack channel.

(f). Personal Assistant


People could use Bots as a fashion advisor for clothing recommendations, or ask
trading tips from a finance bot, suggest places to visit from a travel bot and so forth. This would
help the users get a more personal touch from the chatbot. Also, the chatbot will remember all
your choices and provide you with relevant choices the next time you visit it.

3.2.3 User classes in the System


1). Admin- The mobile user should have the permission to use our platform from Telegram,
Facebook Messenger, Skype, etc and working internet allowance to use it properly. The mobile
user will get the permission to use all the features of our platform.

14
2). User- The user will use this platform to show all Indian railway information from the
Chatbot. The user simply search any details like check train schedule or check pnr status of his
tickets and many others information’s.

3.3 Requirement
The requirement for this project include some software specifications which are: -

1. Heroku server- This is an open server which can be used to create the link between the
chatbot and railway API.

2. Heroku CLI & Git – This is a command line interface for working and deploying the
local repository to the Heroku server which take the help of Git or Github desktop.

3. Python IDE- As the backend is programmed in Python, therefore this IDE helps to script
and debug the test.py file for fetching the JSON from Railway API and getting it back
to the chatbot using webhook.

4. Dialog Flow (API.ai) - This online service allows us to design an Artificial Intelligence
Chatbot through defining the intent/activity and entity and fetching the information
from Heroku using fulfillment/webhook.

5. Facebook Developer Page or token- To enable this chatbot to be used by the passengers,
the administrator has to get access to Facebook Developer platform or any other
required messenger token for deploying the chatbot into their application.

6. Facebook Messenger/Telegram/Slack/Google Assistant- Enables the user to message


the input through keyboard and mic in the form of voice and text and get the output in
the same two formats.

15
CHAPTER – 4
SYSTEM DESIGN

4.1 Introduction
A chatbot aims to make a conversation between both human and machine. The machine
has been embedded knowledge to identify the sentences and making a decision itself as
response to answer a question. The response principle is matching the input sentence from user.
From input sentence, it will be scored to get the similarity of sentences, the higher score
obtained the more similar of reference sentences.

The sentence similarity calculation in this paper using bigram which divides input
sentence as two letters of input sentence. The knowledge of chatbot are stored in the database.
The chatbot consists of core and interface that is accessing that core in relational database
management systems (RDBMS).

The database has been employed as knowledge storage and interpreter has been
employed as stored programs of function and procedure sets for pattern-matching requirement.
The interface is standalone which has been built using programing language of Pascal and Java.

4.2 System Architecture


The system architecture gives the basic idea about how the app will be working. It is
like a blueprint for a common man to understand.

Figure 4.1: System Architecture

16
1. Facebook Messenger/Slack/Telegram/Google Assistant
Enable the user to give the input through keyboard and mic in the form of voice and text
and get the output in the same two formats.

1.1) Input- Example- To get the PNR details the user can give the input as “PNR
85761234”

1.2) Output- Example- The above query given in the input module will be responded
as “PNR 85761234, NAME-AKSHAT SHRIVASTAV, DOJ-1/1/2018, TRAIN NO. -
13552, CUR STAT- RLWL/051”.

Figure 4.2: User Input and Output

2. DialogFlow(API.ai) -

This online service allows us to design a rich Artificial Intelligence Chatbot through
defining the intent/activity and entity.

2.1) Intent- Defines the activity which is performed by identifying the query given by
the user. Intent is the described activity defined in the dialog flow. It can fetch the
information from webhook using fulfilments.

2.2) Entity- The database of the required real-world object that is provided by the
developers.

2.3) Fulfilment- The intent which has a particular action name can use the fulfilment
for connecting the webhook with the Heroku server.

17
3. Backend-
The Backend that is used to connect and fetch the information between the Railway API
and dialog flow.

3.1) Heroku server- This is an open server which is used to create an application to store
the backend database and creating the link between the chatbot and railway API.

3.2) Heroku CLI & Git – This is a command line interface for deploying and debugging
the test.py to the Heroku server which take the help of Git or Github desktop. This
server enables us to use Heroku logs and deploying methods.

3.3) Python- The backend is programmed using Python version 2.7 and pip. This is
used to fetch the JSON object from the Railway API and responding to the DialogFlow
using webhook, flask.

4. Railway API -

Responsible for providing the information as JSON object like PNR status, Train
between the stations, running status, etc. The module works with a unique API key provided
by API providers such as erail.in and railwayapi.com.

4.2.1 Use Case Diagram


A use case diagram at its simplest is a representation of a user’s interaction with the
system that shows the relationship between the user and the different use cases in which the
user is involved. A use case diagram can identify the different types of users of a system and
the different use cases and will often be accompanied by other types of diagrams as well. While
a use case itself might drill into a lot of detail about every possibility, a use-case diagram can
help provide a higher-level view of the system. There are different components of a use case
diagram such as actors, use case, association, etc. Actors represent roles that users take on
when they use the IT system, e.g., the role of a check-in employee. One person can act in more
than one role toward the IT system. It is important for the IT system in which role a person is
acting.

18
Figure 4.3: Use Case Diagram

Use cases describe the interactions that take place between actors and IT systems during
the execution of business processes. A use case represents a part of the functionality of the IT
system and enables the user (modelled as an actor) to access this functionality. Anything that
users would like to do with the IT system has to be made available as a use case (or part of a
use case). An association is a connection between an actor and a use case. An association
indicates that an actor can carry out a use case. Several actors at one use case mean that each
actor can carry out the use case on his or her own and not that the actors carry out the use case
together.

An include relationship is a relationship between two use cases. It indicates that the use
case to which the arrow points is included in the use case on the other side of the arrow. This
makes it possible to reuse a use case in another use case. In the above use case diagram, user
and admin are the two actors. These are connected to various use case in the diagram. However
there would be some difference between the two actors. The user is connected to Facebook
Messenger/Telegram through association. This means that the user has access to Facebook

19
Messenger/Telegram. The other actor admin is connected to all the use cases that are connected
by user and also to new cases like DialogFlow, Intent/Entity, Fullfillment/ Webhook, Heroku
Server, and Railway API. The admin will have access to all the use case because it will control
the entire app.

The DialogFlow is connected to Facebook Messenger/Telegram and it is also


connected to Heroku server and intent/Entity. The intent/Entity include Fullfillment/Webhook.
The user enters the query through text or voice in the Facebook Messenger/Telegram.
DialogFlow is a new ways to interact with your product by building engaging voice and text-
based conversational interfaces powered by AI, which is integrated with Facebook
Messenger/Telegram. The DialogFlow contains Intent/Entity which includes Fullfillment /
webhook. We requires Heroku Server to fetch the data from the server and to fetch the data
from the Railway Server we require RailwayAPI. We fetch the data from the RailwayAPI with
the Heroku Server which is displayed with the integration of Facebook Messenger/Telegram
with the DialogFlow.

4.2.2 Class Diagram


A class diagram in the Unified Modeling Language (UML) is a type of static structure
diagram that describes the structure of a system by showing the system’s classes, their class
diagram is the main building block of object-oriented modelling. It is used for general
conceptual modelling of the systematic of the application, and for detailed modelling
translating the models into programming code. Class diagrams can also be used for data
modeling. The classes in a class diagram represent both the main elements, interactions in the
application, and the classes to be programmed.

A class with three compartments.


 In the diagram, classes are represented with boxes that contain three compartments:
 The top compartment contains the name of the class. It is printed in bold and centered,
and the first letter is capitalized.
 The middle compartment contains the attributes of the class. They are left aligned and
the first letter is lowercase.

20
The bottom compartment contains the operations the class can execute. They are also
left-aligned and the first letter is lowercase. In the design of a system, a number of classes are
identified and grouped together in a class diagram that helps to determine the static relations
between them. With detailed modelling, the classes of the conceptual design are often split into
a number of subclasses. In order to further describe the behaviour of systems, these class
diagrams can be complemented by a state diagram or UML state machine.

Figure 4.4: Class Diagram

21
4.3 System Requirement
 Facebook Messenger/Telegram/Skype
 DialogFlow
 Heroku Server

4.4 Summary
Thus in this chapter system architecture were designed, use case diagram and class
diagram were drawn this help us to understand the flow of our project and how to make a better
one. The user will get to know the flow and working implementation of the project. The system
architecture diagram includes the use of different modules that are used in the system such as
the server used and other functions.

22
CHAPTER – 5
MODULE DESCRIPTION

5.1 Introduction
The Railbot has four sets of modules. The application divided into the modules helps
to find the bugs/errors and fixing them easily.

Thus the modules are custom and can be edited for the correction or modifications. The
constants in the modules contains all the constant values used throughout the app: things like
the base URL of the Railway API, the API key, the paths to the endpoints that we will be
using, the character codes of the train number, pnr number and other parameters.

The process a DialogFlow agent follows from invocation to fulfillment is similar to


someone answering a question, with some liberties taken of course. DialogFlow is an online
service that provides us to create an interactive chatbot and implements any management
system in it. This online service allows us to design a rich Artificial Intelligence Chatbot
through defining the intent/activity and entity.

The implementation starts with the installation of Heroku, the local repository can be
stored in the storage using Git. With the help of Git and Heroku CLI, we can commit a change
and deploy the app to the Heroku Server. Using heroku logs command, we can found any bug
or in which module the bug is occurring, when a request is given from the user end.

The Railway API that uses requestor function to fetch the data from the server. Railway
API is the module uses constants that are fetched from the server and display the details of the
railway parameters. The user have to ask chatbot just like chatting with a person about weather
parameters like train status, pnr status, booking system, details for cancelled trains, fares of trains,
train root and many others information’s.

23
5.2 Facebook Messenger/Alexa/Google Assistant
The Facebook Messenger/Alexa/Google Assistant module is used as a platform to
interact with the chatbot.
5.2.1 Work flow diagram

Figure 5.1: Facebook Messenger/Alexa/Google Assistant

5.2.2 Description
Enable the user to give the input through keyboard and mic in the form of voice and
text, and get the output in the same two formats.

1.1) Input- Example- To get the PNR details the user can give the input as “PNR
85761234”.
1.2) Output- Example- The above query given in the input module will be responded as
“PNR 85761234, NAME-AKSHAT SHRIVASTAVA , DOJ-1/1/2018 , TRAIN N0 -13552,
CUR STAT- RLWL/051”.

5.3 DialogFlow
DialogFlow is an online service that provides us to create an interactive chatbot
and implements any management system in it. It is free of cost you just have to create an
account on it and access all its features.

24
5.3.1 Workflow diagram

Figure 5.2: DialogFlow


5.3.2 Description
DialogFlow (formerly Api.ai, Speaktoit) is a Google-owned developer of human–
computer interaction technologies based on natural language conversations. The company is
best known for creating the Assistant (by Speaktoit), a virtual buddy for Android, iOS,
and Windows Phone smartphones that performs tasks and answers users' question in a natural
language. Speaktoit has also created a natural language processing engine that incorporates
conversation context like dialogue history, location and user preferences.

This online service allow us to design an Artificial Intelligence Chatbot through


defining the intent/activity and entity using JSON object.
2.1) Intent- Defines the activity which is performed by identifying the query given by the user.
Intent is the described activity defined in the dialog flow.
2.2) Entity- The database of the synonyms that is provided by the developers.
2.3) Response- The Response module is the actionable data that is provided by fetching the
information from the API and presenting to the user.

25
5.4 Backend
The Backend that is used to connect and fetch the information between the Railway
API and dialog flow.

3.1) Heroku server- This is an open server which is used to create an application to store the
backend database and creating the link between the chatbot and railway API.

3.2) Heroku CLI & Git – This is a command line interface for deploying and debugging the
test.py to the Heroku server which take the help of Git or Github desktop. This server enables
us to use Heroku logs and deploying methods.

3.3) Python- The backend is programmed using Python version 2.7 and pip. This is used to
fetch the JSON object from the Railway API and responding to the Dialogflow using webhook,
flask.

5.4.1 Workflow diagram

Figure 5.3: Backend

5.5 Railway API


Responsible for providing the information as JSON object like PNR status, Train
between the stations, running status, etc. The module works with a unique API key provided

26
by API providers such as erail.in and railwayapi.com.

5.5.1 Workflow diagram

Figure 5.4: Railway API

5.6 Summary

Thus the above explained modules help the users and developers to understand the
application in the sets or parts. All the modules are customized thus help the developers to find
any bug/error and fix it. The modules reduces the load of application and complexity.

From fetching the information from the Railway Server and the showing result to the user,
all the modules are properly connected to each other and provide the correct details to the users.

1. Facebook Messenger/Alexa/Google Assistant


(a). Enable the user to give the input through keyboard and mic in the form of voice and text
and get the output.

27
2. DialogFlow
(a). This online service allows us to design a rich Artificial Intelligence Chatbot through
defining the intent/activity and entity.

3. Backend
(a). Access the information present in the API to forecast the weather parameters.

4. Railway API
(a). The Backend that is used to connect and fetch the information between the Railway API
and dialog flow.

5. Weather
(a). Responsible for providing the information as JSON object like PNR status, Train between
the stations, running status, etc.

28
CHAPTER – 6
SYSTEM IMPLEMENTATION

6.1 Introduction
In this chapter implementation of the system is described in detail. Here the detail view of
RailBot is described. The Platforms like Heroku server, Python IDE, Dialog Flow, Facebook
Messenger, Telegram, Slack plays a major role.

6.2 Overview of the Platform


The most popular development platforms are Heroku server, Python IDE, Dialog flow,
Facebook Messenger, Telegram and Slack. Here look at each of them:

6.2.1 Heroku Server


Heroku is a cloud platform as a service (PaaS) supporting several programming
languages that is used as a web application deployment model. Heroku, one of the first cloud
platforms, has been in development since June 2007, when it supported only the Ruby
programming language, but now supports Java, Node.js, Scala, Clojure, Python, PHP,
and Go. For this reason, Heroku is said to be a polyglot platform as it lets the developer build,
run and scale applications in a similar manner across all the languages.

Applications that are run on Heroku typically have a unique domain (typically
"applicationname.herokuapp.com") used to route HTTP requests to the correct dyno. Each of
the application containers, or dynos, are spread across a "dyno grid" which consists of several
servers. Heroku's Git server handles application repository pushes from permitted users.

Dyno manager help maintain and operate the dynos created. Because Heroku manages
and runs applications, there’s no need to manage operating systems or other internal system
configuration. One-off dynos can be run with their input/output attached to the local terminal.
These can also be used to carry out admin tasks that modify the state of shared resources, for
example database configuration, perhaps periodically through a scheduler.

29
Heroku’s HTTP routers distribute incoming requests for the application across the
running web dynos. A random selection algorithm is used for HTTP/HTTPS request load
balancing across web dynos. It also supports multiple simultaneous connections, as well as
timeout handling.

The Heroku network runs the customer's apps in virtual containers which execute on a
reliable runtime environment, heroku calls these containers Dynos. These Dynos can run code
written in Node, Ruby, PHP, Go, Scala, Python, Java, Clojure. Heroku also provides custom
build packs with which the developer can deploy apps in any other language. Heroku lets the
developer scale the app instantly just by either increasing the number of dyno or by changing
the type of dyno the app runs in.

Heroku Postgres is the Cloud database (DBaaS) service form Heroku based
on PostgreSQL. Heroku Postgres provides features like continuous protection, rollback and
high availability and also forks, followers and data clips.

Heroku CLI & Git – This is a command line interface for working and deploying the
local repository to the Heroku server which take the help of Git or Git hub desktop. The Heroku
Command Line Interface (CLI) makes it easy to create and manage your Heroku apps directly
from the terminal. It’s an essential part of using Heroku.

Installation Method
The standalone install is a simple tarball with a binary that is useful in scripted
environments or where there is restricted access (non-sudo). These are sample instructions that
can be modified to fit your environment. It contains its own node.js binary and will auto update.
Download the tarball and extract it so that you can access the binary from your PATH.

The CLI is built with Node.js and is installable via npm. This is a manual install method
that can be used in environments where autoupdating is not ideal or where Heroku does not
offer a prebuilt Node.js binary. This installation method is required for users on ARM, BSD,
and Arch Linux. You must have node and npm installed already.

30
Getting started
After you install the CLI, run the heroku login command to log in with your Heroku
account credentials. The CLI saves your email address and an API token to ~/.netrc for future
use. For more information, see Heroku CLI Authentication. Now you’re ready to create your
first Heroku app. Check out your preferred language’s getting started guide for a
comprehensive introduction to deploying your first app.

Staying up to date
The Heroku CLI keeps itself and its plugins (except linked plugins) up to date
automatically, unless you installed the Debian/Ubuntu package or used npm install. When you
run a heroku command, a background process checks for the latest available version of the CLI.
If a new version is found, it’s downloaded and stored in ~/.local/share/heroku/client. This
background check happens at most once every 4 hours. The heroku binary checks for an up-to-
date client in ~/.local/share/heroku/client before using the originally installed client.

CLI Architecture
The Heroku CLI is built with the Open CLI Framework (oclif), developed within
Heroku / Salesforce. oclif is available as a framework for any developer to build a large or a
small CLI. The framework includes a CLI generator, automated documentation creation, and
testing infrastructure.

The code for the Heroku CLI is also open source. It does not require Node.js or any
other dependencies to run. Unless you install the Debian/Ubuntu package or use npm install,
the CLI contains its own Node.js binary that does not conflict with other applications.

6.2.2 Python IDE


Python is an interpreted high-level programming language for general-purpose
programming. Created by Guido van Rossum and first released in 1991, Python has a design
philosophy that emphasizes code readability, notably using significant whitespace. It provides
constructs that enable clear programming on both small and large scales. Python features
a dynamic type system and automatic memory management. It supports multiple programming
paradigms, including object-oriented, imperative, functional and procedural, and has a large
and comprehensive standard library.

31
Python interpreters are available for many operating systems. CPython, the reference
implementation of Python, is open source software and has a community-based development
model, as do nearly all of its variant implementations. CPython is managed by the non-
profit Python Software Foundation.

As the backend is programmed in Python, therefore this IDE helps to script and debug
the test.py file for fetching the JSON from Railway API and getting it back to the chatbot using
webhook.

Heroku makes it easy to deploy and scale Python apps in the cloud. Whether you prefer
frameworks like Django or Flask, or getting your hands dirty with Twisted or raw sockets,
Heroku gets out of the way — allowing you to build things your way, with the tools you love.
Getting Started on Heroku with Python-This will have you deploying a Python app (a simple
Django app) in minutes. Hang on for a few more minutes to learn how it all works, so you can
make the most out of Heroku. User must have: a free Heroku account. Python version 3.6
installed locally - see the installation guides for OS X, Windows, and Linux. Pipenv
installed locally. Accomplish this by running pip install pipenv. Postgres installed locally, if
running the app locally.

Set up
In this step you will install the Heroku Command Line Interface (CLI), formerly known
as the Heroku Toolbelt. You will use the CLI to manage and scale your applications, to
provision add-ons, to view the logs of your application as it runs on Heroku, as well as to help
run your application locally. Once installed, you can use the heroku command from your
command shell. On Windows, start the Command Prompt (cmd.exe) or Powershell to access
the command shell.

Log in using the email address and password you used when creating your Heroku
account: Authenticating is required to allow both the heroku and git commands to operate.
Note that if you’re behind a firewall that requires use of a proxy to connect with external
HTTP/HTTPS services, you can set the HTTP_PROXY or HTTPS_PROXY environment
variables in your local development environment before running the heroku command.

32
Prepare the app
In this step, you will prepare a simple application that can be deployed. To clone the
sample application so that you have a local version of the code that you can then deploy to
Heroku, execute the following commands in your local command shell or terminal. You now
have a functioning git repository that contains a simple application as well as a Pipfile, which
is used by Python’s dependency manager, Pip.

Deploy the app


In this step you will deploy the app to Heroku. Create an app on Heroku, which prepares
Heroku to receive your source code. When you create an app, a git remote (called heroku) is
also created and associated with your local git repository.

Heroku generates a random name (in this case lit-bastion-5032) for your app, or you
can pass a parameter to specify your own app name. Now deploy your code. Now visit the app
at the URL generated by its app name. As a handy shortcut, you can open the website.

View logs
Heroku treats logs as streams of time-ordered events aggregated from the output
streams of all your app and Heroku components, providing a single channel for all of the events.
View information about your running app using one of the logging commands, heroku logs –
tail. Visit your application in the browser again, and you’ll see another log message generated.
Press Control+C to stop streaming the logs.

Define a Procfile
Use a Procfile, a text file in the root directory of your application, to explicitly declare
what command should be executed to start your app. This declares a single process type, web,
and the command needed to run it. The name web is important here. It declares that this process
type will be attached to the HTTP routing stack of Heroku, and receive web traffic when
deployed.

Procfiles can contain additional process types. For example, you might declare one for
a background worker process that processes items off of a queue.

33
Microsoft Windows- The sample app has an additional Procfile for local development on
Microsoft Windows, located in the file Procfile,windows. Later tutorial steps will use this
instead: it starts a different web server, one that is compatible with Windows.

Scale the app


Right now, your app is running on a single web dyno. Think of a dyno as a lightweight
container that runs the command specified in the Procfile.
By default, your app is deployed on a free dyno. Free dynos will sleep after a half hour of
inactivity (if they don’t receive any traffic). This causes a delay of a few seconds for the first
request upon waking. Subsequent requests will perform normally. Free dynos also consume
from a monthly, account-level quota of free dyno hours - as long as the quota is not exhausted,
all free apps can continue to run.

To avoid dyno sleeping, you can upgrade to a hobby or professional dyno type as
described in the Dyno Types article. For example, if you migrate your app to a professional
dyno, you can easily scale it by running a command telling Heroku to execute a specific number
of dynos, each running your web process type.

Scaling an application on Heroku is equivalent to changing the number of dynos that


are running. Scale the number of web dynos to zero.

Access the app again by hitting refresh on the web tab, or heroku open to open it in a
web tab. You will get an error message because you no longer have any web dynos available
to serve requests. Scale it up again.

Declare app dependencies


Heroku recognizes an app as a Python app by the existence of a Pipfile or
requirements.txt file in the root directory. The Pipfile file lists the app dependencies together
with their versions. When an app is deployed, Heroku reads this file and installs the appropriate
Python dependencies using the pipenv install --system --skip-lock command. To do this
locally, use Pipenv to create a virtualenv and install your dependencies.

34
Run the app locally- The app is almost ready to start locally. Django uses local assets, so first,
you’ll need to run collectstatic. Respond with “yes”. Now start your application locally
using heroku local, which was installed as part of the Heroku CLI.

Just like Heroku, heroku local examines the Procfile to determine what to run.
Open http://localhost:5000 with your web browser. You should see your app running locally.
To stop the app from running locally, go back to your terminal window and press Ctrl+C to
exit.

Push local changes- In this step you’ll learn how to propagate a local change to the application
through to Heroku. As an example, you’ll modify the application to add an additional
dependency and the code to use it.

Provision add-ons
Add-ons are third-party cloud services that provide out-of-the-box additional services
for your application, from persistence through logging to monitoring and more.

By default, Heroku stores 1500 lines of logs from your application. However, it makes
the full log stream available as a service - and several add-on providers have written logging
services that provide things such as log persistence, search, and email and SMS alerts.

To help with abuse prevention, provisioning an add-on requires account verification. If


your account has not been verified, you will be directed to visit the verification site. The add-
on is now deployed and configured for your application. You can list add-ons for your app.

To see this particular add-on in action, visit your application’s Heroku URL a few times.
Each visit will generate more log messages, which should now get routed to the papertrail add-
on. Visit the papertrail console to see the log messages: Your browser will open up a Papertrail
web console, showing the latest log events. The interface lets you search and set up alerts.

Start a console- You can run a command, typically scripts and applications that are part of
your app, in a one-off dynousing the heroku run command. It can also be used to launch a
REPL process attached to your local terminal for experimenting in your app’s environment.

35
To get a real feel for how dynos work, you can create another one-off dyno and run
the bash command, which opens up a shell on that dyno. You can then execute commands
there. Each dyno has its own ephemeral filespace, populated with your app and its dependencies
- once the command completes (in this case, bash), the dyno is removed.

Define config vars


Heroku lets you externalise configuration - storing data such as encryption keys or
external resource addresses in config vars. At runtime, config vars are exposed as environment
variables to the application.

Provision a database
The add-on marketplace has a large number of data stores, from Redis and MongoDB
providers, to Postgres and MySQL. In this step you will learn about the free Heroku Postgres
add-on that was automatically provisioned when your app was deployed.
A database is an add-on, and so you can find out a little more about the database provisioned
for your app using the addons command in the CLI.

Next steps
You now know how to deploy an app, change its configuration, view logs, scale, and
attach add-ons. Here’s some recommended reading. The first, an article, will give you a firmer
understanding of the basics. The second is a pointer to the main Python category here on Dev
Center:
 Read How Heroku Works for a technical overview of the concepts you’ll encounter
while writing, configuring, deploying and running applications.
 Read Deploying Python and Django Apps on Heroku to understand how to take an
existing Python or Django app and deploy it to Heroku.
 Visit the Python category to learn more about developing and deploying Python
applications.

6.2.3 DialogFlow
DialogFlow (formerly Api.ai, Speaktoit) is a Google-owned developer of human–
computer interaction technologies based on natural language conversations. The company is
best known for creating the Assistant (by Speaktoit), a virtual buddy for Android, iOS,

36
and Windows Phone smartphones that performs tasks and answers users' question in a natural
language. Speaktoit has also created a natural language processing engine that incorporates
conversation context like dialogue history, location and user preferences.

Voice and conversational interfaces created with DialogFlow works with a wide range
of devices including phones, wearables, cars, speakers and other smart devices. It supports 14+
languages including Brazilian Portuguese, Chinese, English, Dutch, French, German, Italian,
Japanese, Korean, Portuguese, Russian, Spanish and Ukrainian. DialogFlow supports an array
of services that are relevant to entertainment and hospitality industries. DialogFlow also
includes an analytics tool that can measure the engagement or session metrics like usage
patterns, latency issues, etc.

6.2.4 Facebook Messenger


Facebook Messenger (sometimes abbreviated as Messenger) is a messaging app and
platform. Originally developed as Facebook Chat in 2008, the company revamped its
messaging service in 2010, and subsequently released standalone iOS and Android apps in
August 2011. Over the years, Facebook has released new apps on a variety of different
operating systems, launched a dedicated website interface, and separated the messaging
functionality from the main Facebook app, requiring users to use the web interface or download
one of the standalone apps.

Users can send messages and exchange photos, videos, stickers, audio, and files, as well
as react to other users' messages and interact with bots. The service also
supports voice and video calling. The standalone apps support using multiple accounts,
conversations with optional end-to-end encryption, and playing games.

6.2.5 Telegram
Telegram is a non-profit cloud-based instant messaging service. Telegram client apps
are available for Android, iOS, Windows Phone, Windows NT, macOS and Linux. Users can
send messages and exchange photos, videos, stickers, audio and files of any type.

Telegram's security model has received notable criticism by cryptography experts.


They have argued that it is undermined by its use of a custom-designed encryption protocol
that has not been proven reliable and secure, by storing all messages on its servers by default

37
and by not enabling end-to-end encryption for messages by default. Pavel Durov has argued
that this is because it helps to avoid third-party unsecure backups, and to allow users to access
messages and files from any device. Messages in Telegram are server-client encrypted by
default, and the service provides end-to-end encryption for voice calls and optional end-to-end
encrypted "secret" chats.

6.2.6 Slack
Slack is a cloud-based set of proprietary team collaboration tools and services, founded
by Stewart Butterfield. Slack began as an internal tool used by their company, Tiny Speck, in
the development of Glitch, a now defunct online game. The name is an acronym for
"Searchable Log of All Conversation and Knowledge"

While no longer using an IRC backend, Slack offers a lot of IRC-like features:
persistent chat rooms (channels) organized by topic, as well as private groups and direct
messaging (again, historically based on IRC). All content inside Slack is searchable, including
files, conversations, and people. On the free plan, only the 10,000 most recent messages can
be viewed and searched. Slack integrates with a large number of third-party services and
supports community-built integrations. Major integrations include services such as Google
Drive, Trello, Dropbox, Box, Heroku,IBM Bluemix, Crashlytics, GitHub, Runscope, Zendesk
and Zapier. In December 2015, Slack announced their app directory, consisting of over 150
integrations that users can install. Users can add emoji buttons to their messages, which other
users can then click on to express their reactions to messages.

6.2.7 Dropbox
Dropbox is a file hosting service operated by American company Dropbox, Inc.,
headquartered in San Francisco, California, that offers cloud storage, file
synchronization, personal cloud, and client software. Dropbox was founded in 2007,
by MIT students Drew Houstonand Arash Ferdowsi, as a startup company, with initial funding
from seed accelerator Y Combinator.

Dropbox creates a special folder on the user's computer, the contents of which are then
synchronized to Dropbox's servers and to other computers and devices that the user has
installed Dropbox on, keeping the same files up-to-date on all devices. Dropbox uses
a freemium business model, where users are offered a free account with a set storage size, with

38
paid subscriptions available that offer more capacity and additional features. Dropbox Basic
users are given 2 gigabytes of free storage space. Dropbox Plus users are given 1 terabyte of
storage space, as well as additional features, including advanced sharing controls, remote wipe,
and an optional Extended Version History add-on. Dropbox offers computer apps for Microsoft
Windows, Apple macOS, and Linux computers, and mobile apps for iOS, Android,
and Windows Phone smartphones and tablets.

6.3 Implementation Details

1. First, create an account on Dialogflow(api.ai) and Heroku


 Go to https://console.dialogflow.com/api-client/#/login

Figure 6.1: Signing with DialogFlow

2. Second, using Dialogflow create an agent and follow the basic instructions and choose the
version as APIV1.

Figure 6.2: Creating Agent

39
2.1 Creating entities – To create entities go to the entity tab in the side Navigation Bar
and is specify the variables which has to be used in the intents such as pnr_no, train_no,

sys.date.

Figure 6.3: Creating Entity

2.2 Creating Intents- Specify the intent name and describe the expressions or templates
that a user can ask. Specify the parameter using the entities and create an action name,
which has to be the same defined in the Python file.

Figure 6.4: Creating Intent

40
2.3 Fulfilment – Refer section 3-4 of this implementation column to create the backend.
For any given intent the webhook can be enabled which fetched the data from the
Heroku server using the same parameter and action name described in the intent.

Figure 6.5: Fulfillment

2.4 Required – The small talks can be enabled using the prebuilt feature of Dialog flow.
The webhook has to be connected with the Heroku server using the HTTP and token.

3. Install Git and Heroku CLI using the help of documentation available in the Heroku and Git
website (install other required packages like pip and files like proc file, etc).
https://devcenter.heroku.com/categories/deployment

41
Figure 6.6: Required Files for Server

4. After configuring Git and Heroku CLI login into Heroku account. Create an app and specify
the default language to python.

Figure 6.7: Heroku Dashboard


4.1 Using python create a webhook to connect with the Dialogflow , fetch the
information from Railway API using HTTP and python request, store the JSON object
and return the response message https://devcenter.heroku.com/categories/python.

42
Figure 6.8: Python Code for Webhook Fulfillment

5. Integration- For integrating to Facebook Messenger or Telegram or any other applications


(refer the Dialogflow documentation), refer the following steps.
https://dialogflow.com/docs/integrations/

5.1 Create a Facebook account and developer account . After login in create an app and
integrate it to Dialogflow using a generated token. In the webhook section enable
message and message postback.

5.2 Telegram – Create a chatbot user using BotFather and get the token using which
integrate it to the Dialogflow.

43
Figure 6.9: Telegram Chatbot Configuration

6.3.1 Screenshots

Figure 6.10: Small Talk with the Chatbot on Telegram

44
Figure 6.11: Getting PNR and Train Status with the Chatbot on Telegram

Figure 6.12: Bugs with the Chatbot on Telegram

45
6.4 Summary

In system implementation, all the details regarding the simulation and implementation
of the project have been mentioned along with the sample coding for the weather forecasting
app. The screenshot of the every module is also given in the above section. Thus, the proposed
system has been executed successfully.

46
CHAPTER – 7
CONCLUSION AND FUTURE WORK

Thus, hereby we conclude that the proposed system removes all the drawback of the
existing system and enhanced way of fetching the information from Railway server. The
proposed system gives the improved version pre-existing system with better user interface, easy
to implement and other features. It provides the detailed solution to the existing system which
will save the time of the passengers and internet usage.

This paper successfully explains and implemented chatbot which can be used to get the
required information from Indian Railway. In the future, we will fix the bugs and include the
railway complaints and booking information. The key to effective chatbot use is to make sure
they enhance your customer’s experience. The use of Artificial Intelligence or Voice Feedback
feature will provide the real-time voice feedback system and easy to interact with the system.
The proposed system implemented the use of Natural Language Processing through which the
users can converse with the bot in the chat language as they talk with the humans.

47
REFERENCES

[1] Naveen Kumar M, Linga Chandar P C, Venkatesh Prasad A, Sumangali K, “Android


Based Educational Chatbot for Visually Impaired People”, Issue, 2016.

[2] Ravi Santosh Arvapally, Hasan Hicsasmaz, Wally Lo Faro, “Artificial Intelligence
Applied to Challenges in the Fields of Operations and Customer Support”, Issue, 2017.

[3] Daniel Toniuc and Adrian Groz, “Climebot: an argumentative agent for climate
change”, Issue, 2017.

[4] Sören Blom, Matthias Book, Volker Gruhn, “Executable Semantics of Recursively
Nestable Dialog Flow Speciation for Web Applications”, Issue, 2008.

[5] Guo Chunfang , Wu Hao, Sun Zhongyue Guan Zhongliang, “Study on the Public
Information Service Systems of Railway Industry”, Issue, 2010.

48

Vous aimerez peut-être aussi