Skip to content

testWebhook

This page describes the testWebhook() function in zalo-bot-js, used to immediately verify whether the bot's current webhook URL is reachable and responding correctly from Zalo's servers.

Use this function after calling setWebhook() or whenever you suspect the bot is not receiving events, before contacting support.

Function signature

ts
testWebhook(): Promise<TestWebhookResult | undefined>

When to use it

  • diagnose webhook delivery issues
  • verify webhook URL after deployment
  • confirm endpoint is reachable from Zalo's infrastructure
  • avoid contact support for webhook problems

Return value

Returns Promise<TestWebhookResult | undefined>.

ts
interface TestWebhookResult {
  ok: boolean;             // true if API call succeeded
  url: string;             // the webhook URL being tested
  outcome: string;         // classification code
  hint?: string;           // human-readable diagnostic message
}

Outcome codes

OutcomeMeaning
webhook.okWebhook URL responded successfully (2xx)
webhook.http.403Webhook URL rejected with 403 (WAF/CDN block)
webhook.http.404Webhook URL returned 404 (endpoint not deployed)
webhook.http.5xxServer error on your side
webhook.http.otherNon-2xx response (e.g., redirect 3xx)
webhook.err.tlsTLS handshake failure (cert issue)
webhook.err.dnsDNS resolution failure
webhook.err.timeoutWebhook URL did not respond in time
webhook.err.connConnection failure from Zalo's side
webhook.err.proxyProxy connection failure
webhook.err.blockedURL points to blocked address (localhost, internal IP, Zalo domain)
webhook.err.otherUnknown error

Example

ts
const result = await bot.testWebhook();

if (result?.ok && result.outcome === "webhook.ok") {
  console.log("✅ Webhook is working:", result.url);
} else {
  console.error("❌ Webhook test failed:", result?.outcome, result?.hint);
}

Rate limiting

This API is rate-limited per bot per day. When the limit is exceeded, the response returns "ok": false with error code 426.

Practical notes

  • result.ok (outer) indicates the API call succeeded
  • result.outcome tells you whether the webhook URL responded correctly
  • the webhook URL is saved even if verification fails — you can call this again later
  • do not call this in a tight loop; respect the daily rate limit

Next

Last updated: September 7, 2026

Built for Vietnamese developers, documented for everyone.