functions
Manage eduuw serverless functions — TypeScript that reacts to events.
Works with
Agent Skills format with YAML frontmatter. Claude Code reads it as-is.
---
name: "functions"
description: "Manage eduuw serverless functions — TypeScript that reacts to events."
license: "MIT"
---
# Functions
## When to Use
Author and manage serverless functions: TypeScript that reacts to eduuw events (a message arrives, a broadcast is sent, etc.). Base + auth: see `eduuw-rules`.
> **Status:** function **management** (code + trigger + status) is live. The **execution runtime** runs each function as an **isolated Cloudflare Worker** (Workers for Platforms — see *Execution & isolation*). The dispatcher is online and routing is proven; the deploy→execute wiring is being connected. Until fully wired, a `DEPLOYED` function is stored + routable but may not yet auto-run on events.
## Model
`FunctionDef = { id, name, description, trigger, code, status }`.
- **trigger** (event): `message.received | message.status | conversation.started | broadcast.sent`.
- **status:** `DRAFT | DEPLOYED`.
- **code:** TypeScript with a default async handler `export default async function onMessage(event, ctx) { ... }`.
## List
```bash
curl https://api.eduue.com.br/ext/v1/whatsapp/functions \
-H "X-API-Key: $EDUUE_API_KEY" -H "X-Tenant-ID: $TENANT_ID"
# -> { "functions": [ { "id":"...", "name":"echo", "trigger":"message.received", "status":"DEPLOYED" } ] }
```
## Create / update (id empty = create) and deploy
```bash
curl -X POST https://api.eduue.com.br/ext/v1/whatsapp/functions \
-H "X-API-Key: $EDUUE_API_KEY" -H "X-Tenant-ID: $TENANT_ID" -H "Content-Type: application/json" \
-d '{
"name": "echo",
"description": "Responde a qualquer mensagem com o mesmo texto",
"trigger": "message.received",
"status": "DEPLOYED",
"code": "export default async function onMessage(event, ctx) {\n await ctx.wa.sendText(event.message.from, `Você disse: ${event.message.text}`)\n}"
}'
# -> { "id": "<FUNCTION_ID>" }
```
Send `status:"DRAFT"` to save without deploying. Include the `id` to update an existing function.
> ⚠️ `status:"DEPLOYED"` publishes the code as a **live worker** that runs on real inbound events for the tenant. Validate as `DRAFT` (and via the dashboard's test runner) first, and never hardcode secrets in `code` — inject them per-worker (see *Execution & isolation*).
## Get (with code) / delete
```bash
curl https://api.eduue.com.br/ext/v1/whatsapp/functions/<ID> \
-H "X-API-Key: $EDUUE_API_KEY" -H "X-Tenant-ID: $TENANT_ID"
curl -X DELETE https://api.eduue.com.br/ext/v1/whatsapp/functions/<ID> \
-H "X-API-Key: $EDUUE_API_KEY" -H "X-Tenant-ID: $TENANT_ID"
```
## Handler shape (target runtime)
```typescript
// event: the triggering event (e.g. { message: { from, text } })
// ctx: helpers — ctx.wa.sendText(to, text), ctx.ai.chat({system,user}), ctx.fetch(url, init), ctx.secrets.X
export default async function onMessage(event, ctx) {
const reply = await ctx.ai.chat({ system: 'Você é um atendente.', user: event.message.text })
await ctx.wa.sendText(event.message.from, reply)
}
```
## Execution & isolation
Functions run as **isolated Cloudflare Workers** (Workers for Platforms), not `eval` inside the platform process:
- Each function is its **own user worker** inside a dispatch namespace — no shared state, with per-worker CPU/memory/time limits.
- A front **dispatcher worker** authenticates the request (shared secret) and routes to the right user worker by script name (`X-Function-Script`).
- Strong multi-tenant isolation: a function only ever sees its own `ctx` (`wa`/`ai`/`fetch`/`secrets`) — never another tenant's data.
- `status:"DEPLOYED"` publishes the code as a user worker; the runtime invokes it on the `trigger` event with `(event, ctx)`. **Secrets are injected per-worker — never put secrets in the `code`.**
## Starter templates
The dashboard (**Funções**) ships ready-made examples you can clone: minimal echo bot, restaurant-reservation agent, school↔parents assistant, e-commerce order assistant. Start from one, then customize and add secrets.
## Tip
For no-code automations that react to events without writing TypeScript, see `ai-agent` (AI bot + keyword auto-reply).More Refactoring skills
vercel-react-best-practices
vercel-labs/agent-skills
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
analyze-project
lllllllama/rigorpilot-skills
Rigor Analyze / Rigor Audit read-only skill for deep learning research repositories. Use when the user wants to read and understand a repository, inspect model structure and training or inference entrypoints, review configs and insertion points, or flag suspicious implementation patterns without modifying code or running heavy jobs. Do not use for active command execution, broad refactoring, speculative code adaptation, or automatic bug fixing.
request-refactor-plan
mattpocock/skills
Create a detailed refactor plan with tiny commits via user interview, then file it as a GitHub issue. Use when user wants to plan a refactor, create a refactoring RFC, or break a refactor into safe incremental steps.

