ctx.jelou es el cliente de mensajería integrado. Permite enviar mensajes de WhatsApp directamente desde tu función sin configurar APIs externas. Está disponible automáticamente cuando la empresa tiene credenciales de la API de Jelou configuradas.
handler: async (input, ctx) => { if (!ctx.jelou.available) { return { error: "Mensajería no configurada para esta empresa" }; } await ctx.jelou.send({ type: "text", to: input.telefono, text: "Hola" }); return { enviado: true };}
ctx.jelou.available es false cuando la empresa no tiene clientId/clientSecret configurados. Llamar a send() o sendTemplate() en un cliente no disponible lanza un Error.
await ctx.jelou.send({ type: "video", to: "+593987654321", mediaUrl: "https://cdn.example.com/tutorial.mp4", caption: "Tutorial de configuración",});
await ctx.jelou.send({ type: "file", to: "+593987654321", mediaUrl: "https://cdn.example.com/factura.pdf", filename: "factura-1234.pdf", caption: "Tu factura del mes de abril",});
await ctx.jelou.send({ type: "audio", to: "+593987654321", mediaUrl: "https://cdn.example.com/mensaje.ogg",});
await ctx.jelou.send({ type: "quick_reply", to: "+593987654321", text: "¿Fue útil esta información?", replies: [ { title: "Sí, gracias", payload: "helpful_yes" }, { title: "No, necesito más ayuda", payload: "helpful_no" }, ],});
await ctx.jelou.send({ type: "cta_url", to: "+593987654321", text: "Completa tu compra en nuestra tienda:", displayText: "Ir a la tienda", url: "https://tienda.example.com/checkout/1234",});