Bot Connection
The scheme of the bot connection with the SimpleOne instance is as follows:
- To create a Telegram bot, the system administrator sends a command to @BotFather in Telegram. When the bot is successfully created, a bot token is generated.
- The administrator creates an endpoint in the API Action table. When a SimpleOne instance connects to a bot on the corresponding page, the previously generated bot token is used and the endpoint is specified.
- After saving, a request is sent to the Telegram bot with the setWebhook method to establish a connection. The endpoint URL is passed in the request.
User authentication
The algorithm for connecting users to the Telegram bot is as follows:
-
The user writes to the Telegram bot, a request comes to the endpoint.
Request body example
-
Based on the chat ID, the instance checks whether there is a record that binds a user and chat in the Telegram Chat Bindings with Users (itsm_telegram_chat_bindings_with_users) table.
- If there is a corresponding record, the bot works further according to the script.
-
If there is no record, then the Share your phone number button appears in Telegram bot, after clicking on which a request with the key contact and phone_number is sent to the endpoint. The system searches for a user record with the similar phone number. When the record is found, a record is created in the Telegram Chat Bindings with Users (itsm_telegram_chat_bindings_with_users) table.
If there is no user with the phone number specified in Telegram on the instance, the bot displays the following message:
The number is not registered in the system. Log in from another number or contact support {support email}
If the user account is inactive or locked out, the bot displays the following message:
The account is not active. Contact support {support email}