Getting Started · 2 min read · For developers
Webhooks
Get call results pushed to your system after each call, and start journeys from your system with a signed webhook.
There are two directions:
| Direction | What | Set up in |
|---|---|---|
| LemuAI → you | After each call, a voice agent sends the result (variables it captured, duration, recording, transcript) to your URL | A Webhook step in the voice agent |
| You → LemuAI | Your system starts a journey for someone by posting to the journey's webhook URL | A journey with the Webhook trigger |
To send events (orders, sign-ups) that start any journey listening for them, use Send an Event instead; it needs your API key and links the event to a contact.
Receive call results#
Add a Webhook step to the voice agent (Voice Agents → Agents, open the agent). Set the HTTP Method, Endpoint URL, optional Auth and Custom Headers, and a Payload Template (JSON) using these variables:
| Variable | Value |
|---|---|
{{workflow_run_id}} | The call's run id |
{{workflow_id}}, {{workflow_name}} | The agent |
{{initial_context.<name>}} | Values the call started with (from the API, a journey or a campaign) |
{{gathered_context.<name>}} | Variables the agent extracted |
{{cost_info.call_duration_seconds}} | Call duration |
{{recording_url}}, {{transcript_url}} | Recording and transcript links |
Example payload template:
{
"call_id": "{{workflow_run_id}}",
"order_id": "{{initial_context.order_id}}",
"confirmed": "{{gathered_context.confirmed}}",
"duration": "{{cost_info.call_duration_seconds}}",
"recording_url": "{{recording_url}}"
}Your endpoint should answer with a 2xx status quickly. See Webhook (voice agent).
Start a journey with a webhook#
Create a journey with the Webhook trigger. Its panel shows the URL to post to:
POST https://app.lemuai.com/api/v1/workflow-execution/webhooks/{trigger_id}The JSON body becomes the run's starting context, so later steps can use {{context.<field>}}. Include the person's phone so steps that call or message have someone to reach. No API key is needed: the URL is the secret. For extra safety, set a secret on the trigger and sign each request.
Signing requests#
When the trigger has a secret, every request must carry:
X-Webhook-Signature: sha256=<hex HMAC-SHA256 of the raw request body, keyed with the secret>Sign the exact bytes you send. Re-serialising the JSON after signing (different spacing or key order) breaks the signature.
BODY='{"phone":"+919876543210","order_id":"A-1001","amount":1499}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | sed 's/^.* //')
curl -X POST "https://app.lemuai.com/api/v1/workflow-execution/webhooks/123" \
-H "Content-Type: application/json" \
-H "X-Webhook-Signature: sha256=$SIG" \
--data-raw "$BODY"Responses#
| Status | Meaning |
|---|---|
200 | The run started. The body includes the trigger and run details |
401 | "Invalid webhook signature": missing or wrong X-Webhook-Signature |
404 | "Trigger {id} not found": the trigger was deleted, or the id is wrong |
400 | "Trigger {id} is not active", "Trigger {id} is not a webhook trigger", a request that doesn't match the trigger's settings (method, content type, required headers), or a journey that isn't live |
See Journeys troubleshooting for each message.
Was this page helpful?
Docs