Skip to main content
Version: 1.12.1

Bot Connection

The scheme of the bot connection with the SimpleOne instance is as follows:

  1. 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.
  2. 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.
  3. 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:

  1. The user writes to the Telegram bot, a request comes to the endpoint.
Request body example
{"update_id":301617650,
"message":{
"message_id":34235,
"from":{
"id":1344171102,
"is_bot":false,
"first_name":"John",
"last_name":"Doe",
"username":"john.doe",
"language_code":"en"
},
"chat":{
"id":1322171102,
"first_name":"John",
"last_name":"Doe",
"username":"john.doe",
"type":"private"
},
"date":1676130018,
"text":start"
}
}
  1. 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.
  2. 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.
note

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}