diff --git a/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx b/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx index 820491bffde..633cea17a0c 100644 --- a/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx +++ b/packages/client/modules/email/components/SummaryEmail/MeetingSummaryEmail/WholeMeetingSummary.tsx @@ -9,6 +9,11 @@ interface Props { meetingRef: WholeMeetingSummary_meeting$key } +const isServer = typeof window === 'undefined' +const hasAI = isServer + ? !!process.env.OPEN_AI_API_KEY + : !!window.__ACTION__ && !!window.__ACTION__.hasOpenAI + const WholeMeetingSummary = (props: Props) => { const {meetingRef} = props const meeting = useFragment( @@ -44,15 +49,20 @@ const WholeMeetingSummary = (props: Props) => { const {summary: wholeMeetingSummary, reflectionGroups, organization} = meeting const reflections = reflectionGroups?.flatMap((group) => group.reflections) // reflectionCount hasn't been calculated yet so check reflections length const hasMoreThanOneReflection = reflections?.length && reflections.length > 1 - if (!hasMoreThanOneReflection || organization.featureFlags.noAISummary) return null + if (!hasMoreThanOneReflection || organization.featureFlags.noAISummary || !hasAI) return null if (!wholeMeetingSummary) return return } else if (meeting.__typename === 'TeamPromptMeeting') { const {summary: wholeMeetingSummary, responses, organization} = meeting - if (!organization.featureFlags.standupAISummary || organization.featureFlags.noAISummary) { + if ( + !organization.featureFlags.standupAISummary || + organization.featureFlags.noAISummary || + !hasAI || + !responses || + responses.length === 0 + ) { return null } - if (!responses || responses.length === 0) return null if (!wholeMeetingSummary) return return }