-
Notifications
You must be signed in to change notification settings - Fork 0
Home
StatefulBot is a PHP framework to easily create a Telegram Bot. This framework is specifically built to solve the state management problems!
Through this wiki you'll find out how to use it, some basic architectural aspects and all the implementation specifications.
You'll finally understand how to use the framework to easily create complex Telegram Bots.
When you are dealing with Telegram Bot development, you notice that each bot request is stateless, so every request is new to the Telegram Bot webhook. If you want to create a complex procedure in your Telegram Bot, you need to handle it manually, checking that each request is in the right moment of procedure and responding accordingly, changing the state.
To give a practical example, imagine you want to develop a Telegram Bot that asks you for your name, your nickname and your email address, in this specific order, one by one.
Starting from a /start command, the bot sends you the message Send your name, so you send your name Giuseppe. When you send your name, the hook basically doesn't know that you are in this specific procedure, but it sees every command as equally new. So you need to keep the state of your procedure and check it every time a message (or a request, more generally) is sent to the bot, to check if the message sent is consistent with the specific state of the bot, and then updating the state.
Implementing this logic manually can be challenging, but with this framework the main aspects are handled automatically. You only need to follow some basic rules I will explain later in this wiki (link).