Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions integrations/intercom-conversations/src/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -44,10 +48,6 @@ export async function ingestLastClosedIntercomConversations(context: IntercomRun
},
);

logger.info(
`Conversation ingestion started. A maximum of ${maxPages * perPage} conversations will be processed.`,
);

const tasks: Array<IntercomIntegrationTask> = [];
while (pageIndex < maxPages) {
pageIndex += 1;
Expand All @@ -70,6 +70,8 @@ export async function ingestLastClosedIntercomConversations(context: IntercomRun
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,
});
Expand Down