saving data to airtable
This commit is contained in:
@@ -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,
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user