Telegram bot notifications
To make the Telegram bot work, need to create it on the Telegram platform and get its parameters: bot secret token, chat ID and bot name. The bot token is received by the user when creating the bot. The chat ID (mandatory) and the bot name (for reference purposes) are obtained by a special API request. Only one chat is supported.
The following queries are used for management:
getbottgchatid - get information about the bot. Extra options are:
- k - user session ID;
- token - secret bot token, entered by the user.
If the information is received successfully, the response will be as follows:
<bottgchatid type="telegram bot" chat_id="-123456789" chat_title="Test bot group" botname="Vutmaster101" /> |
Where:
- type - notification type, always "telegram bot";
- chat_id - ID of the Telegram chat or group;
- chat_title - group name or name of the user chat;
- botname - name of the Telegram bot.
If an error occurs during the process:
<error type="error" description="Bot not found"/> |
Once the bot parameters are defined, create a new notification (or change one):
addbot - creat the Telegram notification. Required parameters are:
- k - user session ID;
- id - element ID if the element is edited, when creating a new one this field is absent;
- type - notification type, always "telegram bot";
- name - name of the element, entered by the user;
- token - secret bot token, entered by the user;
- botname - bot name received from getbottgchatid request (optional);
- chat_title - group name or name of the user chat received from getbottgchatid request (optional);
- chat_id - chat ID received from getbottgchatid request;
- message - message text template, the length is not more than 2*1024 characters.
If a new element is successfully created, the response contains the element identifier, and looks like:
<error type="no error" id="610001" /> |
When creating a new notification (id is not specified), all the listed parameters are mandatory. When changing, only modifiable parameters can be specified. Empty parameters are not allowed.
testmessage - make a test Telegram message, without creating a new element. Required parameters are:
- k - user session ID;
- type - type of test notification (telegram bot);
- name - name of the element, optional;
- token - secret bot token, entered by the user;
- chat_id - chat ID received from getbottgchatid request;
- message - message text template, the length is not more than 2*1024 characters.
getelement - read the element. Required parameters are:
- k - user session ID;
- id - element ID.
The response contains information about the element:
|
delbot - delete element. Extra options are:
- k - user session ID;
- id - element ID.