docs/src/course/04-workflows/13-creating-ai-enhanced-workflow.md
Now you'll create a new workflow that includes agent analysis alongside your existing content processing steps.
Add this new workflow to your file:
export const aiContentWorkflow = createWorkflow({
id: 'ai-content-workflow',
description: 'AI-enhanced content processing with analysis',
inputSchema: z.object({
content: z.string(),
type: z.enum(['article', 'blog', 'social']).default('article'),
}),
outputSchema: z.object({
content: z.string(),
type: z.string(),
wordCount: z.number(),
metadata: z.object({
readingTime: z.number(),
difficulty: z.enum(['easy', 'medium', 'hard']),
processedAt: z.string(),
}),
summary: z.string(),
aiAnalysis: z.object({
score: z.number(),
feedback: z.string(),
}),
}),
})
.then(validateContentStep)
.then(enhanceContentStep)
.then(generateSummaryStep)
.then(aiAnalysisStep)
.commit()
Update your Mastra configuration to include both workflows and ensure the contentAgent has been added.
// In src/mastra/index.ts
import { contentWorkflow, aiContentWorkflow } from './workflows/content-workflow'
import { contentAgent } from './agents/content-agent'
export const mastra = new Mastra({
workflows: {
contentWorkflow,
aiContentWorkflow, // Add the AI-enhanced version
},
agents: { contentAgent },
// ... rest of configuration
})
You can now access this new Workflow inside the Mastra playground. Select this new ai-content-workflow workflow from the Workflows tab and run a test to validate it works as expected.
Your AI-enhanced workflow now:
This creates a comprehensive, AI-powered content processing system! Next, you'll learn about parallel execution.