WhatsApp follow-up after a call
When a call ends with an outcome you choose, such as interested or call me back, the customer gets your approved WhatsApp template within seconds.
Before you start
- A live key with messages:send.
- An approved WhatsApp template, and a WhatsApp connection on Integrations.
- API access is on Growth and above. Without it every request answers 402, and the key works again once the plan includes it.
How it works
When a call ends with an outcome you choose, such as interested or call me back, the customer gets your approved WhatsApp template within seconds.
Subscribe your webhook to finished calls.
call.completedIn the webhook, look at the call's disposition and pick the calls to follow up, for example interested and callback.
Send the approved template to the call's contact. Each message is billed, and an Idempotency-Key made from the call id is required, so a retried delivery never sends twice. A person on Do-Not-Call, without consent, or in the quiet hours is not messaged.
POST /api/v1/messages/whatsappNo code? On Workflows, make one with the Call Ends trigger and a Send WhatsApp step instead. Use one or the other, not both, or the customer gets two messages.
// Every delivery is signed: check it before you trust the body.
const crypto = require("crypto");
function signed(rawBody, header, secret) {
const want = "sha256=" + crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
return header && crypto.timingSafeEqual(Buffer.from(header), Buffer.from(want));
}
const FOLLOW_UP = ["interested", "callback"]; // the dispositions to follow up
app.post("/aicallstudio", express.raw({ type: "*/*" }), async (req, res) => {
if (!signed(req.body, req.get("X-Aicallstudio-Signature"), process.env.WEBHOOK_SECRET)) return res.sendStatus(401);
const { event, data } = JSON.parse(req.body);
if (event === "call.completed" && FOLLOW_UP.includes(data.call.disposition)) {
await fetch("https://aicallstudio.com/api/v1/messages/whatsapp", { // billed: one message
method: "POST",
headers: {
"Authorization": "Bearer " + process.env.AICALLSTUDIO_KEY,
"Content-Type": "application/json",
"Idempotency-Key": "after-call-" + data.call.id,
},
body: JSON.stringify({
contact_id: data.call.contact_id,
template: "after_call_follow_up", // your approved template's name
values: { "1": data.call.disposition_label },
}),
});
}
res.sendStatus(200);
});Why a template and not a free-text message?
Because the 24-hour window may be closed: only an approved template can start a conversation, so the API sends only templates. A customer who replies opens the window, and your team answers in the WhatsApp inbox.
Costs and what to watch
- Each message is billed. A customer on Do-Not-Call, without consent, or in the quiet hours is not messaged, and the request says so.
More use cases
- Website form to AI call in 60 seconds
- EMI reminder calls with promise-to-pay back into your LMS
- Missed call to WhatsApp and an AI call back
Website form to AI call in 60 seconds
When someone fills in your website form, your AI agent rings them within a minute, already knowing their name and what they asked about.
Read more →EMI reminder calls with promise-to-pay back into your LMS
Each morning your loan system sends the EMIs due; the AI calls each borrower with their own amount and date, and each promise to pay goes back to your LMS.
Read more →Missed call to WhatsApp and an AI call back
A customer rings while every line is busy or after hours: they get a WhatsApp at once, and an AI call back at a time that suits.
Read more →