You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 30 Next »
To set up a Telegram group for a major incident, do the following:
On the Administrator's computer
Create a record in the MID Server (sys_mid_server) table. To do so, click New and complete the fields of the new record as follows:
Field Mandatory Description Name Y A name of the infrastructure server, that will be displayed in the list, for example, TgBotMIDServer. Host Name Y A host name of the external server to connect to. User Y A user name who will have access to the functionality of the infrastructure agent. The user must have the admin role. - Download and set up Infrastructure Agent.
- On disk C, create a folder named MID_agent.
- Move the downloaded .exe and .env files to the created folder in Step 2.
In the .env file, set the following configurations:
Variable Value MID_API_USERNAME A user login, stated in the MID Server (sys_mid_server) record, created in Step 1. MID_API_PASSWORD A user password, stated in the MID Server (sys_mid_server) record, created in Step 1. MID_API_SERVERID ID of the earlier created record in the MID Server (sys_mid_server) table. MID_API_ENDPOINT Instance, that the MID server will run. To continue, ensure that Python and the Telethon library are installed on your computer. To install the library, write in the command line:
python3 -m pip install --upgrade pip python3 -m pip install --upgrade telethon
Create a Telegram client.
To create a Telegram client, complete the steps below:
1. Get registered in Telegram, using any client name.
2. Follow the https://my.telegram.org link for authorization.
3. Complete the form on the https://my.telegram.org/apps website to receive the URL and parameters of api_id and api_hash needed for the users' authorization.
It is possible to link only one api_id to the telephone number.
- Download a script archive, and add the scripts to the SIMPLE_MID_SERVER folder downloaded at the Step 1.
The four scripts in the folder are:- createGroup – to create a group,
- cancelGroup – to restrict commenting upon the completion of the incident and changing its state to Completed,
- deleteGroup – to delete a Telegram group,
- clientInformation – to store api_id and api_hash.
- Open the “clientInformation” script and add the api_id and api_hash values received when creating a Telegram client.
Create a .py file and add the following test script there:
Test script for Telegramfrom telethon import TelegramClient import clientInformation client = TelegramClient('swarming', clientInformation.api_id, clientInformation.api_hash) async def main(): me = await client.get_me() print(me) with client: client.loop.run_until_complete(main())
- Place the created file in the MID_agent folder created earlier.
- Run manually the Python test script using the Telethon library. To do so, in the command line, go to the directory of the created folder and execute the command
python script name.py
. - Enter the mobile phone number that the Telegram account is registered with and then a verification code. As a result, the system returns information about the current user.
- Complete the user's authorization that the system will require. As a result, in the SIMPLE_MID_SERVER folder, a “swarming.session” file is created.
On the SimpleOne instance
- Create three scripts in the MID Scripts (sys_mid_script) table. To do so:
- In the MID Scripts (sys_mid_script) table, click New. A new script form opens.
- Add “createGroup” as the name of the script.
In the Script field, add the path to the script on your computer and the parameters, as shown below.
Repeat the Steps a-c to add “cancelGroup” and “deleteGroup” scripts.
createGroup Script python C:\User's Path\createGroup.py $botUserName $incidentDispalyName $titleMessage $mainInformation cancelGroup Script python C:\User's Path\cancelGroup.py $chatId deleteGroup Script python C:\User's Path\deleteGroup.py $chatId
Go to the System Properties (sys_property) table, set the following values for the properties:
System Property Value itsm.telegram_bot.swarming_session true itsm.telegram_bot.mid_server_id MID Server Record ID itsm.telegram_bot.mid_create_group_script_id MID Scripts Record ID for a group creation (createGroup script) itsm.telegram_bot.mid_close_group_script_id MID Scripts Record ID for comments restriction (cancelGroup script) itsm.telegram_bot.mid_delete_group_script_id: MID Scripts Record ID for a group removal (deleteGroup script) Run the MID agent from the file in the earlier created folder MID_agent.
- Go to a major incident form. Click Start Swarming on the top of the page.
The modal window that appears, contains a list of the recipients of the invitation to the Telegram group. Clicking Start Swarming on the modal window initiates a Telegram group, and a createGroup record appears in the MID Queue (sys_mid_queue) table. The Description field of the createGroup record is automatically filled with the incident number.
Field Description Request BotUserId, the incident name and the first message content that is sent to the Swarming Session participants Server TgBotMIDServer. Script The name of the executed script Response A chat ID created and a lint to the group. The chat ID is stored in the Telegram Chat Bindings with Incident (sys_telegram_chat_bindings_with_incidents) table. State Done when executed Processed at Date and time of the script execution Description Incident number If the connection with the Telegram bot is lost or failed, (see the ITSM Telegram Bot article for more information) a toast message “Telegram bot not connected” appears, and a modal window does not open.
When the incident state is changed to Completed, a closeGroup record in the MID Queue (sys_mid_queue) table appears. Since then, commenting in the group is unavailable, but the participants can read the messages.
Field Description Request A chatId parameter Server TgBotMIDServer Script The name of the executed script Response No response State Done when executed Processed at Date and time of the execution Description Empty When the incident state is changed to Closed, a deleteGroup record in the MID Queue (sys_mid_queue) table appears. The linked Telegram group is deleted.
Field Description Request A chatId parameter
Server TgBotMIDServer Script The name of the executed script Response No response State Done when executed Processed at Date and time of the execution Description Empty
Отключить проверкуПремиальные предложенияОтключить проверкуПремиальные предложения
- No labels