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.
O que é ctx.jelou?
ctx.jelou é o cliente de mensagens integrado. Permite enviar mensagens de WhatsApp diretamente da sua função. Disponível automaticamente quando a empresa tem credenciais da API do Jelou configuradas.
Verificar disponibilidade
if (!ctx.jelou.available) {
return { error: "Mensagens não configuradas para esta empresa" };
}
Enviar mensagens
ctx.jelou.send(options)
Retorna { messageId: string }.
Texto
Imagem
Botões
Lista
Carrossel
await ctx.jelou.send({
type: "text",
to: "+5511987654321",
text: "Seu pedido #1234 está a caminho",
});
await ctx.jelou.send({
type: "image",
to: "+5511987654321",
mediaUrl: "https://cdn.example.com/produto.jpg",
caption: "Produto: Laptop Dell XPS 15",
});
await ctx.jelou.send({
type: "buttons",
to: "+5511987654321",
text: "Como deseja receber seu pedido?",
buttons: [
{ id: "delivery", title: "Entrega em casa" },
{ id: "pickup", title: "Retirada na loja" },
{ id: "express", title: "Entrega express" },
],
});
await ctx.jelou.send({
type: "list",
to: "+5511987654321",
text: "Selecione uma categoria:",
buttonText: "Ver categorias",
sections: [
{
title: "Eletrônicos",
rows: [
{ id: "laptops", title: "Laptops" },
{ id: "phones", title: "Celulares" },
],
},
],
});
await ctx.jelou.send({
type: "carousel",
to: "+5511987654321",
cards: [
{
mediaUrl: "https://cdn.example.com/laptop.jpg",
body: "Dell XPS 15 — R$6.999",
buttons: [{ id: "buy", title: "Comprar" }],
},
],
});
Outros tipos suportados: video, audio, file, sticker, contacts, quick_reply, cta_url, location, flow.
Templates HSM
await ctx.jelou.sendTemplate({
template: "confirmacao_pedido",
to: "+5511987654321",
language: "pt_BR",
params: ["Maria", "PED-1234", "R$59,99"],
});
Tratamento de erros
import { JelouApiError } from "@jelou/functions";
try {
await ctx.jelou.send({ type: "text", to: "+5511987654321", text: "Olá" });
} catch (err) {
if (err instanceof JelouApiError) {
if (err.isRateLimit()) return { error: "rate_limit" };
if (err.isAuth()) return { error: "auth_error" };
}
throw err;
}
Testes
import { createMockContext, createMockJelouClient } from "@jelou/functions/testing";
const mockJelou = createMockJelouClient();
const ctx = createMockContext({ jelou: mockJelou });
await ctx.jelou.send({ type: "text", to: "+5511987654321", text: "Test" });
mockJelou.calls.length; // 1