“Railway Buddy” Chatbot Case Study (Dialogflow, Python)

You are standing at the railway station, waiting for your train to come. Unsure when it will come, you grab your phone to find the live status of the train. You search on google, land on some website providing live status, give your train number and find the current status of the train.

Wouldn’t be it easier if you could just ask Google Assistant and find the live status of your train?

You don’t have to search for the website, fill up form and fetch train status. Just say Ok Google, talk to Railway Buddy, then ask for the live status of the train. No hassle, no typing, instant response!

Our traditional train websites have been labor intensive. Users are required to enter details, select from the drop-down menu, select different options to obtain the result.

It is extremely time consuming and frustrating. Often results are not clear due to overlapping of various in-app ads or the ads on the website. A single innocent click lands you on a completely different page, installs apps without your permission and occupies space on your device. Often, it slows down the phone due to storage of the unnecessary files in form of cache, cookies.

The other way was to download specific apps for getting the updates or maneuver around numerous websites, repeats the same process of entering several details until you receive the result that you want. Apps required to be updated regularly and often two apps work in conjunction to provide a single result.

We wanted to make the whole process easier, fast and fun!

Solution we proposed

We wanted to develop a simpler interface that works with minimal user action, eliminates the dependency on several other websites, and freedom from the installation of third-party apps.

We considered the two factors before proposing a solution. i.e Reach and Accessibility

The solution developed should have the capacity to reach to the majority of people with easy access and the best way is through smartphones.

We (Pragnakalp Solutions) devised a solution by replacing the website interface with a chat/voice based interface. The user can get the information consisting of various train-related inquiries with one simple voice-based command or through chat based interface.

The functionality of the bot

Railway Buddy helps users find information about the Indian Railways like train running status, trains between stations, train time at the station, train live arrival time at the station, coach position, PNR status, and train schedule.

You can search train information by train number or name. For example: “19019” or “Dehradun Express trains”.

“19019 status” or “Dehradun Express status” to get train running status.

“19019 route” or “Dehradun Express route” to get the train timetable.

“19019 at Surat” or “Dehradun Express at Surat” to get the arrival time of the train at that station.

“19019 coach position” to get the train coach position.

“19019 live arrival time” to get the live arrival of the train at the given station.

“PNR 1234567890” or “PNR” to get the ticket reservation information.


Major challenges faced were:

Intent Mapping: Often different sentences means the same. The syntax and arguments are different but they have same semantics (Meaning) We needed to connect all the variations to generate a response.

Like what is the status of train no 19039
19309 train status
Where is train no 19039 currently

Generate meaning from a group of words: A group of words when used together form meaning and understanding the semantics of the sentences are of prime importance. This understanding will help the machine to generate an effective response.

Handling the spelling mistakes: It is pretty possible that users might not type the exact same train name or station name. Also, sometimes text to speech generates different spelling than expected. To handle such cases, we used fuzzy matching and integrated spell checking using Fuzzywuzzy. ( The SpellCheck module we created can be found on our github repository: Dictionary based spell checking in Python)

Display the information in a simple manner with one-tap options for other related information for same train:

Display related information like Coach Position, Arrival Time, Schedule Time.

Technology stack used

Selection of chatbot development platform was critical and the factors that affected the selection were: performance, ease in development and publishing platforms integration.

Dialogflow, a Google-owned developer of human-computer interaction technologies based on natural language conversations was the best fit

One of the major reason was its capability to be integrated with a number of platforms like Facebook Messenger, Amazon Alexa, Telegram, KiK, and Microsoft Cortana. Along with it the In-depth analytics report provided by Google is available to the developer, who can understand the patterns of the usage of the user, introduce ways to simplify it further. In addition to the error reports with each log help back-end teams to eliminate bugs and ensures there is a minimum amount of downtime and latency.

We used Python as a back-end language. Python with its efficient features, numerous frameworks, libraries, and syntax similar to the English language makes it the best fit to design a bot.

To save train time table, stations details and platforms data – we used MySQL.

We connected with several third-party APIs using webhook developed in Python to fetch real time information like live status of trains and PNR information.

Chatbot accessibility

Utilizing multiple chatbot channel support of Dialogflow integration, we made the chatbot available for Google Assistant, Facebook Messenger, Telegram, Website and Skype.

Google Assistant: You can invoke the app by saying “Talk To Railway Buddy”
Telegram: You can message @railway_buddy_bot
Facebook: https://www.facebook.com/RailwayBuddyBot/
Website: http://www.railwaybuddy.site/
Skype: https://join.skype.com/bot/fb99c788-d485-4939-8399-fe1b23b20e82 (Work in progress. Responses are not fully setup yet.)

Demo on Google Assistant

Bot Usage

The bot was firstly launched on Google Assistant where it started receiving very good response. Fueled by Google Assistant’s discovery feature (where Assistant suggests app based on user’s query), many people landed us on our site to find live status of the train and PNR check.

On some fine days bot even received 150+ users. The bot usage should rise further as we are still working on to improving the bot.

We hope you like our Chatbot “Railway Buddy“. Any suggestions/feedback are more than welcome.

If you are looking for any assistance in Chatbot Development, look no further. With our experience in developing several in-house chatbots, we have developed expertise and can assist you in all your business goals leveraging chatbots. Feel free to contact us with your requirement.