diff --git a/connectors/src/connectors/intercom/index.ts b/connectors/src/connectors/intercom/index.ts index ccd213b1e0cf..86ea5e826fca 100644 --- a/connectors/src/connectors/intercom/index.ts +++ b/connectors/src/connectors/intercom/index.ts @@ -32,7 +32,6 @@ import { getTeamInternalId, getTeamsInternalId, isInternalIdForAllConversations, - isInternalIdForAllTeams, } from "@connectors/connectors/intercom/lib/utils"; import { launchIntercomSyncWorkflow, @@ -566,9 +565,22 @@ export class IntercomConnectorManager extends BaseConnectorManager { const helpCenterIds: string[] = []; const collectionIds: string[] = []; const articleIds: string[] = []; - let isAllTeams = false; + let isAllConversations = false; const teamIds: string[] = []; + const intercomWorkspace = await IntercomWorkspace.findOne({ + where: { + connectorId: this.connectorId, + }, + }); + if (!intercomWorkspace) { + return new Err( + new Error( + `Intercom workspace not found for connector ${this.connectorId}` + ) + ); + } + internalIds.forEach((internalId) => { let objectId = getHelpCenterIdFromInternalId( this.connectorId, @@ -595,10 +607,10 @@ export class IntercomConnectorManager extends BaseConnectorManager { return; } if ( - !isAllTeams && - isInternalIdForAllTeams(this.connectorId, internalId) + !isAllConversations && + isInternalIdForAllConversations(this.connectorId, internalId) ) { - isAllTeams = true; + isAllConversations = true; } objectId = getTeamIdFromInternalId(this.connectorId, internalId); if (objectId) { @@ -695,7 +707,7 @@ export class IntercomConnectorManager extends BaseConnectorManager { lastUpdatedAt: article.lastUpsertedTs?.getTime() || null, }); } - if (isAllTeams) { + if (isAllConversations) { nodes.push({ provider: "intercom", internalId: getTeamsInternalId(this.connectorId), @@ -704,7 +716,10 @@ export class IntercomConnectorManager extends BaseConnectorManager { title: "Conversations", sourceUrl: null, expandable: true, - permission: "none", + permission: + intercomWorkspace.syncAllConversations === "activated" + ? "read" + : "none", dustDocumentId: null, lastUpdatedAt: null, }); diff --git a/connectors/src/connectors/intercom/lib/utils.ts b/connectors/src/connectors/intercom/lib/utils.ts index a7beba5e6a01..cc5b9fad5dc0 100644 --- a/connectors/src/connectors/intercom/lib/utils.ts +++ b/connectors/src/connectors/intercom/lib/utils.ts @@ -76,12 +76,6 @@ export function isInternalIdForAllConversations( ): boolean { return internalId === `intercom-conversations-all-${connectorId}`; } -export function isInternalIdForAllTeams( - connectorId: ModelId, - internalId: string -): boolean { - return internalId === `intercom-teams-${connectorId}`; -} export function getTeamIdFromInternalId( connectorId: ModelId, internalId: string