From e17b63ce8e26cd52d105e3851b3af39855ec7fc0 Mon Sep 17 00:00:00 2001 From: Steeve Pastorelli Date: Thu, 6 Nov 2025 16:52:14 +0100 Subject: [PATCH 1/2] Reduce the number of conversations fetched per search API call pages --- .../intercom-conversations/src/conversations.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/integrations/intercom-conversations/src/conversations.ts b/integrations/intercom-conversations/src/conversations.ts index 62117e732..7dc2ae31b 100644 --- a/integrations/intercom-conversations/src/conversations.ts +++ b/integrations/intercom-conversations/src/conversations.ts @@ -20,10 +20,14 @@ export async function ingestLastClosedIntercomConversations(context: IntercomRun const intercomClient = await getIntercomClient(context); let pageIndex = 0; - const perPage = 100; - const maxPages = 7; // Keep under ~1000 subrequest limit. Calc: 7 pages * 100 items ≈ 700 detail calls + 7 search page calls ≈ ~707 Intercom calls (+7 GitBook ingests ≈ ~714 total). + const perPage = 50; + const maxPages = 14; // 14 pages * 50 items ≈ 14 search page calls. let totalConvsToIngest = 0; + logger.info( + `Conversation ingestion started. A maximum of ${maxPages * perPage} conversations will be processed.`, + ); + let page = await intercomClient.conversations.search( { query: { @@ -44,9 +48,7 @@ export async function ingestLastClosedIntercomConversations(context: IntercomRun }, ); - logger.info( - `Conversation ingestion started. A maximum of ${maxPages * perPage} conversations will be processed.`, - ); + logger.info(`First page of conversation fetched.`); const tasks: Array = []; while (pageIndex < maxPages) { @@ -67,9 +69,12 @@ export async function ingestLastClosedIntercomConversations(context: IntercomRun break; } + logger.info(`Fetching next page ${pageIndex + 1}.`); page = await page.getNextPage(); } + logger.info(`Queuing ${tasks.length} tasks to ingest intercom closed conversations...`); + await pMap(tasks, async (task) => queueIntercomIntegrationTask(context, task), { concurrency: 3, }); From a5d1cd34233006f7c2ab635c544e433c0fbeb20e Mon Sep 17 00:00:00 2001 From: Steeve Pastorelli Date: Thu, 6 Nov 2025 16:54:11 +0100 Subject: [PATCH 2/2] Remove logs added for debugging --- integrations/intercom-conversations/src/conversations.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/integrations/intercom-conversations/src/conversations.ts b/integrations/intercom-conversations/src/conversations.ts index 7dc2ae31b..90265f632 100644 --- a/integrations/intercom-conversations/src/conversations.ts +++ b/integrations/intercom-conversations/src/conversations.ts @@ -48,8 +48,6 @@ export async function ingestLastClosedIntercomConversations(context: IntercomRun }, ); - logger.info(`First page of conversation fetched.`); - const tasks: Array = []; while (pageIndex < maxPages) { pageIndex += 1; @@ -69,7 +67,6 @@ export async function ingestLastClosedIntercomConversations(context: IntercomRun break; } - logger.info(`Fetching next page ${pageIndex + 1}.`); page = await page.getNextPage(); }