Updates from R34
The R34 release of Zweb Booking Bot is meant to significantly improve the overall experience, and allow for the presence of a whole companion web application: the admin panel. The panel will be packed with the bot starting from version R36, but its use is completely optional. The configuration structure has undergone some major changes and included some new entries in order to prepare the bot for future updates (such as the admin panel) and at the same time to improve the code organization.
Configurable Telegram Keyboard (advanced topic)
Starting from R35, Service Managers will have the option to change the bottom Telegram menu keyboard layout and buttons, via a separate JSON configuration file. In order to activate a custom bottom keyboard, follow these steps:
- Create a new JSON file (or modify the one bundled with the package), preferably under
assets/user_config
, let's call itcustom_menu.json
. - Uncomment (remove the hash "#") from the line
USE_KEEPER_CUSTOM_MENU
of the .env file and insert the path of your JSON menu file inside the double quotes, e.g.USE_KEEPER_CUSTOM_MENU="assets/user_config/custom_menu.json"
This lets the bot know you want to replace the standard elements of the menu keyboard with the custom entries shown
- Give the JSON file this type of structure, as in the bundled JSON menu file:
{ "entries": [ [ { "command": "active_reservations" }, { "command": "cancel_reservation" } ], [ { "command": "control_panel" } ], [ { "command": "edit_reservation" }, { "command": "all_active_reservations_text" } ], [ { "command": ".list CON", "raw": 1 } ] ] }
In this file each couple of square brackets represents a row of the keyboard, while each couple of curly brackets inside it represents a single button. The value after command represents the associated command that button refers to; remember: this command has to match the property name (the label) of a keeper command or a user command as in the main config file, for example:
"control_panel"
. Wrong values in the menu file may easily lead to crashes of the bot. By default, the values must match commands like "help" or "location", those that are shown with a leading slash "/" in the Telegram Keyboard and are technically called Telegram commands; you must not insert the slash, the bot will do it for you, and will show the corresponding JSON text value of the command as in the main config file: for instance, if the main config file contains the following string"active_reservations": "my_reservations"
in the user commands section, if you enter"command": "active_reservations"
inside the menu file, the bot will show a button with text:/my_reservations
. However, you can also declare some commands as "raw", by inserting the property"raw" : 1
like shown above: this way, the command will be interpreted as a normal, custom text command as is and will be shown unaltered in a button. In the example above, with.list CON
we leverage the ability of the bot to list all the reservations relative to the service whose code is"CON"
(in the default main config file, this refers to the sample service named "Consulting"). Even in this case, the 'raw' text command must match a pattern that has a meaning, that is must match one of the main config file commands. For example, you can create a menu button with{"command": ".get latest 20", "raw": 1}
to see a list with the last 20 reservations.
Main updates in the JSON end .env config files
Here is a short list of the main news:
- From now on, it is recommended to put the config file inside
assets/user_config
folder, while not mandatory. - The first level options appearing in the json file will display 1 or 0 instead of true or false, for smarter compatibility with the admin panel and the database
- All text strings concerning time have been moved under the
text
object; this way, all the strings will be translatable from the admin panel editor, and the config file is more intuitive; - Duration options can be specified inside a service to override the general duration options (it is recommended, however, to keep at least one generic duration option: the bot needs to find at least one duration option in the hierarchy)
- Now some duration options can be hidden from customers and shown only to the service manager, in order to let them reserve or block a service more easily, especially if that duration is not suitable for the customer or does not make sense. In order to make a duration option reserved, add the property:
"reserved_to_keeper": 1
inside a duration option object. ask_note_text
: if this property is put inside a service object, instead of asking for confirmation of the reservation, the user will receive this text message and be asked to write a note: the note will override their personal name as reservation name in the ticket AND in the database!admin_color
: This will be used, inside each service, to show a colored curve of the reservations month by month in a chart that will appear in the homepage of the admin panel. If missing, default color is blue.day_off_code
: Here you have to specify a short, upper/snake-case code, like "DAY_OFF", that is how you the day off pseudo-service is recognized in the bot. Recommended for future compatibility: maximum 7 characters.PRIMARYCONFIG
: this options has been added in the .env file. Now you will be able to specify 'db' or 'file' as your main options source. Until the admin panel release, only 'file' will be working and you don't need to change anything.- New translation strings have been added to the text object of the json config file.
- Telegram Id(s) belonging to the service manager(s) can now be inserted only inside the .env file, just like the other sensitive data.
- A service's
short_name
property is to retain only a cosmetic function. Wherever it was used,code
property is now used instead.