Skip to content

[INTEG-3262] feat: create ai content type parser agent - #10255

Merged
Harika Kondur (harikakondur) merged 20 commits into
masterfrom
INTEG-3262-create-ai-agent-content-type-parser
Nov 18, 2025
Merged

[INTEG-3262] feat: create ai content type parser agent#10255
Harika Kondur (harikakondur) merged 20 commits into
masterfrom
INTEG-3262-create-ai-agent-content-type-parser

Conversation

@harikakondur

@harikakondur Harika Kondur (harikakondur) commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Purpose

This PR adds the content type analyzer agent to the google docs import app.

Approach

  1. uses AI SDK generateObject method for content type parsing/analysis
  2. the agent takes in an array of content type ids and returns a structured output consisting of the following:
    • summary for each content type (ContentTypeSummary)
    • overall summary for the selected content types (FinalContentTypesResultSummary)
    • complexity rating
  3. content type service to fetch selected content types via cma
  4. content type picker modal

Testing steps

To test:

  1. configure the open ai api key in the config page
  2. upload a doc
  3. select content types to view the agent's raw output. (it doesn't do anything with the uploaded doc as of right now, just parses the selected content types)

If you are adding logs in the function (createEntriesFromDocument), you can access them in the actions tab of the app definition. Be sure to run npm run deploy:dev

Dependencies and/or References

https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-object

Screenshots

Screen.Recording.2025-11-17.at.5.37.26.PM.mov
Screenshot 2025-11-17 at 5 38 19 PM

Content Type Picker
Screenshot 2025-11-17 at 5 38 47 PM
Screenshot 2025-11-17 at 5 38 54 PM

@harikakondur Harika Kondur (harikakondur) changed the title Integ 3262 create ai agent content type parser [INTEG-3262] feat: create ai content type parser agent Nov 17, 2025
Comment thread apps/google-docs/functions/createEntriesFromDocument.ts Fixed
Comment on lines -17 to +29
apiKey?: string;
apiKeyLength?: number;
apiKeySuffix?: string;
openAiApiKey?: string;
openAiApiKeyLength?: number;
openAiApiKeySuffix?: string;
}

const VISIBLE_SUFFIX_LENGTH = 4;

const ConfigScreen = () => {
const sdk = useSDK<ConfigAppSDK>();
const [apiKeyInput, setApiKeyInput] = useState<string>('');
const [apiKeyObfuscatedDisplay, setApiKeyObfuscatedDisplay] = useState<string>('');
const [apiKeyIsValid, setApiKeyIsValid] = useState<boolean>(true);
const [isValidatingApiKey, setIsValidatingApiKey] = useState<boolean>(false);
const [openAiApiKeyInput, setOpenAiApiKeyInput] = useState<string>('');
const [openAiApiKeyObfuscatedDisplay, setOpenAiApiKeyObfuscatedDisplay] = useState<string>('');
const [openAiApiKeyIsValid, setOpenAiApiKeyIsValid] = useState<boolean>(true);
const [isValidatingOpenAiApiKey, setIsValidatingOpenAiApiKey] = useState<boolean>(false);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming for clarity

Comment on lines +429 to +450
<Heading as="h3" marginBottom="spacingS">
Analysis Result
</Heading>
<Paragraph marginBottom="spacingS">
Raw output from the content type analysis agent:
</Paragraph>
<Box
style={{
maxHeight: '400px',
overflow: 'auto',
background: '#f7f9fa',
padding: '16px',
borderRadius: '4px',
fontFamily: 'monospace',
fontSize: '12px',
whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
}}>
{JSON.stringify(analysisResult.result.response, null, 2)}
</Box>
</Box>
)}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ui is temporary for testing

@harikakondur
Harika Kondur (harikakondur) marked this pull request as ready for review November 18, 2025 00:40

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really solid! I left a few comments on some small things I noticed.

Comment on lines +230 to +238
const result = await sdk.cma.appActionCall.createWithResult(
{
appDefinitionId,
appActionId: '3nLAuoEuepbJMvdgp1qX6g',
},
{
parameters: { contentTypeIds },
}
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this app action be assigned an ID that describes the action, and then use that ID here instead of the system-generated one?

That would help make this app code work with multiple installations so that we can eventually have dev/staging/prod versions of the app.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this should be done before merging otherwise when we install this into staging and production, this wiill break. I can help you with this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done ✅

Comment on lines +23 to +26
// TODO: Double check these values and make sure they are compatible because not every user will have a key
// to access all models
const modelVersion = 'gpt-4o';
const temperature = 0.3;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with using OpenAI for the GA release, we could allow the user to select their model from a dropdown list in the app configuration. We could get the list of available models from an API, similar to what we do in the other OpenAI apps: https://github.com/contentful/apps/blob/master/apps/ai-content-generator/src/components/config/model/Model.tsx#L23

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add this to a fast follow ticket

Comment thread apps/google-docs/functions/createEntriesFromDocument.ts Outdated
Comment thread apps/google-docs/src/components/ContentTypePickerModal.tsx Outdated
Comment thread apps/google-docs/src/components/ContentTypePickerModal.tsx Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@harikakondur
Harika Kondur (harikakondur) merged commit 46dd050 into master Nov 18, 2025
14 checks passed
@harikakondur
Harika Kondur (harikakondur) deleted the INTEG-3262-create-ai-agent-content-type-parser branch November 18, 2025 16:53
Shannon Grice (snowdoniadarkness) referenced this pull request in citizenwatchamerica/citizen-contentful-apps Jul 7, 2026
* feat: helper function to fetch content types

* wip: content parser agent

* chore:cleanup

* feat: content type service

* ct picker modal for testing

* fix: allow for multi select in content type picker modal

* calls app action

* app action fetches a single content type

* app action fetches multiple content types

* app action calls agent!!!

* fix: openai api key  parameter bug

* chore: cleanup config page

* chore: cleanup variable names

* cleanup:logs n comments

* fic: agent loader

* chore: cleanup styles

* fix: creating a `getAppActionId()` util to clean up code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants