I am looking to run multiple search queries/scripts in three fields where users will enter a long format answer explaining project needs. These are populating in a request table. I have second Airtable that lists out my talent at my agency and have created a ‘Keywords’ column that lists out all the different expertise fields and past industries.
My goal is to search through the long format answers client input and connect the keywords to the best match talent in my pool. Any thoughts or stimuli from past projects?
Below is what I have tried so far, but do not know if there is a simpler way since it is two air tables and not calling another database outside Airtable
let table = base.getTable('Project_Needs');
let resultsField = table.getField('Talent v2');
let record = await input.recordAsync('Record', table);
let searchQuery = record.getCellValueAsString("TalentTable_KeywordsField")
if (searchQuery) {
table.updateRecordAsync(record, {dresultsField.id]: 'Updating...'});
output.markdown(`Searching for ${searchQuery}...`);
let results = await searchAsync(searchQuery.split(',').map(term => term.trim()).join('\n'));
await table.updateRecordAsync(record, {dresultsField.id]: results});
output.markdown(results);
}
async function searchAsync(Project_Needs) {
let response = await fetch(
`https://api.airtable.com/v0/appUBDlZzwWdC433V/Project_Needs`,
{
method: "POST",
headers: {"content-type": "application/json"},
body: JSON.stringify({queries: Project_Needs}),
},
);
let result = await response.json();
let resultLines = s];
for (let {searchQuery, TalentTable_KeywordsField} of result) {
resultLines.push(`## ${searchQuery.term}`);
for (let {TalentTable_FirstNameField} of TalentTable_KeywordsField) {
resultLines.push(`- (**${TalentTable_FirstNameField}**:])`);
}
}
return resultLines.join('\n');