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.
Instale o CLI
npm install -g @jelou/cli
Verifique a instalação:Autentique-se
Você precisa de um token de acesso pessoal (crie um no painel do Jelou).jelou login
# Paste your access token: ****
# ✓ Logged in
Em CI você pode passar o token diretamente: jelou login --token jfn_pat_your_token
Inicialize um projeto
Crie um diretório e execute jelou init:mkdir query-customer && cd query-customer
jelou init
# ? Function slug: query-customer
# ? Description: Looks up customer information for the WhatsApp bot
# ? Create new or link existing? Create new
# ✓ Created query-customer
Isso gera os arquivos base:| Arquivo | Finalidade |
|---|
index.ts | Sua função principal |
jelou.json | Configuração do projeto |
deno.json | Import map do SDK |
.env | Variáveis de ambiente locais |
Escreva sua função
Substitua o conteúdo de index.ts por uma função que consulta clientes pelo telefone:import { define, z } from "@jelou/functions";
export default define({
name: "query-customer",
description: "Looks up customer information by phone number for the support bot",
input: z.object({
phone: z.string().min(10).describe("Customer phone number"),
}),
output: z.object({
name: z.string(),
email: z.string(),
plan: z.string(),
balance: z.number(),
}),
handler: async (input, ctx) => {
ctx.log("Looking up customer", {
phone: input.phone,
company: ctx.company.id,
});
const apiKey = ctx.env.get("CRM_API_KEY");
const res = await fetch(
`https://crm.example.com/api/customers?tel=${input.phone}`,
{ headers: { Authorization: `Bearer ${apiKey}` } },
);
const customer = await res.json();
return {
name: customer.name,
email: customer.email,
plan: customer.plan,
balance: customer.balance,
};
},
});
Execute localmente
Inicie o servidor de desenvolvimento:jelou dev
# ▸ Listening on http://localhost:3000
# ▸ Watching for changes...
O servidor recarrega automaticamente quando você edita os arquivos. Teste com curl
Em outro terminal, envie uma requisição:curl -X POST http://localhost:3000 \
-H "Content-Type: application/json" \
-d '{"phone": "593987654321"}'
Resposta:{
"name": "Maria Garcia",
"email": "[email protected]",
"plan": "Premium",
"balance": 150.00
}
Você também pode testar o endpoint MCP em http://localhost:3000/mcp e o health check em http://localhost:3000/__health.
Configure os secrets
Antes de fazer o deploy, adicione as variáveis de ambiente que sua função precisa:jelou secrets set query-customer CRM_API_KEY=YOUR_CRM_API_KEY
# ✓ Set 1 secret
Faça o deploy para produção
jelou deploy
# ▸ Files: index.ts (1.2 KB), jelou.json (98 B), deno.json (65 B)
# ? Deploy query-customer? (Y/n) y
# ✓ Deployed to https://query-customer.fn.jelou.ai
# ⚠ A default runtime token was created for this function.
# Save it now — it will not be shown again.
# ▸ Token jfn_rt_abc123...
Salve o token — ele não será exibido novamente. Você precisa dele para chamar sua função em produção.
Sua função já está disponível em produção. Os agentes de IA do Jelou podem invocá-la como ferramenta MCP automaticamente.Verifique em produção
curl -X POST https://query-customer.fn.jelou.ai \
-H "Content-Type: application/json" \
-H "X-Jelou-Token: jfn_rt_abc123..." \
-d '{"phone": "593987654321"}'
Monitore os logs em tempo real:jelou logs query-customer
Próximos passos