Skip to content

Commit fbaa6bf

Browse files
committed
Polish and enhance
1 parent 7897734 commit fbaa6bf

File tree

7 files changed

+308
-8
lines changed

7 files changed

+308
-8
lines changed

src/content/blog/ai-pipelines-and-agents-mastra/page.mdx

Lines changed: 308 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,335 @@ import { createMetadata } from '@/utils/createMetadata'
44
import aieWorkshop from '@/images/aie-workshop-room.webp'
55
import aieFisheye from '@/images/aie-workshop-fisheye.webp'
66
import zackAndNick from '@/images/zack-and-nick.webp'
7+
import good1 from '@/images/good1.jpeg'
8+
import good2 from '@/images/good2.png'
9+
import good3 from '@/images/good3.jpg'
10+
import good4 from '@/images/good4.jpeg'
11+
import feedback1 from '@/images/mastra-workshop-feedback-1.webp'
12+
import feedback2 from '@/images/mastra-workshop-feedback-2.webp'
713

814
export const metadata = createMetadata({
915
author: 'Zachary Proser',
1016
date: '2025-06-03',
11-
title: 'AI Pipelines and Agents in Pure TypeScript with Mastra.ai',
17+
title: 'Live Workshop: AI Pipelines and Agents in Pure TypeScript with Mastra.ai - Nick Nisi and Zack Proser',
1218
description: 'Nick Nisi and I taught 70 engineers how to build AI workflows and agents with Mastra.ai at the AI Engineer World Fair in San Francisco.',
1319
image: aieWorkshop,
1420
slug: '/blog/ai-pipelines-and-agents-mastra',
1521
})
1622

1723
<Image src={aieWorkshop} alt="Nick Nisi presenting with me" />
1824

19-
On June 3rd, 2025, my colleague **Nick Nisi** and I hosted a two hour workshop at the **AI Engineer World Fair** in San Francisco. The event gathered more than 70 engineers eager to build AI powered workflows in their own products.
25+
On June 3rd, 2025, my colleague **Nick Nisi** and I hosted a two hour workshop at the **AI Engineer World Fair** in San Francisco. The event gathered more than 70 engineers eager to build AI powered workflows in their own products using **Mastra.ai** - a new framework that allows you to orchestrate AI tasks using pure TypeScript.
2026

21-
Mastra.ai provided an early preview of their workflow tooling, which allows you to orchestrate tasks using pure TypeScript. We showed how to chain those workflows together into pipelines and grant access to them through natural language driven agents.
27+
<figure>
28+
<Image src={zackAndNick} alt="Zack and Nick ready to teach" />
29+
<figcaption className="mt-2 text-center text-sm text-gray-600 dark:text-gray-400">
30+
Nick Nisi is a TypeScript expert, and I'm a full stack developer who has gone deep into GenAI and the <Link href="/blog/vercel-ai-sdk" className="text-blue-600 hover:text-blue-700 underline">Vercel AI SDK</Link>.
31+
</figcaption>
32+
</figure>
2233

23-
All of the materials are open source in the [mastra-agents-meme-generator](https://github.com/workos/mastra-agents-meme-generator) repo. We built the full app first, wrote up the steps in `workshop.md`, and staged each phase on a separate git branch so everyone could work at their own pace.
34+
## Live Demo: AI Meme Generator in Action
35+
36+
Here's our complete workshop demonstration showing the agentic application we built running end-to-end. Watch how workplace frustrations get transformed into shareable memes through a multi-step AI workflow:
37+
38+
<div style={{ position: 'relative', width: '100%', height: 0, paddingBottom: '56.25%' }}>
39+
<iframe
40+
src="https://www.youtube.com/embed/oZmaBSuxZVA"
41+
style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' }}
42+
allowFullScreen
43+
title="Mastra AI Workshop Demo"
44+
/>
45+
</div>
46+
47+
## How the AI Workflow Works
48+
49+
Users simply enter their random workplace frustrations - anything from "my meetings always run over" to "the deployment process is completely broken." Then our **4-step agentic workflow** takes over:
50+
51+
1. **🧠 Analyzes their frustrations** - Uses structured AI generation to extract and categorize the workplace pain points
52+
2. **🎭 Selects the right base meme** - Searches through Imgflip's extensive template database to find the perfect format
53+
3. **✍️ Humorously recaptions it** - Generates contextually funny text that transforms frustration into humor
54+
4. **🚀 Creates and hosts it** - Produces the final shareable meme with a stable URL
55+
56+
The result? Common workplace struggles become genuinely funny, shareable content that teams can actually use.
57+
58+
## Key Learning Outcomes
59+
60+
By the end of the workshop, attendees had:
61+
62+
- ✅ Built a complete agentic workflow with multiple specialized steps
63+
- ✅ Integrated external APIs (Imgflip, OpenAI)
64+
- ✅ Used structured generation for reliable data extraction
65+
- ✅ Created a fun, shareable application that solves real problems
66+
- ✅ Learned Mastra's agent and workflow patterns
67+
- ✅ Gained experience with AI-powered workflows and step composition
68+
69+
## From Toy Example to Production Patterns
70+
71+
While we chose a humorous implementation for our workshop, the **patterns, architecture, and Mastra framework** we demonstrated are ideal for creating **enterprise-grade agentic applications**. The same workflow concepts apply whether you're building:
72+
73+
- **Customer Support Automation** - Multi-step ticket resolution workflows
74+
- **Data Processing Pipelines** - ETL workflows with AI-powered transformations
75+
- **Content Generation Systems** - Marketing copy, documentation, and reports
76+
- **Complex Business Logic** - Approval processes and intelligent routing
77+
78+
The modular, typed, and testable approach we used for meme generation scales directly to serious production use cases.
79+
80+
## The Meme Generation Pipeline: Technical Deep Dive
81+
82+
Our workshop demonstrates a complete **4-step agentic workflow** that transforms workplace frustrations into shareable memes:
83+
84+
### Understanding the Workflow Architecture
85+
86+
```typescript {theme: 'gruvbox-dark'}
87+
// Our main agent orchestrates the entire meme generation process
88+
const memeGeneratorAgent = new Agent({
89+
name: 'MemeGenerator',
90+
instructions: 'Help users turn their work frustrations into funny memes',
91+
workflows: {
92+
'meme-generation': memeGenerationWorkflow,
93+
},
94+
});
95+
```
96+
97+
The workflow consists of four modular, reusable steps:
98+
99+
1. **Extract Frustrations** - Parse user input and categorize workplace pain points
100+
2. **Find Base Meme** - Select appropriate meme templates from Imgflip's API
101+
3. **Generate Captions** - Create contextually funny text using AI
102+
4. **Generate Meme** - Produce the final shareable meme image
103+
104+
### Step 1: Extract Frustrations with Structured Generation
105+
106+
One of Mastra's most powerful features is its integration with **structured generation** using Zod schemas and the Vercel AI SDK:
107+
108+
```typescript {theme: 'gruvbox-dark'}
109+
const extractFrustrationsStep = createStep({
110+
id: 'extract-frustrations',
111+
description: 'Extract and categorize user frustrations from raw input',
112+
inputSchema: z.object({
113+
userInput: z.string().describe('Raw user input about work frustrations'),
114+
}),
115+
execute: async ({ inputData }) => {
116+
const result = await generateObject({
117+
model: openai('gpt-4'),
118+
schema: frustrationsSchema,
119+
prompt: `Extract frustrations from: ${inputData.userInput}`,
120+
});
121+
return result.object;
122+
},
123+
});
124+
```
125+
126+
The `frustrationsSchema` ensures reliable data extraction:
127+
128+
```typescript {theme: 'gruvbox-dark'}
129+
const frustrationsSchema = z.object({
130+
primaryFrustration: z.string().describe('The main workplace frustration'),
131+
category: z.enum(['meetings', 'communication', 'process', 'technical', 'management']),
132+
intensity: z.number().min(1).max(10).describe('Frustration level from 1-10'),
133+
context: z.string().describe('Additional context about the situation')
134+
});
135+
```
136+
137+
### Step 2: Find Base Meme Templates
138+
139+
The second step searches Imgflip's extensive meme template database:
140+
141+
```typescript {theme: 'gruvbox-dark'}
142+
const findBaseMemeStep = createStep({
143+
id: 'find-base-meme',
144+
description: "Get a diverse selection of meme templates from Imgflip's free API",
145+
inputSchema: frustrationsSchema.extend({
146+
analysis: z.object({
147+
message: z.string(),
148+
}),
149+
}),
150+
execute: async ({ inputData }) => {
151+
const response = await fetch('https://api.imgflip.com/get_memes');
152+
const data = await response.json();
153+
154+
// Select templates that work well for workplace humor
155+
const selectedMemes = data.data.memes.slice(0, 10);
156+
return { templates: selectedMemes };
157+
},
158+
});
159+
```
160+
161+
### Step 3: Generate Contextual Captions
162+
163+
This step uses AI to create relevant, funny captions based on the extracted frustrations:
164+
165+
```typescript {theme: 'gruvbox-dark'}
166+
const generateCaptionsStep = createStep({
167+
id: 'generate-captions',
168+
description: 'Generate meme captions based on frustrations and template',
169+
inputSchema: z.object({
170+
frustrations: frustrationsSchema,
171+
baseTemplate: memeTemplateSchema,
172+
}),
173+
execute: async ({ inputData }) => {
174+
const captions = await generateObject({
175+
model: openai('gpt-4'),
176+
schema: captionsSchema,
177+
prompt: `Create funny captions for ${inputData.baseTemplate.name}
178+
based on: ${inputData.frustrations}`,
179+
});
180+
return captions.object;
181+
},
182+
});
183+
```
184+
185+
### Step 4: Generate the Final Meme
186+
187+
The final step uses Imgflip's caption API to create the actual meme:
188+
189+
```typescript {theme: 'gruvbox-dark'}
190+
const generateMemeStep = createStep({
191+
id: 'generate-meme',
192+
description: "Create a meme using Imgflip's caption API",
193+
inputSchema: z.object({
194+
baseTemplate: memeTemplateSchema,
195+
captions: captionsSchema,
196+
}),
197+
execute: async ({ inputData }) => {
198+
const formData = new URLSearchParams();
199+
formData.append('template_id', inputData.baseTemplate.id);
200+
formData.append('username', process.env.IMGFLIP_USERNAME || 'imgflip_hubot');
201+
formData.append('password', process.env.IMGFLIP_PASSWORD || 'imgflip_hubot');
202+
formData.append('text0', inputData.captions.topText);
203+
formData.append('text1', inputData.captions.bottomText);
204+
205+
const response = await fetch('https://api.imgflip.com/caption_image', {
206+
method: 'POST',
207+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
208+
body: formData,
209+
});
210+
211+
const result = await response.json();
212+
return {
213+
imageUrl: result.data.url,
214+
pageUrl: result.data.page_url
215+
};
216+
},
217+
});
218+
```
219+
220+
## Real Examples from Our Workshop
221+
222+
Here are actual memes generated during our workshop, showcasing how workplace frustrations get transformed into shareable humor:
24223

25-
<Image src={zackAndNick} alt="Zack and Nick ready to teach" />
224+
### Open Office Nightmares → Workplace Reality
225+
226+
<Image src={good1} alt="Open floor plan noise meme" />
227+
228+
*When they move all the engineers to an open floor plan with noisy co-workers...*
229+
230+
### Compensation Blues → The Talent Paradox
231+
232+
<Image src={good2} alt="Excellent but underpaid meme" />
233+
234+
*Being told you're excellent at your job but somehow still underpaid...*
235+
236+
### The Helper's Dilemma → Salary Irony
237+
238+
<Image src={good3} alt="Helping higher paid colleague meme" />
239+
240+
*When you refer an engineer who constantly asks for your help but gets paid more than you...*
241+
242+
<Image src={good4} alt="Salary disparity meme" />
243+
244+
*That awkward moment when your mentee's starting salary is higher than your current one...*
245+
246+
These examples demonstrate how our AI workflow transforms common workplace frustrations into contextually appropriate and genuinely funny memes that teams can actually share!
247+
248+
## Why Mastra.ai for Production Workflows
249+
250+
### Modular Step Design
251+
252+
Each workflow step is designed to be:
253+
254+
- **Modular**: Can be used independently or as part of larger workflows
255+
- **Typed**: Uses Zod schemas for input/output validation
256+
- **Testable**: Can be tested in isolation using Mastra's built-in tools
257+
- **Reusable**: Can be composed into different workflows
258+
259+
### Built-in Testing and Development
260+
261+
Mastra provides excellent development experience:
262+
263+
```bash {theme: 'gruvbox-dark'}
264+
# Start the development server
265+
npm run dev
266+
267+
# Visit the Mastra playground at http://localhost:4111
268+
# Use the chat interface to test the complete workflow
269+
```
270+
271+
### Error Handling and Reliability
272+
273+
The framework includes graceful error handling and recovery mechanisms, essential for production AI applications.
274+
275+
## Workshop Experience and Results
276+
277+
All of the materials are open source in the [mastra-agents-meme-generator](https://github.com/workos/mastra-agents-meme-generator) repo. We built the full app first, wrote up the steps in `workshop.md`, and staged each phase on a separate git branch so everyone could work at their own pace.
26278

27279
The hands-on format let attendees build a simple pipeline from scratch, then wrap it with an agent interface. Seeing the agents successfully complete tasks through our pipelines was an awesome moment for everyone in the room.
28280

29281
One of us stayed on the mic while the other roamed the room answering questions and fixing issues. This tag-team approach kept everyone moving forward and made sure no one fell behind.
30282

31283
We tied the workshop back to lessons from my [earlier talk at a16z](/blog/a16z-sf-dec-2023-ai-apps-production) about taking prototypes to production. This time, it was all coded live in TypeScript with the Mastra.ai SDK.
32284

33-
34285
<Image src={aieFisheye} alt="Workshop room fisheye view" />
35286

36-
By the end, almost every attendee succeeded in getting the finished agent running. The energy in the room was incredible, and we were fired up by how many developers were brainstorming ways to use Mastra.ai in their own workflows. We can't wait to run more of these sessions in the future. If you want to follow along yourself, head to the [mastra-agents-meme-generator](https://github.com/workos/mastra-agents-meme-generator) repo.
287+
By the end, almost every attendee succeeded in getting the finished agent running. The energy in the room was incredible, and we were fired up by how many developers were brainstorming ways to use Mastra.ai in their own workflows.
288+
289+
## Glowing Feedback from Attendees
290+
291+
The response from workshop attendees was overwhelmingly positive. Here's what engineers said about the experience:
292+
293+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 my-8">
294+
<Image src={feedback1} alt="Workshop feedback highlighting practical learning" className="rounded-lg shadow-lg" />
295+
<Image src={feedback2} alt="Workshop feedback praising hands-on approach" className="rounded-lg shadow-lg" />
296+
</div>
297+
298+
The feedback validated our approach of combining humor with serious technical patterns - attendees appreciated both the engaging format and the practical, production-ready skills they gained.
299+
300+
## Beyond Memes: Enterprise Applications
301+
302+
While our workshop focused on meme generation, the same patterns apply to serious business applications:
303+
304+
### Workflow Types
305+
306+
- **Customer Support**: Multi-step ticket resolution workflows
307+
- **Data Processing**: ETL pipelines with AI-powered transformations
308+
- **Content Generation**: Marketing copy, documentation, reports
309+
- **Business Logic**: Complex approval and routing processes
310+
311+
---
312+
313+
## Interested in AI Workshops for Your Team?
314+
315+
Want to bring hands-on AI training to your organization? I provide workshops and training sessions on building production AI workflows, agentic systems, and practical machine learning implementations.
316+
317+
<section className="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-xl p-8 text-center">
318+
<h2 className="text-2xl font-bold text-gray-900 dark:text-white mb-4">Looking for Technical Training?</h2>
319+
<p className="text-gray-600 dark:text-gray-300 mb-6 max-w-2xl mx-auto">
320+
I'm available for corporate workshops, conference talks, and team training sessions on AI engineering, workflow automation, and developer tools. From hands-on coding sessions to strategic AI implementation planning.
321+
</p>
322+
<div className="flex flex-col sm:flex-row gap-4 justify-center">
323+
<Link
324+
href="/speaking"
325+
className="inline-flex items-center justify-center px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-md transition-colors"
326+
>
327+
View Speaking & Training Services
328+
</Link>
329+
<Link
330+
href="/contact"
331+
className="inline-flex items-center justify-center px-6 py-3 bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-900 dark:text-white font-semibold rounded-md transition-colors"
332+
>
333+
Get in Touch
334+
</Link>
335+
</div>
336+
</section>
37337

38-
If you want to see more events like this one, check out my <Link href="/speaking">speaking page</Link>.
338+
We can't wait to run more of these sessions in the future. If you want to follow along with the workshop materials yourself, head to the [mastra-agents-meme-generator](https://github.com/workos/mastra-agents-meme-generator) repo.

src/images/good1.jpeg

124 KB
Loading

src/images/good2.png

2.06 MB
Loading

src/images/good3.jpg

68.3 KB
Loading

src/images/good4.jpeg

79.9 KB
Loading
36.9 KB
Loading
55.7 KB
Loading

0 commit comments

Comments
 (0)