Overview
In the era of digital India, creating website is the most common thing one can see wherever he goes. To attract clients an attractive website is a necessary thing, which can be achieved by adding exciting features into it. Let’s talk about one: Push Notifications.
Before jumping to problem, let’s fresh up few concepts. What is simple web application? Answer is: A web application is application software that runs on a web server (source: wiki). Client initiates request to server and server response back to client over HTTP or some protocol. This is a standard practice for having conversation on internet. And in most of the cases it is initiated by client. We may consider notifications is a different case in which server sends information to client (or server initiates the conversation). A traditional HTTP protocol follows client-server terminology, so one thing pops in your mind that you must need something different! Yes, there are multiple options available as a solution of this problem.
We can use Redis pub/sub model. The functionality of pub/sub channels in Redis is wonderful. You just need to subscribe client to the channel in server, and anytime there is an update in server, the clients automatically listen to that. Redis is widely used, is well maintained, is easy to use, and is designed for very large scale applications.
AWS SNS is also a good option. Web socket can also be a good option. Let’s not dive deeper into the ocean. There are multiple options available if you want to build from scratch.
In our case we will use in-built library provided by telegram for this purpose.
Goals
Our Goal is to achieve/offer understanding of how telegram bot works, what features they provide and how to access them.
Specifications
P.S. Current implementation is just a piece of iceberg. There are still plenty of information out there which need to get mined from the ocean!
Let’s understand feature step-by-step.
Open Telegram and search for telegram bot in UI.
Register yourself for bot and get API-Key which will play an crucial role in our project. p.s. You can set bot description, profile picture and other things.
Now you can perform lots of task by writing scripts. Let’s discuss a few.
You can have detailed information about all methods over here.
Get Message:
To know what messages bot has received we have 2 option:
1. periodic pulling (get Updates) or 2. Redirect instantly to API (you need to set up web hooks for this option).
Send Message:
1. define telegram bot
2. pass params in bot.sendMessage(params) function
Create groups, channels, private messages, permissions, forms and many more features are available. To learn about them please visit documentation page.
Milestones
“Winter is coming, and when the Long Night falls, only the Night’s Watch will stand between the realm and the darkness that sweeps from the North.”
- Game of thrones.
P.S. This is just a beginning. There is still plenty of things (room) in the bottom.