saving data to airtable

This commit is contained in:
AmitChauhan63390
2025-02-07 22:14:40 +05:30
parent 16a5a6c01c
commit 7bbe9e15db
2 changed files with 7 additions and 3 deletions

View File

@@ -611,7 +611,7 @@ router.get("/airtable", (req, res) => {
response_type: 'code',
state: robotId.toString(),
scope: 'data.records:read data.records:write schema.bases:read',
scope: 'data.records:read data.records:write schema.bases:read schema.bases:write',
code_challenge: code_challenge,
code_challenge_method: 'S256'
});
@@ -804,6 +804,8 @@ router.post("/airtable/remove", requireSignIn, async (req: AuthenticatedRequest,
airtable_access_token: null,
airtable_refresh_token: null,
airtable_base_id: null,
airtable_table_name: null,
airtable_table_id: null,
});

View File

@@ -38,13 +38,13 @@ export async function updateAirtable(robotId: string, runId: string) {
if (!robot) throw new Error(`Robot not found for robotId: ${robotId}`);
const plainRobot = robot.toJSON();
if (plainRobot.airtable_base_id && plainRobot.airtable_table_name) {
if (plainRobot.airtable_base_id && plainRobot.airtable_table_name && plainRobot.airtable_table_id) {
console.log(`Writing to Airtable base ${plainRobot.airtable_base_id}`);
await writeDataToAirtable(
robotId,
plainRobot.airtable_base_id,
plainRobot.airtable_table_name,
plainRobot.airtable_table_id || '',
plainRobot.airtable_table_id ,
data
);
console.log(`Data written to Airtable for ${robotId}`);
@@ -82,6 +82,8 @@ export async function writeDataToAirtable(
if (sampleRow) {
const sampleValue = sampleRow[field];
await createAirtableField(baseId, tableName, field, sampleValue, accessToken, tableId);
console.log("from airtable.ts",tableId);
console.log("from airtable.ts",tableName);
}
}