# Asana

## Create a Task in Asana via Webhook Template

Follow the below steps to configure the “Asana - Create Task” action via webhooks.

We will be utilizing Asana's Rest APIs to Create Task

## Create a Key to authenticate Asana Rest API

Asana's APIs can be authenticated in different ways, check them out [here](https://developers.asana.com/docs/authentication). We will be using Personal Access Token (PAT) to authenticate their API

1. Login to <https://app.asana.com/0/my-apps> -> Under **Personal Access Token** -> **Create new token** -> Enter the details and **Create Token**
2. Copy the **Token** to Create Cards

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-002920417d75e995899400f7cad15db0b4c96bf6%2FScreenshot%202023-06-06%20at%2019.30.02.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Get Workspace and Project IDs to access the API

1. Open <https://developers.asana.com/reference/getworkspaces> to get the Workspace ID.
2. Enter the PAT copied above in the box on the right side and click on **Try it**.
3. Copy the right **Workspace ID** in which you would like to create tasks.
4. Open <https://developers.asana.com/reference/getworkspaces> to get the Project ID.
5. Enter the PAT copied above in the box on the right side and click on **Try it**.
6. Copy the right **Project ID** in which you would like to create tasks.

<div><figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-852ae710dbf66005a128674a15a5a5c4fcdd701a%2FScreenshot%202023-06-06%20at%2019.53.42.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-ba3bcee9d709651943508f54d97e388ea042d9ef%2FScreenshot%202023-06-06%20at%2019.54.16.png?alt=media" alt=""><figcaption></figcaption></figure></div>

## Using Webhooks to Create Asana Tasks for Squadcast Incidents

1. Navigate to **Settings** -> **Webhooks**.
2. Click **Add Webhook**. On the next screen, you will be guided through three steps. Navigate between these steps by clicking on any of the steps on the top bar.
3. **Add Webhook Details**:

   1. **Webhook Name**: Enter the webhook name as **Asana - Create Task**.
   2. **Webhook Description** (optional): Enter an optional description. For example - This webhook is for task creation in Asana for Squadcast Incidents.
   3. **Failure Notification Email** (optional): Enter an email where you want to receive failure notifications. This is particularly helpful when you (or an administrator) want to be notified of webhook-related failures.
   4. **URL**: Copy and paste the below API.
   5. **Additional Headers**: Add `Key: Authorization` and paste the `Value` copied from Postman with the prefix **Bearer**

   <https://app.asana.com/api/1.0/tasks>

{% hint style="info" %}
**Note:**

Under Additional headers, Content-Type: application/JSON is added by default.
{% endhint %}

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-d1d2869fa4b623888a99a2fc9e8ac62a54e79af2%2FScreenshot%202023-06-06%20at%2019.43.10.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Click **Next: Choose Webhook Type**, and navigate to the next step.

4. **Choose Webhook Type**: Choose Webhook type (Manual or Automatic) and add configurations.
   1. **Manual Webhook**: Manually trigger Webhooks under incidents, on demand. Under Manual Webhook, select the teams that are authorized to access the Webhook. You can select All Teams or enter specific Teams, from the drop-down.

{% hint style="info" %}
**Note:**

Select this option only if you want to create Asana tasks manually on-demand. If you want a ticket, created automatically when certain conditions are met, please choose Automatic webhooks.
{% endhint %}

2. **Automatic Webhook**: Automatically trigger Webhooks when the configured conditions match. To set up Automatic Webhook Configurations:
   1. **Versions**: Select **v2**
   2. **Triggers**: Select the following Trigger events (conditions) for which the Webhook will be triggered:
      1. Incident Triggered (This will create an Asana task whenever a new incident gets triggered in Squadcast)
   3. **Filters**: You can apply filters on top of events, based on Teams, Services, Alert Sources, and Tags, by having an individual expression or a combination of expressions/expression groups.

Applying filters will trigger the webhook and create Asana tasks only for events that match the filter.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-ab8c1674f1f5ed459fbe4a3038b76343d435b450%2FScreenshot%202023-04-28%20at%2018.14.39.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Click **Next: Configure Payload**, and navigate to the next step.

5. **Configure Payload**:\
   \
   Select the pre-configured template for **Asana - Create Task**. You can also test the Webhook by clicking the **Test Webhook** on the bottom right.

<figure><img src="https://1574591692-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8TaWz01jmUJl58p4ZVel%2Fuploads%2Fgit-blob-ac4e1ab96a8aa64295ed8cec8e974f288b6bfe52%2FScreenshot%202023-06-06%20at%2019.58.35.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
**Note:**

Enter the Workspace ID and Project ID copied in the previous steps. We have added the necessary fields in the template.

You can also [use this link](https://developers.asana.com/reference/createtask) to check the fields accepted by Asana API.
{% endhint %}

Click **Save** and your **Webhook** is created.

*Have any questions?* [*Ask the community*](https://community.squadcast.com/view/home)*.*
