155 lines
3.2 KiB
Markdown
155 lines
3.2 KiB
Markdown
# Les 10: Supabase Automation - Cron Jobs, Webhooks & AI Workflows
|
|
|
|
> 📋 **Lesmateriaal nog niet uitgewerkt**
|
|
>
|
|
> De volgende bestanden worden gegenereerd wanneer deze les wordt uitgewerkt:
|
|
> - Les10-Slide-Overzicht.md
|
|
> - Les10-Lesplan.md
|
|
> - Les10-Bijlage-A-Lesopdracht.md
|
|
> - Les10-Bijlage-B-Huiswerkopdracht.md
|
|
|
|
---
|
|
|
|
## Hoofdstuk
|
|
**Hoofdstuk 3: Advanced** (Les 8-18)
|
|
|
|
## Beschrijving
|
|
Leer dingen automatiseren met Supabase cron jobs die AI agents triggeren voor intelligente workflows.
|
|
|
|
---
|
|
|
|
## Te Behandelen
|
|
|
|
### Waarom Automatiseren?
|
|
- Verminder manual werk
|
|
- Consistente executie
|
|
- Scale zonder effort
|
|
- 24/7 beschikbaarheid
|
|
|
|
### Types van Automation
|
|
- Scheduled tasks (cron jobs)
|
|
- Event-driven (webhooks)
|
|
- AI-powered workflows
|
|
|
|
### Supabase Edge Functions voor Automation
|
|
- Deno runtime
|
|
- TypeScript
|
|
- Serverless at edge
|
|
|
|
### Scheduled Edge Functions (Cron Jobs)
|
|
- Timing configuratie
|
|
- Use cases
|
|
|
|
### Webhook Edge Functions
|
|
- Getriggerd door database changes
|
|
|
|
### AI Integratie in Edge Functions
|
|
- Call OpenAI/Anthropic APIs
|
|
- Process data met AI
|
|
|
|
### Supabase Cron Jobs
|
|
- pg_cron extension
|
|
- Schedule taken in Postgres
|
|
|
|
### Database Webhooks
|
|
- Supabase Realtime broadcasts
|
|
- INSERT/UPDATE/DELETE triggers
|
|
|
|
### Edge Functions Chainen
|
|
webhook → Edge Function → AI → actie
|
|
|
|
### AI Automation Workflow Patterns
|
|
- Nieuwe user → AI onboarding email
|
|
- Content → AI moderatie → approve/reject
|
|
- Dagelijks → data → AI summary → email
|
|
|
|
### AI Agents in Automation
|
|
- Monitoring agents
|
|
- Data verrijking agents
|
|
|
|
---
|
|
|
|
## Tools
|
|
- Supabase (Edge Functions, pg_cron)
|
|
- Claude API / OpenAI API
|
|
- Resend / SendGrid (email)
|
|
|
|
---
|
|
|
|
## Lesopdracht (2 uur)
|
|
|
|
Bouw 2 automation workflows: 1 scheduled + 1 event-driven met AI.
|
|
|
|
### Deel 1: Scheduled - Daily Summary Email (1 uur)
|
|
|
|
**Flow:**
|
|
```
|
|
Supabase cron (dagelijks 9:00)
|
|
→ Edge Function
|
|
→ Haal gisteren's data op
|
|
→ Claude API voor intelligente samenvatting
|
|
→ Email via Resend/SendGrid
|
|
```
|
|
|
|
- Implementatie
|
|
- Test
|
|
- Documentatie
|
|
|
|
### Deel 2: Event-Driven - AI Content Moderation (1 uur)
|
|
|
|
**Trigger:** Webhook bij nieuwe todo
|
|
|
|
**Flow:**
|
|
```
|
|
INSERT
|
|
→ Webhook
|
|
→ Edge Function
|
|
→ Claude API moderatie check
|
|
→ Flag if problematisch
|
|
→ Enrich if clean (tags, effort estimate, subtask suggestions)
|
|
→ Save to database
|
|
```
|
|
|
|
- Implementatie
|
|
- Test
|
|
- Documentatie
|
|
|
|
---
|
|
|
|
## Huiswerk (2 uur)
|
|
|
|
### Deel 1: Intelligente Notificaties (1 uur)
|
|
|
|
**Cron 8:00:**
|
|
- Haal due todos op
|
|
- Per user: Claude genereert gepersonaliseerd motiverend bericht
|
|
- Email met AI message + todo lijst
|
|
|
|
### Deel 2: AI Task Breakdown Agent (1 uur)
|
|
|
|
**Webhook op INSERT:**
|
|
- Als todo lang/complex → automatisch Claude aanroepen
|
|
- Suggestie 3-5 subtaken
|
|
- Auto-create in database
|
|
|
|
**Test met complex todo**
|
|
|
|
### Deliverables
|
|
- 4 werkende automations
|
|
- Documentatie
|
|
- Reflectie (300 woorden):
|
|
- Kracht van automation?
|
|
- Wat nog meer automatiseren?
|
|
- Gebruik in echte projecten?
|
|
|
|
---
|
|
|
|
## Leerdoelen
|
|
Na deze les kan de student:
|
|
- Supabase Edge Functions schrijven en deployen
|
|
- Cron jobs configureren met pg_cron
|
|
- Webhooks triggeren op database changes
|
|
- AI APIs integreren in Edge Functions
|
|
- Scheduled en event-driven workflows bouwen
|
|
- Praktische AI automation patterns implementeren
|