Receive Call Updates

View as Markdown

1. Create an endpoint

1const express = require("express");
2const app = express();
3
4app.use(express.json());
5
6app.post("/webhooks/formant", async (req, res) => {
7 const event = req.body;
8 console.log(`Received ${event.event_type}: ${event.event_id}`);
9 res.status(204).send();
10});
11
12app.listen(3000);

2. Add signature verification

Before production, verify X-FormantAI-Signature using the webhook secret.

3. Configure the agent

Open the dashboard:

Agent -> Webhook tab -> Add Target

Set:

  • Name: crm-sync
  • URL: https://your-api.example.com/webhooks/formant
  • Secret: your generated webhook secret
  • Events: call.completed, call.no_answer, call.busy, call.failed
  • Include transcript: enabled if your CRM needs it
  • Include recording URL: enabled if you need recordings

4. Process events idempotently

Webhook delivery can retry. Store event_id and ignore duplicates.

1async function handleEvent(event) {
2 const inserted = await insertEventIfNew(event.event_id, event);
3 if (!inserted) return;
4
5 if (event.event_type === "call.completed") {
6 await updateCustomerFromCall(event.data.call, event.data.results);
7 }
8}

5. Monitor delivery

Track webhook receiver latency and failures. Your endpoint should return a 2xx response within 10 seconds.