Skip to main content
ConceptsMeta-tools

codespar_notify

Messaging meta-tool. WhatsApp BR via Z-API; SMS / email USD via Twilio + SendGrid; WhatsApp INTL via Twilio.

2 min read · updated

codespar_notify

Meta-tool

codespar_notify is the unified messaging interface for transactional notifications — order confirmations, shipping updates, payment receipts, KYC nudges. The agent picks recipient and message; CodeSpar picks the channel and rail.

There is no typed wrapper yet — call via session.execute() (or session.send() if you do not need the delivery receipt).

Rails

RailCurrencyCountryProviderNotes
WhatsAppBRLBRZ-APIDefault for BR — path_secret auth, phone_id-scoped
WhatsAppINTLINTLTwilioForm-encoded body. Different from Z-API's JSON shape
SMSUSDINTLTwilioAccount SID + Auth Token
EmailUSDINTLSendGridAPI key

The router prefers Z-API for BR WhatsApp because Z-API has lower latency and supports template-free chat for verified business numbers; Twilio is the global fallback.

Direct execute

const result = await session.execute("codespar_notify", {
  recipient: "+5511999998888",
  message: "Olá, Maria! Seu pedido #1234 foi enviado. Rastreio: BR123456789.",
  channel: "whatsapp",
});

console.log(result.id, result.status); // "queued" or "sent"

For email:

const result = await session.execute("codespar_notify", {
  recipient: "maria@example.com",
  subject: "Order #1234 confirmation",
  message: "Hi Maria, your order has shipped.",
  channel: "email",
});

Args shape

FieldTypeRequiredDescription
recipientstringYesPhone in E.164 format (+5511...) for WhatsApp/SMS, email address for email
messagestringYesBody content. WhatsApp BR honors plaintext; email + SMS truncate at provider limits
channelstringNowhatsapp, sms, email. Inferred from recipient shape if omitted
subjectstringNoEmail only
template_idstringNoProvider-side template id (Z-API HSM, Twilio template, SendGrid dynamic-template)
variablesobjectNoTemplate substitutions when template_id is set

Result shape

type NotifyResult = {
  id: string;                    // provider message id
  status: "queued" | "sent" | "delivered" | "failed";
  channel: string;
  delivered_at?: string;         // ISO 8601, set on terminal "delivered"
};

For session.execute() you get the synchronous send/queue result. Delivery confirmation lands later as a webhook — wire a trigger on notify.delivered if you need it.

Operator setup

Each rail wants its own credentials in /dashboard/auth-configs:

  • Z-APIpath_secret auth_type. Operator uploads a phone-id (path-embedded) plus a companion header token. Connection scoped to a single Z-API instance.
  • Twilio — Account SID + Auth Token (basic-auth shape). Same credentials drive SMS, voice, and Twilio WhatsApp.
  • SendGrid — API key (api_key auth_type) with mail.send scope.

For Z-API the path_secret pattern is documented in path_secret auth — the phone_id is the path component and the companion header is Client-Token.

See also

Edit on GitHub

Last updated on