Skip to main content
Available on all Cloud plans; Self-Hosted requires Business or higher.
Coding Tip: This document provides coding guides and examples for AI Script functionality. For optimal coding results, we recommend using the claude-sonnet-4 model to write and optimize scripts.

Basic Concepts

Teable Script functionality allows you to automate data processing through JavaScript code, implementing complex business logic and data operations.

Execution Environment

  • Language: JavaScript (ES6+)
  • Environment: Secure sandbox environment
  • Module System: CommonJS (require())
  • Support: Top-level await, modern JavaScript features

Getting Input Data

Scripts get output from previous workflow steps through the input object. Each previous step’s output uses its actionId as the key:
Using output.set() is the best approach because it preserves the complete format of objects:

Dependency Management

If using external npm packages, they must be declared in dependency configuration:
Recommendation: Prioritize using JavaScript built-in features to avoid additional dependencies

HTTP Requests

Use the built-in fetch() function:

Debugging Tips

1. View Input Data Structure

2. Error Handling

Quick Start Steps

  1. Debug input first - Use console.log(JSON.stringify(input, null, 2)) to view data structure
  2. Extract needed data - Get field values through input[actionId].record.fields[fieldId]
  3. Process data - Use JavaScript for calculations, transformations, filtering, and other operations
  4. Set output - Use output.set(key, value) to set results
  5. Test and verify - Run script to check if output meets expectations

Practical Application Examples

Basic Data Processing

API Call Example

Teable API Operations

Important Notes

Authentication and Security

  • Use built-in process.env.AUTOMATION_TOKEN
  • Avoid hardcoding sensitive information in scripts
  • Ensure scripts only access necessary tables and fields

Data Processing

  • Recommend enabling typecast: true for automatic type conversion
  • Validate input data integrity and format before processing
  • Use meaningful field names

Performance Optimization

  • Prefer batch operations over individual loop operations
  • Use pagination for large datasets
  • Only retrieve required fields

Error Handling

  • All API calls must be wrapped with try/catch
  • Record detailed error information for debugging
  • Implement graceful degradation, partial failures should not affect overall flow

Common Teable API Endpoints

Getting Help

If you have specific script requirements or encounter issues, please describe your needs in detail in the script editor. AI will generate corresponding code examples and solutions for you.
Last modified on May 26, 2026