Lead Webhooks
Token-based authentication. Push leads from any CRM or form tool into Naturalead.
WhatsApp (Meta)
HMAC-SHA256 signature verification via the Meta Cloud API.
Telegram
Registered as a Telegram bot webhook URL via BotFather.
Email (Resend)
Inbound email events from Resend with conversation threading.
Lead inbound webhook
The lead webhook lets you push leads into Naturalead from any external system (CRM, landing page, form builder, etc.) without API key authentication. Each account has a unique webhook token.Leads are deduplicated by phone number. If a lead with the same phone already exists, the webhook returns
201 with created: false and the existing lead ID. Any additional string fields beyond name, phone, email, and tags are stored as custom fields.WhatsApp webhook (Meta Cloud API)
The WhatsApp integration uses the Meta Cloud API. You need to configure your WABA (WhatsApp Business Account) in the Meta Developer Portal and point the webhook to Naturalead.META_WEBHOOK_VERIFY_TOKENFB_APP_SECRETFB_APP_IDIn the Meta Developer Portal, navigate to your app’s WhatsApp configuration and set the webhook URL:
Enter the same verify token you set in
META_WEBHOOK_VERIFY_TOKEN. Meta will send a GET request with a challenge that Naturalead echoes back to complete verification.Every inbound POST from Meta includes an
X-Hub-Signature-256 header containing an HMAC-SHA256 hash of the request body, signed with your FB_APP_SECRET.const crypto = require("crypto");
function validateSignature(rawBody, signature, appSecret) {
const expected =
"sha256=" +
crypto.createHmac("sha256", appSecret).update(rawBody).digest("hex");
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}
If
FB_APP_SECRET is not configured, signature validation is skipped (development mode only). Always set it in production.The WhatsApp webhook always returns HTTP 200, even on errors. This is required by Meta — non-200 responses cause Meta to retry with exponential backoff and eventually disable the webhook.
Telegram webhook
The Telegram integration uses a bot token from BotFather. Naturalead registers itself as the bot’s webhook endpoint./newbot and follow the prompts123456789:ABCdefGHIjklMNOpqrsTUVwxyz)Naturalead verifies the token by calling the Telegram
getMe API. If valid, the token is saved and the webhook URL is:curl "https://api.telegram.org/bot${BOT_TOKEN}/setWebhook?url=https://your-api-domain.com/api/webhooks/telegram"
When a user sends a text message to the bot, Telegram posts an Update object to the webhook. Naturalead:
Email webhook (Resend)
The email integration uses Resend for both sending and receiving emails. Inbound emails are received via Resend webhook events.The configure endpoint returns DNS records (SPF, DKIM, etc.) that must be added to your domain before verification will pass.
https://your-api-domain.com/api/webhooks/emailemail.received eventSet the
RESEND_RECEIVING_DOMAIN environment variable to your inbound email domain. Naturalead uses the pattern reply+{conversationId}@{domain} for email threading, allowing it to match inbound replies to the correct conversation.reply+{conversationId}@{domain}to addressWebhook token management
Each Naturalead account has a unique
webhookToken generated at account creation. This token is used exclusively for the lead inbound webhook and is separate from API keys.- The webhook token is visible via
GET /api/accounts/current(requiresaccount:viewpermission) - Webhook tokens do not expire — if compromised, contact support to regenerate
- All leads created via webhook are logged to the audit trail with
source: "webhook"
Troubleshooting
| Problem | Solution |
|---|---|
| Lead webhook returns 401 | Check that the token in the URL matches your account’s webhookToken |
| WhatsApp messages not arriving | Verify the webhook URL is registered in Meta Developer Portal and the META_WEBHOOK_VERIFY_TOKEN matches |
| WhatsApp signature validation fails | Ensure FB_APP_SECRET is set correctly and the raw request body is preserved |
| Telegram bot not responding | Run getWebhookInfo to confirm the URL is registered: curl https://api.telegram.org/bot${BOT_TOKEN}/getWebhookInfo |
| Email replies not detected | Check that RESEND_RECEIVING_DOMAIN matches your domain and DNS records are verified |
| Email content is empty | Verify the Resend webhook is subscribed to email.received events and RESEND_API_KEY is set |