How to connect YouTrack to Albato

YouTrack: Project management integrations
YouTrack
·
9/19/2023
·
3 min. read

YouTrack - everything in one place. Track tasks, manage projects, maintain a knowledge base, support your customers, collaborate, and deliver great products.

Available triggers

Triggers are the events that trigger the automation, All triggers run in real time, i,e, data is transferred in the moment the event occurs

  • Issue created
  • Issue updated

Available actions

Actions are what Albato performs when your automation is running, Actions also allow you to transfer data to other apps and systems

  • New issue
  • Update issue
  • Find an issue

Before setting up integrations with YouTrack, connect the tool to Albato.

To do this, go to the Apps section and click the Add a connection button.

Example.png

Select the app and click the Add a connection button.

YouTrack.png

Come up with a name for your connection.

Enter your Domain and API key.

Click the Continue button.

YouTrack (1).png

How to get API key

Go to your YouTrack account.

Either copy the ID from the browser address bar or enter the name of the workspace you used to create the account. Go to the list of system users, select the user who will access the integration, and open the Account Security tab.

Next, create a new token and copy its value.

YouTrack (2).png

Paste the token into the Albato connection field.

The first part of the connection is finished. To receive tickets from YouTrack, we need to create two more workflows in YouTrack, write our JS code there and insert the webhook from the connection into them.

Go to the Workflows tab.

YouTrack (3).png

Create a new Workflow.

YouTrack (4).png

Set a name for your Workflow

YouTrack (5).png

and select the rule:

YouTrack (6).png

Paste the following code:

const albatoHook = '{{albatoHook}}';
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const http = require('@jetbrains/youtrack-scripting-api/http');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');

function periodToHours(period) {
  return period ? (
    period.getMinutes() / 60 +
    (
      period.getHours() +
      period.getDays() * 8 +
      period.getWeeks() * 40
    )
  ) : 0;
}

function formatValue(value) {
  if (typeof value === 'object' && value !== null) {
    switch (value.$$type) {
      case 'User':
        value = value.fullName;
        break;
      default:
        if ('getPeriodType' in value) {
          value = periodToHours(value);
        } else if (value.constructor.name === 'ImmutableIterableWW') {
          const array = value;
          value = [];
          array.forEach(item => value.push(item.name));
        } else {
          value = value.name;
        }
    }
  }
  return value === undefined ? null : value;
}
exports.rule = entities.Issue.onChange({
  title: workflow.i18n('Send webhook to Albato'),
  guard: function(ctx) {
    return ctx.issue.becomesReported && ctx.issue.isReported;
  },
  action: function(ctx) {
    const issue = ctx.issue;
    const fields = {};
    for (let field in issue.fields) {
      fields[field] = formatValue(issue.fields[field]);
    }
    const tags = [];
    issue.tags.forEach(nameTag => tags.push(nameTag.name));
    const payload = {
      'event': 'newTicket',
      'ticketUrl': issue.url,
      'tags': tags,
      'id': issue.id,
      'summary': issue.summary,
      'description': issue.description,
      'projectId': issue.project.key,
      'project': issue.project.name,
      'dateCreate': issue.created,
      'dateUpdate': issue.updated,
      'fields': fields,
    };
    console.log(issue.tags);
    const connection = new http.Connection(albatoHook, null, 2000);
    connection.addHeader('content-type', 'application/json');
    const response = connection.postSync('', null, payload);
    if (!response.isSuccess) {
      console.warn('Failed to post webhook to Albato. Details: ' + response.toString());
    }
  },
});

This code catches only the creation of tasks, and the following code catches changes to tasks. You can work in one rule, or you can create an additional rule and add the following code to it:

const albatoHook = '{{albatoHook}}';
const entities = require('@jetbrains/youtrack-scripting-api/entities');
const http = require('@jetbrains/youtrack-scripting-api/http');
const workflow = require('@jetbrains/youtrack-scripting-api/workflow');

function periodToHours(period) {
  return period ? (
    period.getMinutes() / 60 +
    (
      period.getHours() +
      period.getDays() * 8 +
      period.getWeeks() * 40
    )
  ) : 0;
}

function formatValue(value) {
  if (typeof value === 'object' && value !== null) {
    switch (value.$$type) {
      case 'User':
        value = value.fullName;
        break;
      default:
        if ('getPeriodType' in value) {
          value = periodToHours(value);
        } else if (value.constructor.name === 'ImmutableIterableWW') {
          const array = value;
          value = [];
          array.forEach(item => value.push(item.name));
        } else {
          value = value.name;
        }
    }
  }
  return value === undefined ? null : value;
}
exports.rule = entities.Issue.onChange({
  title: workflow.i18n('Send webhook to Albato'),
  guard: function(ctx) {
    return !ctx.issue.becomesReported && ctx.issue.isReported;
  },
  action: function(ctx) {
    const issue = ctx.issue;
    const fields = {};
    for (let field in issue.fields) {
      fields[field] = formatValue(issue.fields[field]);
    }
    const tags = [];
    issue.tags.forEach(nameTag => tags.push(nameTag.name));
    const payload = {
      'event': 'changedTicket',
      'ticketUrl': issue.url,
      'tags': tags,
      'id': issue.id,
      'summary': issue.summary,
      'description': issue.description,
      'projectId': issue.project.key,
      'project': issue.project.name,
      'dateCreate': issue.created,
      'dateUpdate': issue.updated,
      'fields': fields,
    };
    console.log(issue.tags);
    const connection = new http.Connection(albatoHook, null, 2000);
    connection.addHeader('content-type', 'application/json');
    const response = connection.postSync('', null, payload);
    if (!response.isSuccess) {
      console.warn('Failed to post webhook to Albato. Details: ' + response.toString());
    }
  },
});

Important!

Now you have to replace in each rule where you inserted the code, in the very first constant "const albatoHook = '{{albatoHook}}';", the value {{albatoHook}}, with the actual webhook from the previously created connection. Copy the webhook from the connection you created to Albato.

YouTrack (8).png

Insert a webhook into each process you create:

YouTrack (7).png

Next, you need to link your Workflow to the project you need. To do this, go back to your Workflow list, select the Workflow you created and link it to the projects:

YouTrack (9).png

Done! Now you can use the YouTrack in your integrations.


YouTrack

Related articles

Show more
Slack, CRM, and Task Manager Integrations: The Key to a Smooth Workflow
CRM
4 min. read

Slack, CRM, and Task Manager Integrations: The Key to a Smooth Workflow

No more manually creating tasks and notes, and no more wasting valuable time. With the help of automation, you can stay organized and focus on what matters most.

How to set up HubSpot Integrations with 800+ Apps
HubSpot
2 min. read

How to set up HubSpot Integrations with 800+ Apps

Learn how to integrate HubSpot with 800+ apps through Albato. Step-by-step guide to HubSpot integration and connecting your favorite business tools.

Connect Digital Samba with Albato | Elevate Your Webinar Experiences
3 min. read

Connect Digital Samba with Albato | Elevate Your Webinar Experiences

Digital Samba is a powerful platform for hosting and managing webinars, designed with user-friendly features and scalability in mind. See how Albato can help you enhance the app’s usability!

Connect Intento with Your Favorite Apps | Optimize Your Translations with Albato
3 min. read

Connect Intento with Your Favorite Apps | Optimize Your Translations with Albato

Intento is an AI-powered platform for managing multilingual content and optimizing translation workflows. See how Albato can help you enhance the app’s usability!

How to connect ClickUp to Albato for seamless Integrations | ClickUp Integrations Guide
4 min. read

How to connect ClickUp to Albato for seamless Integrations | ClickUp Integrations Guide

Learn how to set up ClickUp integrations with Albato in our step-by-step guide. Unlock powerful ClickUp integrations & automate workflows to boost productivity.

Integrate Ortto with 800+ Apps | Enhance Your Marketing Automation with Albato
3 min. read

Integrate Ortto with 800+ Apps | Enhance Your Marketing Automation with Albato

Ortto redefines the landscape of marketing automation with its intuitive service that simplifies email marketing, customer journey mapping, and targeted messaging. See how Albato can help you enhance the app’s usability!

Connect Zendesk with Popular Apps | Streamline Your Support Workflow with Albato
4 min. read

Connect Zendesk with Popular Apps | Streamline Your Support Workflow with Albato

Zendesk offers a comprehensive customer service solution, designed for ease of use and scalability. See how Albato can help you enhance the app’s usability!

How to use Claude Artifacts: 7 Ways with examples | Guide 2025
Claude AI
10 min. read

How to use Claude Artifacts: 7 Ways with examples | Guide 2025

Learn how to use Claude Artifacts with our detailed guide. Explore 7 best ways with real Artifact examples: web pages, prototypes, presentations and visualizations.

Connect Gumlet with Your Favorite Apps | Optimize Your Media Management with Albato
3 min. read

Connect Gumlet with Your Favorite Apps | Optimize Your Media Management with Albato

Gumlet is best way to stream ad-free videos on internet. It has powerful CMS to organise videos and hollywood grade DRM. See how Albato can help you enhance the app’s usability!

Connect Octopush with Albato | Elevate Your SMS Marketing Strategy
3 min. read

Connect Octopush with Albato | Elevate Your SMS Marketing Strategy

With Octopush, businesses are well equipped to propel their brand, promote their offers and services at scale. See how Albato can help you enhance the app’s usability!

Connect DocuSign with 800+ Apps | Simplify Document Management on Albato
3 min. read

Connect DocuSign with 800+ Apps | Simplify Document Management on Albato

DocuSign is a top electronic signature and digital transaction management platform, helping organizations manage contracts and agreements securely and efficiently. See how Albato can help you enhance the app’s usability!

Chili Piper Alternatives 2024: Top 6 Scheduling & Lead Management Tools
CalendarHero
4 min. read

Chili Piper Alternatives 2024: Top 6 Scheduling & Lead Management Tools

Discover the top 6 Chili Piper alternatives for scheduling and lead management. Compare features, pros & cons of Calendly, Dashly, Cal.com & more. Find the best fit for your business.