Developers · Guides
Integration examples
OTP login, order updates, CRM sync and lead capture, end to end.
On this page
Complete patterns you can adapt. Each one lists what to set up in the workspace, then the code.
OTP login
Set up: an approved Authentication template (here login_code) and a connected app for your auth service.
import crypto from "node:crypto";export async function sendLoginCode(phone) { const code = crypto.randomInt(100000, 1000000).toString(); await saveCodeForPhone(phone, code, { expiresInSeconds: 300 }); // your own storage const res = await fetch(process.env.CODIQUE_API_URL + "/api/app-notifications/send", { method: "POST", headers: { "Content-Type": "application/json", "x-app-id": process.env.CODIQUE_APP_ID, "x-app-service-key": process.env.CODIQUE_SERVICE_KEY, }, body: JSON.stringify({ to: phone, category: "SYSTEM", notification_type: "login_otp", template_name: "login_code", template_variables: [code], // also fills the copy-code button app_user_id: phone, }), }); if (!res.ok) throw new Error((await res.json()).error);}Order updates with a tracking button
Set up: a Utility template order_shipped with an image header, body “Hi {{1}}, order {{2}} has shipped”, and a website button https://shop.example.com/track/{{1}}. Get its template code, then call it from your order system when the status changes.
def notify_order_shipped(order): res = requests.post( f"{CODIQUE_API_URL}/api/app-notifications/send", headers={"x-app-id": APP_ID, "x-app-service-key": SERVICE_KEY}, json={ "to": order.customer_phone, "category": "TRANSACTIONAL", "notification_type": "order_shipped", "template_name": "order_shipped", "template_variables": [order.customer_first_name, order.number], "button_variables": [order.tracking_id], "header_media_url": order.product_image_url, # optional "metadata": {"order_id": order.id}, }, timeout=30, ) if res.status_code != 200: log.warning("WhatsApp update failed for %s: %s", order.id, res.json().get("error"))When the customer replies (“when will it arrive?”), the reply lands in the inbox thread with your notification above it, so your agent has the context.
Push WhatsApp conversations into your CRM
Set up: an outbound webhook subscribed to message.received and contact.created, and an API key with contact:read and inbox:read.
- Your webhook receiver verifies the signature and queues the event (see Receive events).
- For
contact.created, create the lead in your CRM usingwa_idas the key. - For
message.received, attachbodyto the CRM record as an activity. Link back withconversation_id. - Need more detail? Call
GET /api/v1/contacts?search=<wa_id>orGET /api/v1/conversations/<conversation_id>/messages.
Website form to WhatsApp follow-up
Set up: a workflow that starts with Inbound webhook received and sends a welcome template, waits for a reply and assigns the Sales team; and an inbound webhook endpoint website-lead with that workflow as its default.
<?php$body = json_encode([ "phone" => $_POST["phone"], // with country code "name" => $_POST["name"], "event" => "website_lead", "interest" => $_POST["product"],]);$signature = "sha256=" . hash_hmac("sha256", $body, getenv("CODIQUE_INBOUND_SECRET"));$ch = curl_init(getenv("CODIQUE_INBOUND_URL"));curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, CURLOPT_HTTPHEADER => ["Content-Type: application/json", "X-Webhook-Signature-256: " . $signature], CURLOPT_POSTFIELDS => $body,]);curl_exec($ch);curl_close($ch);Tip
interest is available to the workflow’s messages.Campaign results to your reporting
Subscribe a webhook to campaign.completed. When it arrives, call GET /api/v1/campaigns/<id>/recipients (or /export.csv) with a campaign:read key and load each recipient’s final status into your warehouse.
Still stuck? Contact us with what you were doing and the exact message you saw.