How we made Jira and Telegram friends

  • Introduction to support and Jira SD

  • What are Telegram bots and how to work with them

  • User identification

  • Basics of interacting with the Jira API

  • Results

INTRODUCTION TO SUPPORT AND JIRA SD

When talking about support, I mean the internal technical support of the VSK Insurance House, which processes requests from our employees. All issues related to IT products and technical equipment are resolved by technical support specialists.

Support requests should always be stored somewhere. This makes them easier to track and process. Our company uses Jira ServiceDesk (hereinafter referred to as Jira, Jira SD).

When the user (hereinafter we will call him initiator) contacts support, his request is recorded in the form of an application. Our company provides several channels for creating applications:

  • User portal

  • Mailbox

  • Support hotline

Using any of these channels, the initiator can create a request and wait for its decision.

It is important to note that all three channels allow you to uniquely identify the initiator: due to this, the initiator can always receive up-to-date data on their applications, and performers can contact the initiator.

Statement of the problem

Create an application, check its status, receive notifications – all this functionality is available only from the employee’s workplace. As soon as an employee leaves home or loses access to the work computer, contact with support is lost (not counting the hotline, which does not handle notifications).

These restrictions especially affect employees working in different time zones. For example, when an employee from Khabarovsk finishes his working day, support from Moscow is just leaving for work. Therefore, an employee from Khabarovsk will learn about all changes in his applications only the next day, when he comes to work.

To solve this problem, we have created a service that allows you to create applications, track their statuses, add comments and receive notifications via Telegram. Using this service, initiators can quickly find out that their request has been resolved or that a support specialist requires additional information.

WHAT ARE TELEGRAM BOTS AND HOW TO WORK WITH THEM

Telegram bots were perfect for solving our problem!

The difference between a regular user account and a bot account is that bots cannot exist separately from users. And user accounts interact with Telegram through the Telegram API, and bot accounts interact through the Telegram Bot API.

To create bots, the main bot BotFather is used. It creates a bot account and passes an authorization token to the owner user. The bot program is usually placed on a server, where it runs 24/7, performing its intended functionality.

To give an example of how the bot works, I’ll tell you about two main processes: sending a message on behalf of the bot to a Telegram user and receiving information about any user action in the chat.

Sending a message

To send a message you need the following information:

The Bot API request looks like this:

https://api.telegram.org/bot{token}/sendMessage?chat_id={chat_id}text={text}

And the process diagram looks like this:

By “additional data” I mean keyboards, text formatting, link formatting, etc.

Chat activity tracking

When a user performs an action in Telegram, an event is logged. Chat participants (including bots) can react to these events. For example, subscription to a channel is an event. Sending a message is also an event. Pressing a button is an event. And so on.

Information about events is stored on Telegram servers. In order for the bot to respond to these events, you need to request them and update them in a timely manner. There are two tools for this: Webhook and Polling.

Webhook (hereinafter referred to as webhook) must be deployed on a server separately from the bot. Telegram has certain requirements for the configuration of such servers, you need to take this into account. After deployment, the webhook needs to be registered. After this, Telegram will contact our webhook when events that interest us occur (for example, events in a chat with our bot).

Polling is a simpler method. This is a process in which our service itself will poll Telegram to find out if there are new events. For example, once every 2 seconds it comes to Telegram and requests recent changes, after which it independently parses them.

In any case, having received information about a certain event, the bot can react in some way (for example, send a message in response or launch some kind of internal process).

The diagram will look like this:

You can learn more about creating bots and interacting with them on free resources, for example on Stepik: https://stepik.org/course/120924/syllabus in the course of Mikhail Kryzhanovsky or on GitHub by user MasterGroosha: https://github.com/MasterGroosha/aiogram-2-guide

These are not the only sources, but in my opinion they are the most convenient for beginner Telegram bot administrators.

USER IDENTIFICATION

As I wrote above, when creating tickets in Jira SD, the initiator is always uniquely identified. The application is associated with the company employee's account. Therefore, specialists have access to extended information about the initiator (for example, a specialist can find out which branch the employee works in, see his email address or corporate telephone number for communication).

If we want to create an additional channel for creating and monitoring applications through Telegram, then we need to learn how to determine who exactly is writing to us. Telegram is concerned about the anonymity of its users, so it is impossible to find out who owns the account using built-in methods. But, to create applications, we definitely need to be 100% sure that the person on the other side of the screen is an employee of the company.

To solve this problem, we introduced a registration system. Our bot communicates only with registered users.

To register, the bot sends an authorization code to the employee’s corporate email. If the user returns the code to the bot, then we create a connection between the user’s Telegram account and the employee’s account. Of course, this information is available only to our service and is not published anywhere.

Example: there is a man (let him be called Artyom Almazov). He has a Telegram account Abrikos_2022. In addition, Artyom works at the VSK Insurance House under the login AlmazovA. After registration, the connection will be saved on the server: TelegramID account Abrikos_2022 → Account ID AlmazovA. And whenever the user Abrikos_2022 does something in the bot, we will assume that these actions are performed by an employee under the login AlmazovA.

The diagram looks like this:

BASICS OF INTERACTION WITH JIRA API

To create requests and receive information on them, we need to configure the interaction between our service and Jira SD. The easiest and most convenient way to do this is through the API.

Information about methods of working with Jira is available on the page https://docs.atlassian.com/.

To work with Jira via the API, you must be authorized. To do this, we created a separate user (specifically for our system) and gave him the necessary rights.

Having received all access, you can send requests to create applications/receive information about the application. The request template looks like this:

https://jira.vsk.ru/rest/api/2/{method_name}

Using API requests you can:

  • Create an application (including on behalf of a user)

  • Add a comment

  • Change application status

  • Upload application information

RESULTS

Let's put together everything that was described above. The goal is for users to interact with Jira SD via Telegram.

  1. We create a bot in Telegram using BotFather.

  2. Users who write to us must register through corporate email. The result is that the service can correlate a Telegram account with an employee account.

  3. Setting up interaction with Jira. The result is that the service can work with Jira via the API.

  4. We are setting up interaction with Telegram so that the service can send messages to users and respond to user actions.

The overall result is as follows: we have created a service with which employees can create requests, check their status, write comments, and also receive notifications. Employees are provided with prompt and high-quality support, and it is easier for a support specialist to get additional information and work!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *