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.
What is ctx.jelou?
ctx.jelou is the built-in messaging client. It lets you send WhatsApp messages directly from your function. Available automatically when the company has Jelou API credentials configured.
Check availability
if (!ctx.jelou.available) {
return { error: "Messaging not configured for this company" };
}
Send messages
ctx.jelou.send(options)
Returns { messageId: string }.
Text
Image
Buttons
List
Carousel
Location
await ctx.jelou.send({
type: "text",
to: "+593987654321",
text: "Your order #1234 is on its way",
});
await ctx.jelou.send({
type: "image",
to: "+593987654321",
mediaUrl: "https://cdn.example.com/product.jpg",
caption: "Product: Dell XPS 15 Laptop",
});
await ctx.jelou.send({
type: "buttons",
to: "+593987654321",
text: "How would you like to receive your order?",
buttons: [
{ id: "delivery", title: "Home delivery" },
{ id: "pickup", title: "Store pickup" },
{ id: "express", title: "Express shipping" },
],
});
await ctx.jelou.send({
type: "list",
to: "+593987654321",
text: "Select a product category:",
buttonText: "View categories",
sections: [
{
title: "Electronics",
rows: [
{ id: "laptops", title: "Laptops", description: "Notebooks and portables" },
{ id: "phones", title: "Phones", description: "Smartphones and accessories" },
],
},
],
});
await ctx.jelou.send({
type: "carousel",
to: "+593987654321",
cards: [
{
mediaUrl: "https://cdn.example.com/laptop.jpg",
body: "Dell XPS 15 — $1,299",
buttons: [
{ id: "buy_laptop", title: "Buy" },
{ id: "info_laptop", title: "More info" },
],
},
],
});
await ctx.jelou.send({
type: "location",
to: "+593987654321",
lat: -2.1894,
lng: -79.8891,
name: "Store Guayaquil",
address: "Av. 9 de Octubre 123",
});
Other supported types: video, audio, file, sticker, contacts, quick_reply, cta_url, flow.
Send HSM templates
ctx.jelou.sendTemplate(options)
Returns Array<{ id, destination }>.
await ctx.jelou.sendTemplate({
template: "order_confirmation",
to: "+593987654321",
language: "es",
params: ["Maria", "ORD-1234", "$59.99"],
});
// Multiple recipients
await ctx.jelou.sendTemplate({
template: "monthly_promo",
to: ["+593987654321", "+593912345678"],
params: ["20%", "April 30"],
});
Bot override
All messages default to ctx.bot.id. Override with botId:
await ctx.jelou.send({
type: "text",
to: "+593987654321",
text: "Message from another bot",
botId: "bot-notifications-456",
});
Error handling
import { JelouApiError } from "@jelou/functions";
try {
await ctx.jelou.send({ type: "text", to: "+593987654321", text: "Hello" });
} catch (err) {
if (err instanceof JelouApiError) {
if (err.isRateLimit()) return { error: "rate_limit" };
if (err.isAuth()) return { error: "auth_error" };
if (err.isValidation()) return { error: "validation_error" };
}
throw err;
}
Testing
import { createMockContext, createMockJelouClient } from "@jelou/functions/testing";
const mockJelou = createMockJelouClient();
const ctx = createMockContext({ jelou: mockJelou });
await ctx.jelou.send({ type: "text", to: "+593987654321", text: "Test" });
mockJelou.calls.length; // 1
mockJelou.reset();