The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Document Teams speaker attribution and warn when names are withheld (#28195)
nitinaeb8de3be0de
diff --git a/packages/twenty-apps/public/teams/SETUP.md b/packages/twenty-apps/public/teams/SETUP.mdindex cf26db741e1..b0a4da2adbf 100644--- a/packages/twenty-apps/public/teams/SETUP.md+++ b/packages/twenty-apps/public/teams/SETUP.md@@ -12,9 +12,6 @@Twenty. Use the secret **Value**, not its ID.4. Add the Microsoft Graph delegated permissions below and obtain administratorconsent where required by your organization.-5. In Teams admin center > Meetings > Meeting settings > Transcript API access,- enable **Microsoft Graph access**. Without it, Graph answers transcript- requests with `GraphAccessToTranscriptsDisabled`.| Permission | Purpose || ---------------------------------- | -------------------------------------------------------------- |@@ -33,6 +30,22 @@ installed without transcript setup. Both must be configured before users can adda Microsoft connection. See [Bot server variables](#bot-server-variables) for thebot configuration.+## Microsoft 365 organization settings++Microsoft applies these per organization, so a Microsoft 365 admin of every+organization whose users connect sets them in Teams admin center > Meetings >+Meeting settings > Transcript API access:++- Turn on **Microsoft Graph access**. Without it, Graph answers transcript+ requests with `GraphAccessToTranscriptsDisabled`.+- Select **Configure** and turn on **Include speaker attribution**, which is off+ by default. Without it, Microsoft serves transcripts without speaker names.++In Teams PowerShell, both are+`Set-CsTeamsMeetingConfiguration -Identity Global -EnableGraphTranscriptAccess $true -EnableAttributedTranscripts $true`.+The same admin consents to the delegated permissions when the organization+requires it.+## Bot server variablesThe bot's identity is an Entra app registration behind an Azure Bot resource.@@ -207,9 +220,13 @@ workspace. Public apps use the monorepo CI workflows.connection and the workspace has no shared one.- `GraphAccessToTranscriptsDisabled`: enable Microsoft Graph transcript accessin Teams meeting settings.-- Call Recording without speaker names: the tenant disallows speaker- attribution in Teams meeting settings, so Microsoft only serves the transcript- without speakers.+- Call Recording without speaker names: the organization has **Include speaker+ attribution** off, so Microsoft serves transcripts without speakers and the+ app logs a warning starting with `[teams] Microsoft withheld speaker names`.+ Turn it on as in+ [Microsoft 365 organization settings](#microsoft-365-organization-settings);+ it can take a while to apply. Run **Sync Teams Transcript** on a transcript+ imported before then to add its speaker names.- Empty result: verify that transcription was started during the scheduledmeeting time, give or take 15 minutes, Microsoft has finished processing it,and the connected account organized the meeting.diff --git a/packages/twenty-apps/public/teams/src/features/transcripts/logic-functions/utils/__tests__/download-meeting-transcript-content.test.ts b/packages/twenty-apps/public/teams/src/features/transcripts/logic-functions/utils/__tests__/download-meeting-transcript-content.test.tsnew file mode 100644index 00000000000..148eca2786f--- /dev/null+++ b/packages/twenty-apps/public/teams/src/features/transcripts/logic-functions/utils/__tests__/download-meeting-transcript-content.test.ts@@ -0,0 +1,86 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { downloadMeetingTranscriptContent } from 'src/features/transcripts/logic-functions/utils/download-meeting-transcript-content';++const ATTRIBUTED_CONTENT =+ 'WEBVTT\n\n00:00:01.000 --> 00:00:03.000\n<v Alice Martin>Hello.</v>\n';++const UNATTRIBUTED_CONTENT =+ 'WEBVTT\n\n00:00:01.000 --> 00:00:03.000\nHello.\n';++const fetchMock =+ vi.fn<+ (+ url: string,+ init: { headers: Record<string, string> },+ ) => Promise<Response>+ >();++const buildGraphErrorResponse = (status: number, innerErrorCode: string) =>+ new Response(+ JSON.stringify({+ error: { message: 'Denied', innerError: { code: innerErrorCode } },+ }),+ { status },+ );++const getRequestedFormats = () =>+ fetchMock.mock.calls.map(([, init]) => init.headers.Accept);++const download = () =>+ downloadMeetingTranscriptContent({+ accessToken: 'token',+ meetingId: 'meeting-1',+ transcriptId: 'transcript-1',+ });++describe('downloadMeetingTranscriptContent', () => {+ const consoleWarnSpy = vi.spyOn(console, 'warn');++ beforeEach(() => {+ vi.clearAllMocks();+ vi.stubGlobal('fetch', fetchMock);+ consoleWarnSpy.mockImplementation(() => undefined);+ });++ afterEach(() => {+ vi.unstubAllGlobals();+ });++ it('should download the transcript with its speakers', async () => {+ fetchMock.mockResolvedValue(new Response(ATTRIBUTED_CONTENT));++ await expect(download()).resolves.toBe(ATTRIBUTED_CONTENT);+ expect(getRequestedFormats()).toEqual(['text/vtt']);+ expect(consoleWarnSpy).not.toHaveBeenCalled();+ });++ it('should warn and fall back to the transcript without speakers when the organization does not allow speaker attribution', async () => {+ fetchMock+ .mockResolvedValueOnce(+ buildGraphErrorResponse(403, 'SpeakerAttributionNotAllowed'),+ )+ .mockResolvedValueOnce(new Response(UNATTRIBUTED_CONTENT));++ await expect(download()).resolves.toBe(UNATTRIBUTED_CONTENT);+ expect(getRequestedFormats()).toEqual([+ 'text/vtt',+ 'application/vnd.microsoft.graph.transcript+text',+ ]);+ expect(consoleWarnSpy).toHaveBeenCalledTimes(1);+ expect(consoleWarnSpy).toHaveBeenCalledWith(+ expect.stringContaining('Include speaker attribution'),+ );+ });++ it('should not fall back when Microsoft refuses the transcript for another reason', async () => {+ fetchMock.mockResolvedValue(+ buildGraphErrorResponse(403, 'GraphAccessToTranscriptsDisabled'),+ );++ await expect(download()).rejects.toThrow(+ 'GraphAccessToTranscriptsDisabled',+ );+ expect(getRequestedFormats()).toEqual(['text/vtt']);+ });+});diff --git a/packages/twenty-apps/public/teams/src/features/transcripts/logic-functions/utils/download-meeting-transcript-content.ts b/packages/twenty-apps/public/teams/src/features/transcripts/logic-functions/utils/download-meeting-transcript-content.tsindex c8c88a7c623..e56c7843131 100644--- a/packages/twenty-apps/public/teams/src/features/transcripts/logic-functions/utils/download-meeting-transcript-content.ts+++ b/packages/twenty-apps/public/teams/src/features/transcripts/logic-functions/utils/download-meeting-transcript-content.ts@@ -29,6 +29,10 @@ export const downloadMeetingTranscriptContent = async ({throw error;}+ console.warn(+ `[teams] Microsoft withheld speaker names for transcript ${transcriptId} of meeting ${meetingId}: turn on Include speaker attribution in Teams admin center > Meetings > Meeting settings > Transcript API access > Configure.`,+ );+return fetchGraphText({accessToken,url: transcriptContentUrl,