> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mayil.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Jira

## Installing Mayil's Jira integration

*Estimated setup time: 20 minutes*

Mayil's Jira integration consists of a OAuth 2.0 app and a webhook. The general instructions to install a Jira OAuth 2.0 is outlined [here](https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/). Information on how to set up a webhook is outlined [here](https://developer.atlassian.com/server/jira/platform/webhooks/#registering-a-webhook-via-the-jira-administration-console)

## Prerequisites

1. Admin access to Jira
2. Enable OAuth 2.0 in the [developer console](https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/#:~:text=app%20using%20the-,developer%20console,-.)

## Setting up a OAuth 2.0 integration

1. From any page on developer.atlassian.com, select your profile icon in the top-right corner, and from the dropdown, select My apps.
2. Select create ➤ OAuth 2.0 integration. You should see something like this-

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_newoauth.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=f7020802ebc1c1be8c90087f105c440c" alt="New OAuth App" width="1100" height="1182" data-path="selfhosting/jira_newoauth.png" />

3. Name the app MayilAI. Once created, you should see something like this-

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_newapp.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=911af346e4773ea9d7edf1f8602530b8" alt="New Jira app" width="2120" height="1506" data-path="selfhosting/jira_newapp.png" />

4. Go to Authorization. Add a new authorization for OAuth 2.0 (3LO)-

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_add_auth.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=6b931350fa843e002c7063f203fb4236" alt="Add new authorization" width="2138" height="872" data-path="selfhosting/jira_add_auth.png" />

5. You will now be prompted to enter a callback URL. Enter `<deploment>/api/callback/jira/` where deployment is where Mayil's backend API was deployed (An example would be `https://mayil.companyname/api/callback/jira/`)

6. Add API authorizations by clicking this button-

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_addapi.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=256c49aa5cc023c694e2acebefcab0da" alt="add auth" width="1502" height="1174" data-path="selfhosting/jira_addapi.png" />

7. Select Add ➤ Configure under `Jira API` and make this selection-

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_permissions.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=2f303b40ac93711a1eb51d07b79d1a82" alt="add auth" width="1906" height="1532" data-path="selfhosting/jira_permissions.png" />

8. Click Save.

## Configuring the app's avatar

Go to Settings and select Change avatar. Update it to the image provided in the installation package

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_dp.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=5c4e1ed44b86d27ca9def84d74dee898" alt="add avatar" width="2348" height="1064" data-path="selfhosting/jira_dp.png" />

## Configuring Mayil's backend API

Various details generated during the setup process will need to be copied and provided to Mayil's backend API as configuration details. Update this JSON block with all the procured information-

```
{
    "integration_type": "jira",
    "identifier": "",
    "ignore_labels": [ ],
    "project": "My Kanban Project",
    "secret": "",
    "url": "",
    "webhook_secret": ""
}
```

1. Go to Settings for your new created OAuth app and copy `Client ID` into `identifier`  and copy `secret` into `secret`.
2. Identify the URL in which Jira runs and save that under URL (e.g `https://mayiltest.atlassian.net`)

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_url.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=8c499e7aec3e41047bfda0dc27795c77" alt="URL" width="1260" height="620" data-path="selfhosting/jira_url.png" />

3. Identify the project name and save it under `Project`. In the example below, it is "My Kanban Project"

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_projectname.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=43928b4538db123b4af88aac4339826d" alt="Project Name" width="1336" height="812" data-path="selfhosting/jira_projectname.png" />

4. Mayil can be configured to not run on a ticket if certain tags are present on that ticket. List the names of those tags under `ignore_labels`. These tags can be called anything.

5. `webhook_secret` will be updated in the section below. After completing that, add this config block to `INTEGRATIONS` as outlined in the [Configuration](./configuration) page.

6. Now go to `<deploment>/api/health` and click on the Jira icon. Follow the instructions there to validate the OAuth app. Once completed, you should see this page-

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/jira_validation.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=bec264438050dff985b8def6a80d3222" alt="full completed Jira integration" width="2190" height="1306" data-path="selfhosting/jira_validation.png" />

## Setting up a webhook

1. Click the Gear icon on Jira > System

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/Jira_webhook1.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=9e18a42b5829f1181aa4573a9dc1a70b" alt="Webhook 1" width="1336" height="812" data-path="selfhosting/Jira_webhook1.png" />

2. Click Webhook from the menu on the left and click Create a Webhook.

3. Enter `mayil-wh-1` under name.

4. Set status as `Enabled`

5. Under URL, enter `<deploment>/api/webhook/jira/` where deployment is where Mayil's backend API was deployed (An example would be `https://mayil.companyname/api/webhook/jira/`)

6. Set a secret and update `webhook_secret` in the configuration details from the previous step

7. Add these Events-

<img src="https://mintcdn.com/mayilai/y96ydTNm8O7xwqcJ/selfhosting/Jira_perms.png?fit=max&auto=format&n=y96ydTNm8O7xwqcJ&q=85&s=08317af5c1751beaa2f715ecac19f493" alt="Jira WH Permissions" width="1724" height="1644" data-path="selfhosting/Jira_perms.png" />

8. Click save

***

This completes the Jira setup. A successful setup will be indicated on the health page (`<deploment>/api/health`)
