Help

Re: Polish your Data with Auto-Tagging

2681 0
cancel
Showing results for 
Search instead for 
Did you mean: 

The other day a friend of mine watched as I imported 7,000 support tickets from Jira into Airtable and then auto-tagged them in less than a minute. He was amazed; I was yawning.

image.png

I suppose it’s a pretty cool thing, but we often get good at something(s) and forget about how much time they save and possibly how much more useful the data becomes when we attend to the seemingly little things like consistent keyword tagging through automation.

I use my Airdrop framework to do this - it’s a simple script management system that allows me to use ordinary javascript functions in Google Apps Script (or in Airtable) to perform acrobatics on Airtable data and all without setting up a new API app every time I need a new API process. But I think you can also do this through Zapier, Integromat and your own API code of course.

Airdrop allows me to frame an API process in a pseudo-code script like this:

image.png

Once this script is made “active”, Airdrop will run this function passing the support Titles field values and getting back the comma-delimited keyword tag list and finally, dropping the results into the Tags field.

image.png

The function references a list of stopwords (cCommonWords) which is an array of commonly used words that are non-operative and should be disregarded as tags. I’ll publish that below along with the text of the javascript function itself.

Enjoy…

var cCommonWords = ["0","1","2","3","4","5","6","7","8","9","a","about","above","after","again","against","all","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","between","both","but","by","can't","cannot","could","couldn't","did","didn't","do","does","doesn't","doing","don't","down","during","each","few","for","from","further","had","hadn't","has","hasn't","have","haven't","having","he","he'd","he'll","he's","her","here","here's","hers","herself","him","himself","his","how","how's","i","i'd","i'll","i'm","i've","if","in","into","is","isn't","it","it's","its","itself","let's","me","more","most","mustn't","my","myself","no","nor","not","of","off","on","once","only","or","other","ought","our","ours", "ourselves","out","over","own","re","re:","same","shan't","she","she'd","she'll","she's","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","to","too","under","until","up","very","was","wasn't","we","we'd","we'll","we're","we've","were","weren't","what","what's","when","when's","where","where's","which","while","who","who's","whom","why","why's","with","won't","would","wouldn't","you","you'd","you'll","you're","you've","your","yours","yourself","yourselves"];

//
// tags extractor 
//
function tagExtractor(str)
{
  
  // make sure we're dealing with a clean text string
  str = str.toString().toLowerCase().replace(/[^\w\d ]/g, '');
  
  // tokenize the string
  var aTokens = str.split(' ');
  
  // remove all the stop-words while creating the tags list
  var aTags = [];
  for (var i in aTokens)
  {
    if ((cCommonWords.indexOf(aTokens[i]) === -1) && (aTags.indexOf(aTokens[i]) === -1))
      aTags.push(aTokens[i]);
  }
  
  // return a string (because Airtable's multi-select doesn't support dynamic creation of new tags)
  return(aTags.toString());
  
}
3 Replies 3

Nice :slightly_smiling_face:

JB

Kate_Horowitz2
4 - Data Explorer
4 - Data Explorer

As someone who is not an engineer, I am having trouble following these instructions to do the same. Could someone elaborate a little to help me out? I would really appreciate it.

Nathan_Feemster
6 - Interface Innovator
6 - Interface Innovator

Thanks @Bill.French! I remember reading this post before automations came out, and thinking “This is great but I don’t have a server somewhere to activate code.” Now, with automations, scripts and a few tweaks, I was able to recreate it without any external tools!

The idea of the automation is to create tags based on event titles from a calendar. “Title from Cal” is the field that has our title and “tags” is the field the automation writes to.
Screen Shot 2021-07-21 at 8.08.07 AM

The automation triggers once on the condition that the “Title from Cal” field is not empty, and then performs a script action and an update record action.
Screen Shot 2021-07-21 at 8.08.23 AM

The script action has 2 input config variables: The “Title from Cal” string, and the record ID.
Screen Shot 2021-07-21 at 8.17.16 AM

Script is below. There are only a few tweaks from @Bill.French’s original script.

// Adapted from code by Bill French - https://community.airtable.com/t/polish-your-data-with-auto-tagging/25394


// import input varables from trigger
let inputConfig = input.config();


// common words list - Add words if you want them to be filtered out
let cCommonWords = ["0","1","2","3","4","5","6","7","8","9","a","about","above","after","again","against","all","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","between","both","but","by","can't","cannot","could","couldn't","did","didn't","do","does","doesn't","doing","don't","down","during","each","few","for","from","further","had","hadn't","has","hasn't","have","haven't","having","he","he'd","he'll","he's","her","here","here's","hers","herself","him","himself","his","how","how's","i","i'd","i'll","i'm","i've","if","in","into","is","isn't","it","it's","its","itself","let's","me","more","most","mustn't","my","myself","no","nor","not","of","off","on","once","only","or","other","ought","our","ours", "ourselves","out","over","own","re","re:","same","shan't","she","she'd","she'll","she's","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","to","too","under","until","up","very","was","wasn't","we","we'd","we'll","we're","we've","were","weren't","what","what's","when","when's","where","where's","which","while","who","who's","whom","why","why's","with","won't","would","wouldn't","you","you'd","you'll","you're","you've","your","yours","yourself","yourselves"]

// Clean string
var str = inputConfig.titlestring.toString().toLowerCase().replace(/[^\w\d ]/g, '');

// tokenize
var aTokens = str.split(' ');

// remove all stop-words while creating tags list
var aTags = [];
for (var i in aTokens)
{
    // added >= 2 condition because I was getting empty strings from double spaces
    if ((cCommonWords.indexOf(aTokens[i]) === -1) && (aTags.indexOf(aTokens[i]) === -1) && aTokens[i].length >= 2)
    aTags.push(aTokens[i]);
}


// Output tags so they can be ported to multiselect field. This is a workaround because dealing with the multiselect field in the update record method is annoying.

output.set('autoTags', aTags.toString());

Finally, the last action updates the record, with the output from the script going to the “tags” field.
Screen Shot 2021-07-21 at 8.23.24 AM

And that’s it! Hope that helps anyone trying to use this same method.