Provide AI large models with complete capabilities for handling Feishu Bitable, supporting operations on data tables, records, fields, and materials.
Skill Developer's Environment
node --version v24.13.0
⚠️ Important: About Code Obfuscation
This skill's scripts/ All JavaScript files in the directory have been obfuscated.
AI Behavior Guidelines
✅ May execute: directly call and execute these scripts, use --parameter-file-path to pass parameters
❌ Do not read: do not read or analyze scripts/ in the directory .js file contents, reasons:
- Obfuscated code has extremely poor readability and no practical meaning
- Avoid wasting tokens and time
- All function descriptions are fully described in this document and the
references/directory
When encountering problems
- refer to the documentation in the
references/directory - check the error messages and error codes output by the scripts
- do not attempt to read obfuscated code
🎯 Trigger Mapping: User Says → AI Does
| User Input Trigger Word | AI Execution Action | Corresponding Script |
|---|---|---|
| "view records"/"get records"/"list records" | Run record/get.js to query the record list |
scripts/record/get.js |
| "add record"/"create record"/"insert record" | Run record/create.js to create a single record |
scripts/record/create.js |
| "modify record"/"update record"/"edit record" | Run record/update.js to update a single record |
scripts/record/update.js |
| "delete record"/"remove record" | Run record/delete.js to delete a single record |
scripts/record/delete.js |
| "batch add records"/"add multiple records" | Run record/batch-create.js to batch create records |
scripts/record/batch-create.js |
| "batch modify records"/"update multiple records" | Run record/batch-update.js to batch update records |
scripts/record/batch-update.js |
| "batch delete records"/"clear records" | Run record/batch-delete.js to batch delete records |
scripts/record/batch-delete.js |
| "view tables"/"data table list" | Run table/list.js to list all data tables |
scripts/table/list.js |
| "create table"/"add data table" | Run table/create-single.js to create a single data table |
scripts/table/create-single.js |
| "modify table name"/"rename table" | Run table/update.js to update the data table name |
scripts/table/update.js |
| "delete table"/"remove data table" | Run table/delete-one.js to delete a single data table |
scripts/table/delete-one.js |
| "view fields"/"column info" | Run field/list.js to list all fields |
scripts/field/list.js |
| "add field"/"new column" | Run field/create.js to create a field |
scripts/field/create.js |
| "modify field"/"modify column" | Run field/update.js to update a field |
scripts/field/update.js |
| "Delete Field"/"Remove Column" | Run field/delete.js to delete the field |
scripts/field/delete.js |
| "Upload File"/"Upload Image"/"Upload Attachment" | Run media/upload.js to upload media |
scripts/media/upload.js |
| "Get Download Link"/"Get Direct Link" | Run media/file-token-to-url.js to get the file URL |
scripts/media/file-token-to-url.js |
Decision Process
用户请求涉及飞书多维表格?
│
├─ 是 → 检查具体操作类型
│ │
│ ├─ 需要访问凭证?
│ │ └─ 运行 get-tenant-access-token.js
│ │
│ ├─ 需要从URL解析信息?
│ │ └─ 运行 parse-bitable-url.js
│ │
│ └─ 执行具体操作
│ ├─ 数据表操作 → table/ 脚本
│ ├─ 记录操作 → record/ 脚本
│ ├─ 字段操作 → field/ 脚本
│ └─ 素材操作 → media/ 脚本
│
└─ 否 → 不使用此 Skill
How to Use This Skill
Feature Overview
This Skill provides complete Feishu Bitable API operation capabilities:
| Feature Modules | Supported Operations |
|---|---|
| Data Table Management | Create, update, and delete data tables (batch operations supported) |
| Record Operations | Create, delete, update, and query records, with batch operations supported (up to 1000 per request) |
| Field Management | Create, update, and delete fields, and list all fields |
| Media Upload | Upload files, images, and other media, and get temporary download links |
Output Format
After execution completes, the Skill outputs:
- Success: Returns the operation result data (in JSON format), including the complete API response
- Failure: Returns error information, including the error code and suggested solutions
Prerequisites
- A valid
tenant_access_token: Required for all API operations app_token: Identifies the Bitable to operate ontable_id: Identifies the data table to operate on (required for some operations)
Parameter Passing Method
Note: All scripts in this Skill use the --parameter-file-path parameter to pass configuration, and must be invoked via a parameter file.
AI Invocation Specification: This Skill is designed specifically for AI. The AI automatically handles the creation and cleanup of temporary files; human users only need to describe their requirements in natural language.
AI Automatic Temporary File Handling Process
When the AI invokes this Skill, it must follow the process below to automatically manage temporary files:
import { createTempParamsFile, cleanupTempFile } from "./scripts/utils";
import { execSync } from "child_process";
// 1. 创建临时参数文件(自动存放在系统临时目录)
const tempFile = createTempParamsFile(
{
tenant_access_token: "xxx",
app_token: "xxx",
table_id: "xxx"
// ... 其他参数
},
"operation-name"
);
try {
// 2. 执行脚本
const result = execSync(`node scripts/xxx.js --parameter-file-path "${tempFile}"`, { encoding: "utf-8" });
const data = JSON.parse(result);
// 3. 处理结果并返回给用户
return formatResultForUser(data);
} finally {
// 4. 确保清理临时文件(无论成功或失败)
cleanupTempFile(tempFile);
}
Key Principles:
- ✅ Temporary files must be created in the system temporary directory (
os.tmpdir()) - ✅ Clean up temporary files immediately after script execution completes
- ✅ Use
try...finallyto ensure cleanup occurs even if an error occurs - ❌ Do not create parameter files in the skill directory or the user's working directory
Standard Usage Process
Step 1: Obtain Access Credentials
node scripts/get-tenant-access-token.js --parameter-file-path params.json
Parameter file example (params.json):
{
"appId": "cli_xxx",
"appSecret": "xxx"
}
For detailed credential management rules, see Authentication and Credential Management Guide。
Step 2: Parse the Bitable URL
Extract from the URL the app_token and table_id:
node scripts/parse-bitable-url.js --parameter-file-path params.json
Step 3: Execute the Specific Operation
Choose the corresponding script according to your needs:
# 查询记录
node scripts/record/get.js --parameter-file-path "params.json"
# 创建记录
node scripts/record/create.js --parameter-file-path "params.json"
# 批量创建记录
node scripts/record/batch-create.js --parameter-file-path "params.json"
Core Concepts
| Concept | Description |
|---|---|
| Bitable | A ByteDance product that combines the flexibility of a spreadsheet with the structured characteristics of a database |
| Table | A single table within a Bitable, similar to an Excel worksheet |
| Record | A row of data in a data table |
| Field | The header of a column in the data table, used to set the data type of that column |
| Media | Uploaded files, images, videos, etc. |
Operation API Quick Reference
Basic Operations
| Action | Script Path | Description |
|---|---|---|
| Get access token | get-tenant-access-token.js | Get tenant_access_token |
| Parse the Feishu Bitable URL | parse-bitable-url.js | Extract from the URL app_token、table_id、view_id |
Data Table Operations
| Action | Script Path | Description |
|---|---|---|
| Create a data table | create-single.js | Supports specifying the name, view, and fields |
| Create multiple data tables | batch-create.js | Only the data table name can be specified |
| Update data table name | update.js | Update the name of the specified data table |
| List data tables | list.js | Get the ID, version number, and name of all data tables |
| Delete a data table | delete-one.js | Via app_token and table_id delete |
| Delete multiple data tables | batch-delete.js | Batch delete multiple data tables |
For detailed parameters, see table reference documentation directory.
Record Operations
| Action | Script Path | Description |
|---|---|---|
| Create record | create.js | Create a record in the data table |
| Update record | update.js | Update a record in the data table |
| Query records | get.js | Query up to 500 rows at a time, supports pagination |
| Delete record | delete.js | Delete a record in the data table |
| Create multiple records | batch-create.js | Create up to 1,000 at a time |
| Update multiple records | batch-update.js | Update up to 1,000 at a time |
| Batch get records | batch-get.js | Query by record ID, up to 100 |
| Delete multiple records | batch-delete.js | Batch delete multiple records |
For detailed parameters, see record reference documentation directory.
Field Operations
| Action | Script Path | Description |
|---|---|---|
| Create field | create.js | Create a field in the data table |
| Update field | update.js | Full update of the field (property will be overwritten) |
| List fields | list.js | Get all fields in the data table |
| Delete field | delete.js | Delete a field in the data table |
For detailed parameters, see field reference documentation directory.
Media/File Operations
| Action | Script Path | Description |
|---|---|---|
| Media upload | upload.js | Upload files, images, videos, and other media |
| Get direct link | file-token-to-url.js | file_token Convert to a temporary download link (valid for 24 hours) |
For detailed parameters, see media reference documentation directory.
Instructions for Using Files and Directories
| Item | Description |
|---|---|
| Documentation Location | references/ Documents in the directory, with specific API call commands or script execution methods |
| Script location | scripts/ Node.js scripts in the directory can be used directly |
| Temporary files | System temporary directory (%TEMP% or /tmp), automatically deleted after the operation is complete |
| Parameter files | System temporary directory, referenced using absolute paths |
| Upload records | System temporary directory (feishu-bitable-upload-records.json) |
Best Practices for Temporary File Management
All temporary files of this skill (parameter files, upload records) are stored in the system temporary directory to avoid polluting the user's home directory and the skill directory:
Windows example:
C:\Users\xxx\AppData\Local\Temp\feishu-create-record-1740374400000-a7x9k2.json
C:\Users\xxx\AppData\Local\Temp\feishu-bitable-upload-records.json
Linux/Mac example:
/tmp/feishu-create-record-1740374400000-a7x9k2.json
/tmp/feishu-bitable-upload-records.json
Utility function usage example
import { createTempParamsFile, cleanupTempFile, cleanupAllTempFiles } from './utils';
// 1. 创建临时参数文件(自动存放在系统临时目录)
const params = {
tenant_access_token: 'xxx',
app_token: 'xxx',
table_id: 'xxx',
fields: { ... }
};
const tempFilePath = createTempParamsFile(params, 'create-record');
// 2. 执行脚本
const result = await executeScript(tempFilePath);
// 3. 立即清理临时文件
cleanupTempFile(tempFilePath);
// 4. 清理所有过期的临时文件(24小时前的)
cleanupAllTempFiles();
Temporary file naming convention:
- Format:
feishu-{operation}-{timestamp}-{random}.json - Example:
feishu-batch-create-1740374400000-a7x9k2.json
Cleanup strategy:
- Immediately attempt to delete the parameter file whether it succeeds or fails
- Deletion failure does not affect the main process
- The system temporary directory is automatically cleaned up periodically
- Run
cleanupAllTempFiles()to batch-clean expired files (older than 24 hours)
AI processing example
The user says: "Help me add a record in the Feishu spreadsheet https://xxx.feishu.cn/wiki/xxx , the task name is 'Complete Report', progress 50%"
AI execution steps:
| Step | Execution action | Script/Command |
|---|---|---|
| 1 | Check tenant_access_token | If not present, run get-tenant-access-token.js |
| 2 | Parse the URL to obtain app_token and table_id | Run parse-bitable-url.js |
| 3 | Create a temporary parameter file | Run createTempParamsFile(), stored in the system temporary directory |
| 4 | Create a record | Run record/create.js |
| 5 | Clean up the temporary parameter file | Run cleanupTempFile() |
| 6 | Return the result | Return to the user: "Record created successfully! Record ID: recxxx" |
User perception: There is no need to know about the existence of temporary files at all; only natural language interaction is needed.
Error handling
| Error scenario | Error manifestation | Handling method |
|---|---|---|
| Missing access credential | API returns a 401/403 error | Run get-tenant-access-token.js to obtain the credential |
| Access credential expired | API returns error code: 99991663, error message: Invalid access token for authorization | Run get-tenant-access-token.js to obtain the credential |
| URL parsing failed | Unable to extract app_token/table_id | Check whether the URL format is correct, or provide the parameters manually |
| Record does not exist | API returns a 404 error | Check whether record_id is correct, or first run record/get.js to query |
| Field type mismatch | API returns a 400 error | Run field/list.js to view the field types, adjust the parameters, and retry |
| Text field format error | TextFieldConvFail Error |
Text fields use string format, do not use rich text array format |
| Field update missing parameter | field validation failed |
When updating a field, you must provide the type parameter |
| File token format error | Cannot read properties |
Use file_tokens(array) instead of file_token(string) |
| Batch operation exceeds limit | API returns 422 error | Reduce the number of operations per request (up to 1000 records, up to 100 for batch retrieval) |
| Temporary file creation failed | Insufficient disk space or permission issue | Check the system temporary directory permissions and disk space |
| Network timeout | No response to request | Check the network connection and try again later |
Detailed Explanation of Common Errors
1. Text field format error (TextFieldConvFail)
Error message:the value of 'Multiline' must be a string
Cause: When creating/updating a record, the text field used the rich text array format returned by queries
Solution:
- ❌ Incorrect:
"字段名": [{"text": "内容", "type": "text"}] - ✅ Correct:
"字段名": "内容"
2. Field update missing type parameter
Error message:field validation failed - type is required
Cause: When updating a field, type parameter was not provided
Solution: When updating a field, you must include type, such as "type": 1(1=text, 2=number)
3. Error in parameters for getting file download link
Error message:Cannot read properties of undefined (reading 'map')
Cause: Used file_token instead of file_tokens
Solution:
- ❌ Incorrect:
"file_token": "xxx" - ✅ Correct:
"file_tokens": ["xxx"]
Reference Documentation
| Document | Description |
|---|---|
| Authentication and Credential Management Guide | Detailed credential management instructions, including how to obtain App ID/App Secret and the automatic tenant_access_token retrieval process |
| Get Access Token API | Specific API call instructions and script usage for obtaining tenant_access_token |
| Feishu URL Parsing Tool | Instructions for using the tool to extract app_token, table_id, and view_id from Feishu Bitable URLs |
| Common Errors and Solutions | Common API call error codes and troubleshooting methods |
| Parameter Configuration Examples and Best Practices | Parameter configuration examples for various operation scenarios |