> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jelou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Inicio rápido

> Crea, prueba y despliega tu primera Jelou Function en menos de 5 minutos.

**1. Instala el CLI**

```bash theme={null}
npm install -g @jelou/cli
```

Verifica la instalación:

```bash theme={null}
jelou --version
```

**2. Autentícate**

Necesitas un token de acceso personal (créalo en el dashboard de Jelou).

```bash theme={null}
jelou login
# Paste your access token: ****
# ✓ Logged in
```

> [!TIP]
>
> En CI puedes pasar el token directamente: `jelou login --token jfn_pat_tu_token`

**3. Inicializa un proyecto**

Crea un directorio y ejecuta `jelou functions init`:

```bash theme={null}
mkdir consultar-cliente && cd consultar-cliente
jelou functions init
# ? Function slug: consultar-cliente
# ? Description: Busca información de clientes para el canal de WhatsApp
# ? Create new or link existing? Create new
# ✓ Created consultar-cliente
```

Esto te genera los archivos base:

| Archivo | Propósito |
| - | - |
| `index.ts` | Tu función principal |
| `jelou.json` | Configuración del proyecto |
| `deno.json` | Import map del SDK |
| `.env` | Variables de entorno locales |

**4. Escribe tu función**

Reemplaza el contenido de `index.ts` con una función que busca clientes por teléfono:

```typescript index.ts theme={null}
import { define, z } from "@jelou/functions";

export default define({
  name: "consultar-cliente",
  description: "Busca información de un cliente por número de teléfono para el canal de soporte",
  input: z.object({
    telefono: z.string().min(10).describe("Número de teléfono del cliente"),
  }),
  output: z.object({
    nombre: z.string(),
    email: z.string(),
    plan: z.string(),
    saldo: z.number(),
  }),
  handler: async (input, ctx) => {
    ctx.log("Buscando cliente", {
      telefono: input.telefono,
      company: ctx.company.id,
    });

    const apiKey = ctx.env.get("CRM_API_KEY");
    const res = await fetch(
      `https://crm.example.com/api/clientes?tel=${input.telefono}`,
      { headers: { Authorization: `Bearer ${apiKey}` } },
    );
    const cliente = await res.json();

    return {
      nombre: cliente.nombre,
      email: cliente.email,
      plan: cliente.plan,
      saldo: cliente.saldo,
    };
  },
});
```

**5. Ejecuta en local**

Inicia el servidor de desarrollo:

```bash theme={null}
jelou functions dev
# ▸ Listening on http://localhost:3000
# ▸ Watching for changes...
```

Tu servidor se recarga automáticamente cuando editas archivos.

**6. Prueba con curl**

En otra terminal, envía una petición:

```bash theme={null}
curl -X POST http://localhost:3000 \
  -H "Content-Type: application/json" \
  -d '{"telefono": "593987654321"}'
```

Respuesta:

```json theme={null}
{
  "nombre": "María García",
  "email": "maria@example.com",
  "plan": "Premium",
  "saldo": 150.00
}
```

> [!TIP]
>
> También puedes probar el endpoint MCP en `http://localhost:3000/mcp` y el health check en `http://localhost:3000/__health`.

**7. Configura secrets**

Antes de desplegar, agrega las variables de entorno que necesita tu función:

```bash theme={null}
jelou functions secrets set consultar-cliente CRM_API_KEY=YOUR_CRM_API_KEY
# ✓ Set 1 secret
```

**8. Despliega a producción**

```bash theme={null}
jelou functions deploy
# ▸ Files: index.ts (1.2 KB), jelou.json (98 B), deno.json (65 B)
# ? Deploy consultar-cliente? (Y/n) y
# ✓ Deployed to https://consultar-cliente.fn.jelou.ai
```

> [!TIP]
>
> Tu función queda protegida por defecto. Para llamarla necesitas una API key de plataforma — créala en [apps.jelou.ai](https://apps.jelou.ai), en la sección de configuración de la app, y envíala como `Authorization: Bearer sk_...`. Consulta la [guía de autenticación](https://docs.jelou.ai/guides/functions/autenticacion.md) para más detalles.

Tu función ya está disponible en producción. Los agentes IA de Jelou pueden invocarla como herramienta MCP automáticamente.

**9. Verifica en producción**

```bash theme={null}
curl -X POST https://consultar-cliente.fn.jelou.ai \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk_..." \
  -d '{"telefono": "593987654321"}'
```

Monitorea los logs en tiempo real:

```bash theme={null}
jelou functions logs consultar-cliente
```

## Siguientes pasos

* [Validación de entrada/salida](https://docs.jelou.ai/guides/functions/validacion.md) — esquemas Zod, coerción de tipos y formato de errores
* [Funciones multi-tool](https://docs.jelou.ai/guides/functions/multi-tool.md) — agrupa varias herramientas en un solo despliegue con `app()`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.