Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(batch/scrape/webhook): add batch_scrape.started

Móricz Gergő431e64e752cc
diff --git a/apps/api/src/controllers/v1/batch-scrape.ts b/apps/api/src/controllers/v1/batch-scrape.ts
index 9fd5cc50a..3830b1feb 100644
--- a/apps/api/src/controllers/v1/batch-scrape.ts
+++ b/apps/api/src/controllers/v1/batch-scrape.ts
@@ -16,6 +16,7 @@ import { logCrawl } from "../../services/logging/crawl_log";
import { getScrapeQueue } from "../../services/queue-service";
import { getJobPriority } from "../../lib/job-priority";
import { addScrapeJobs } from "../../services/queue-jobs";
+import { callWebhook } from "../../services/webhook";
export async function batchScrapeController(
req: RequestWithAuth<{}, CrawlResponse, BatchScrapeRequest>,
@@ -86,6 +87,10 @@ export async function batchScrapeController(
);
await addScrapeJobs(jobs);
+ if(req.body.webhook) {
+ await callWebhook(req.auth.team_id, id, null, req.body.webhook, true, "batch_scrape.started");
+ }
+
const protocol = process.env.ENV === "local" ? req.protocol : "https";
return res.status(200).json({
diff --git a/apps/api/src/types.ts b/apps/api/src/types.ts
index d78214072..cc04ca18c 100644
--- a/apps/api/src/types.ts
+++ b/apps/api/src/types.ts
@@ -166,4 +166,4 @@ export type PlanType =
| "";
-export type WebhookEventType = "crawl.page" | "batch_scrape.page" | "crawl.started" | "crawl.completed" | "batch_scrape.completed" | "crawl.failed";
\ No newline at end of file
+export type WebhookEventType = "crawl.page" | "batch_scrape.page" | "crawl.started" | "batch_scrape.started" | "crawl.completed" | "batch_scrape.completed" | "crawl.failed";
\ No newline at end of file