Back to Integrations

Airtable Integration

Collaboration

Automate image processing in Airtable bases

Airtable Script Example

Automation Script
// Airtable Scripting Extension
const BUTTERFLY_API_KEY = 'your_api_key';

let table = base.getTable('Products');
let query = await table.selectRecordsAsync({ fields: ['Name', 'Original Image', 'Enhanced Image'] });

for (let record of query.records) {
  // Skip if already processed
  if (record.getCellValue('Enhanced Image')) continue;
  
  let originalImage = record.getCellValue('Original Image');
  if (!originalImage || !originalImage[0]) continue;
  
  let imageUrl = originalImage[0].url;
  
  // Call ButterflyAPI to enhance
  let response = await fetch('https://butterflyapi.com/api/v1/run', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${BUTTERFLY_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      api: 'image-enhance',
      input: { image_url: imageUrl, scale: 2 }
    })
  });
  
  let result = await response.json();
  
  // Update record with enhanced image
  await table.updateRecordAsync(record.id, {
    'Enhanced Image': [{ url: result.output.image_url }]
  });
  
  output.text(`Processed: ${record.getCellValue('Name')}`);
}