Skip to main content
Solved

Possible to script a "send this record to Asana"?


Forum|alt.badge.img+6

Would love to know if it is possible to use the Script Block for something like this - basically, send a record to an Asana Board and create a ticket with certain fields.

Is that possible?

Best answer by JonathanBowen

Aron11 wrote:

Hi Hal,

You can send a new record (or new record in view) to Asana using Zapier (Airtable zapier triggers here). However, note that this will not sync the airtable record in Asana (e.g. changes to the record will not be reflected in Asana or vice-versa).

I’m not very familiar with Asana but if they have an API you could periodically sync between Airtable and Asana using something like Parabola or scripting block (this would be manually triggered).

Best
Aron

Want to learn Airtable? Join me for a webinar at airtable.com/webinar


Hi @Hal_Atkins - yes you can use the scripting block to create records in Asana using their API. Here’s a basic skeleton script:

let url = 'https://app.asana.com/api/1.0/tasks';

let headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
};

let myData = {
  "data": {
    "name": "Test task",
    "projects": [
      "YOUR_PROJECT_ID"
    ]
  }    
}

let apiResponse = await fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(myData),
})
let data = await apiResponse.json();
console.log(data);

You’ll notice that there’s no interaction with your base in this script, so that’s obviously something you’ll need to do, i.e. define a table, query a table, iterate through the records and so on. This script was just to prove you could do a POST request from the scripting block to Asana and create the task. There’s a lot more to the Asana API too - assignees, due dates, parent tasks etc, so all of this could be added in as needed to the data object.


If this answers your question, please consider marking it as the "solution". If not, please post again for more help. Thanks!
View original
Did this topic help you find an answer to your question?

7 replies

Forum|alt.badge.img+3
  • Inspiring
  • 63 replies
  • June 4, 2020

Hi Hal,

You can send a new record (or new record in view) to Asana using Zapier (Airtable zapier triggers here). However, note that this will not sync the airtable record in Asana (e.g. changes to the record will not be reflected in Asana or vice-versa).

I’m not very familiar with Asana but if they have an API you could periodically sync between Airtable and Asana using something like Parabola or scripting block (this would be manually triggered).

Best
Aron

Want to learn Airtable? Join me for a webinar at airtable.com/webinar


JonathanBowen
Forum|alt.badge.img+18
  • Inspiring
  • 1110 replies
  • Answer
  • June 4, 2020
Aron11 wrote:

Hi Hal,

You can send a new record (or new record in view) to Asana using Zapier (Airtable zapier triggers here). However, note that this will not sync the airtable record in Asana (e.g. changes to the record will not be reflected in Asana or vice-versa).

I’m not very familiar with Asana but if they have an API you could periodically sync between Airtable and Asana using something like Parabola or scripting block (this would be manually triggered).

Best
Aron

Want to learn Airtable? Join me for a webinar at airtable.com/webinar


Hi @Hal_Atkins - yes you can use the scripting block to create records in Asana using their API. Here’s a basic skeleton script:

let url = 'https://app.asana.com/api/1.0/tasks';

let headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
};

let myData = {
  "data": {
    "name": "Test task",
    "projects": [
      "YOUR_PROJECT_ID"
    ]
  }    
}

let apiResponse = await fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(myData),
})
let data = await apiResponse.json();
console.log(data);

You’ll notice that there’s no interaction with your base in this script, so that’s obviously something you’ll need to do, i.e. define a table, query a table, iterate through the records and so on. This script was just to prove you could do a POST request from the scripting block to Asana and create the task. There’s a lot more to the Asana API too - assignees, due dates, parent tasks etc, so all of this could be added in as needed to the data object.


If this answers your question, please consider marking it as the "solution". If not, please post again for more help. Thanks!

Forum|alt.badge.img+6
  • Author
  • New Participant
  • 2 replies
  • June 5, 2020
JonathanBowen wrote:

Hi @Hal_Atkins - yes you can use the scripting block to create records in Asana using their API. Here’s a basic skeleton script:

let url = 'https://app.asana.com/api/1.0/tasks';

let headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
};

let myData = {
  "data": {
    "name": "Test task",
    "projects": [
      "YOUR_PROJECT_ID"
    ]
  }    
}

let apiResponse = await fetch(url, {
  method: 'POST',
  headers: headers,
  body: JSON.stringify(myData),
})
let data = await apiResponse.json();
console.log(data);

You’ll notice that there’s no interaction with your base in this script, so that’s obviously something you’ll need to do, i.e. define a table, query a table, iterate through the records and so on. This script was just to prove you could do a POST request from the scripting block to Asana and create the task. There’s a lot more to the Asana API too - assignees, due dates, parent tasks etc, so all of this could be added in as needed to the data object.


If this answers your question, please consider marking it as the "solution". If not, please post again for more help. Thanks!

Thanks @JonathanBowen - really appreciate the sample code as well!


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8779 replies
  • June 5, 2020

Also, if Asana accepts Webhooks, you can create a URL to send data to Asana about your current record.


Forum|alt.badge.img+19
  • Inspiring
  • 3264 replies
  • June 5, 2020
ScottWorld wrote:

Also, if Asana accepts Webhooks, you can create a URL to send data to Asana about your current record.


Asana supports both inbound and outbound webhooks, so it is possible, but it’s not as simple as it might seem as this thread indicates. Inbound webhooks are equally complex to REST calls.


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8779 replies
  • June 6, 2020
Bill_French wrote:

Asana supports both inbound and outbound webhooks, so it is possible, but it’s not as simple as it might seem as this thread indicates. Inbound webhooks are equally complex to REST calls.


Ah, good to know. Some apps use a webhook that is just a simple URL.

You can also use Integromat to communicate between Airtable and Asana.


Forum|alt.badge.img+19
  • Inspiring
  • 3264 replies
  • June 6, 2020
ScottWorld wrote:

Ah, good to know. Some apps use a webhook that is just a simple URL.

You can also use Integromat to communicate between Airtable and Asana.


It’s not really app-dependent; more aligned with the use case and the direction of the hook, inbound or outbound.

Imagine a desperately-needed outbound webhook from Airtable that serves no other purpose that to alert an external process that a record has changed and the field(s) that we modified. A simple GET will do it. Whereas, an inbound hook that supports a complex payload including the possibility of a base64 image will require a far different design.

And while I’m a fan of glue-factory solutions like Integromat for quick and satisfying PoCs, many companies get nervous when their data has to cross multiple continents and countries where privacy laws are lax. Personally, the privacy issue doesn’t typically concern me; it’s more the issue of multiple hops to achieve one task which leads to deeper abstract integration designs and more points of failure.


Reply