Building a Telegram Bot with Node.js and fully powered by AWS
I consider that the best way to learn new concepts on software is building things that connect with real-world use cases. The process consists of putting out a minimum viable project that's "good enough" and iterating over the existing code to add more features.
On my case, the resulting project of one weekend was a simple but useful bot for Telegram developed with Node.js and entirely powered by AWS that informs the balance available of the card used to pay the public bus service. In case that wants to interact with the bot, you can found on Telegram with the name of "Saldo Red Bus".
Why choose AWS how to a provider?
The answer is they provide me some obvious benefits like flexibility, scalability, security, and the most important is the model pricing of "pay as you go". This is useful when you're starting from scratch.
Step by Step
The first step was to start coding each scene of the bot with the help of Telegraf. This is an excellent framework for Node.js to integrate with the native API of Telegram. The resulting code only has 90 lines in total. Not too bad, right?.
Once the development finished, it was time to verify the correct performance of the entire application on multiple devices and users. The last step and the most important was designing and implement one architecture on AWS taking as a pillar the high availability of the system to moving our bot from a development environment to the cloud and attend all the petitions 24x7. The below diagram proves that requirement. With the ELB set at the top of the structure, you're accepting incoming traffic from all the clients to each registered targets (EC2 instances) on each availability zone.
Spreading the code
If you want to look at the entire code, you can find this and much other exciting projects on my personal Github. New pull requests with improvements are well received.