# tawk.to webhooks in production: duplicates, ordering, retries and timeouts

Agent skill: `npx skills add hookdeck/webhook-skills --skill tawk-to-webhooks` ([details](https://hookdeck.com/webhooks/tawk-to/skill))

This guide covers the problems tawk.to webhooks cause in production and how to handle each one. What tawk.to sends and how it works is on the [tawk.to webhooks](/webhooks/tawk-to) overview, the four events are on [tawk.to webhook events](/webhooks/tawk-to/events), and signature verification code is on [Verify tawk.to webhooks](/webhooks/tawk-to/verify).

## At a glance

| Problem | What to do | With Event Gateway |
| --- | --- | --- |
| [Timeouts](#timeouts) | Return a 2xx within 30 seconds; process in a background job | Accepts the delivery at once, then queues it for your service |
| [Duplicates](#duplicates) | Deduplicate on `X-Hook-Event-Id` | Can drop repeats before they reach your handler |
| [Ordering](#ordering) | Tie events together with the chat ID and compare `time` | Logs every event and attempt, so you can see arrival order when debugging |
| [Retries](#retries) | Fix outages inside 12 hours; expect no resend after that | Accepts deliveries while your service is down and replays them |
| [Choosing events](#choosing-events) | Subscribe to what you handle; route on the `event` field | Filters and routes events by type |
| [Testing](#testing) | Forward to localhost and run real chats and tickets | Forwards to localhost and replays past events |
| [Other limits](#other-limits) | Plan for the webhook limit, no replay protection and personal data | Verifies the signature and fans one URL out to many services |

## tawk.to webhook timeouts and slow handlers {#timeouts}

Return a `2xx` within 30 seconds, and do the work in a background job.

**Why it happens:** tawk.to waits 30 seconds for a response. If none arrives, the call counts as a failure and is retried, even if your handler later finishes the work.

**Fix it in your handler:**

1. Verify the signature, store the raw body and return `200`.
2. Process it in a worker. See [why to process webhooks asynchronously](/webhooks/guides/why-implement-asynchronous-processing-webhooks).
3. Keep calls to your CRM, ticketing system and other services out of the request path.

**With Event Gateway:** Hookdeck accepts each tawk.to delivery immediately, then queues it and delivers to your service at a rate it can handle. A slow handler doesn't cause tawk.to to retry.

## Duplicate tawk.to webhooks {#duplicates}

A retry repeats the event with the same `X-Hook-Event-Id`, so deduplicate on that header.

**Why it happens:** tawk.to retries after any non-`2xx` response or timeout, so a handler that did the work and then failed to respond in time gets the event again. tawk.to's own advice is to make sure your system can handle duplicate requests safely.

**Fix it in your handler:**

1. Save each `X-Hook-Event-Id` under a unique constraint before you process the event, and skip any you've seen. See [how to implement webhook idempotency](/webhooks/guides/implement-webhook-idempotency).
2. If two webhooks subscribe to the same event, don't assume they share an event ID, because the docs don't say. Key side effects on `chatId`, `chat.id` or `ticket.id` as well.

**With Event Gateway:** Hookdeck's deduplication can drop repeated deliveries with the same `X-Hook-Event-Id` before they reach your service, and you choose the fields it compares.

## Out-of-order tawk.to webhooks {#ordering}

tawk.to doesn't document delivery order, so don't build logic that needs `chat:start` to arrive before `chat:end`.

**Why it happens:** Nothing in the docs rules out a retried delivery arriving after a newer event, and the spacing between retries isn't published.

**Fix it in your handler:**

1. Tie chat events together with `chatId`, which is `chat.id` on `chat:transcript_created`.
2. Compare the `time` field, which holds when the event was generated, with the last one you applied to that chat.
3. Accept a `chat:end` for a chat you haven't seen, and create the record from its `visitor` and `property` fields.

**With Event Gateway:** Hookdeck logs every event and delivery attempt, so you can see the order things arrived in while you debug. It doesn't put events back in order, so your handler still needs these checks.

## tawk.to webhook retries {#retries}

tawk.to retries for up to 12 hours, so an outage longer than that can lose events for good.

**Why it happens:** Anything other than a `2xx`, or no response within 30 seconds, is retried. tawk.to doesn't publish the spacing between attempts, and its docs describe no attempts after the 12 hours and no way to resend an event.

**Fix it in your handler:**

1. Monitor the endpoint so that outages are fixed well inside 12 hours.
2. Return a non-`2xx` only when you want a retry. Acknowledge events you've chosen to ignore.
3. Don't count on a later event to make up for a lost one. `chat:transcript_created` is a webhook delivery too, so a long outage can lose it along with `chat:end`.

**With Event Gateway:** Hookdeck accepts deliveries while your service is down, retries to your service on a schedule you set, and lets you replay anything that failed, so tawk.to's 12 hours aren't what you depend on.

## Choosing tawk.to events {#choosing-events}

Subscribe each webhook to the events it handles, and route on the body's `event` field, because no header names the event.

**Why it happens:** There are four events, and each covers less than its name might suggest. `chat:start` covers only the first message from a visitor or agent, whispers and system notifications such as triggers don't count, and no event is documented for later messages. `chat:end` has no messages. The conversation comes in `chat:transcript_created`, which tawk.to sends after 3 minutes of inactivity once all chats with the customer have ended. The two payloads with messages also describe senders differently: `chat:start` uses `message.sender.type` with `agent`, `visitor` or `system`, and the transcript uses `sender.t` with `a`, `v` or `s`.

**Fix it in your handler:**

1. Use `chat:transcript_created` for anything that needs the messages, such as archiving or analysis, and use `chat:start` for alerts.
2. Switch on `event`, and log and acknowledge anything you don't recognise, rather than returning an error that triggers retries.
3. If one receiver handles several properties, check `property.id`, since webhooks are set up per property.

**With Event Gateway:** Hookdeck filters and routes events by the `event` field, so each one can go to the service that handles it.

## Testing tawk.to webhooks {#testing}

Point a webhook at your machine and run real chats and tickets through it.

**Why it's awkward:** tawk.to's docs describe no test button. Its examples are JavaScript object literals, with unquoted keys, single-quoted strings and one trailing comma, so they won't parse as JSON if you paste them into a test. They also differ from the field tables: the `ticket:create` example has a `requester.type` the table doesn't list, and the transcript sample in tawk.to's help center leaves out `domain` and `referrer`.

**How to test:**

1. Forward deliveries to your machine with `hookdeck listen`, and use the URL it prints as the webhook's endpoint.
2. Start a chat on a page with your widget, or create a ticket. tawk.to also suggests running a few test chats before you go live.
3. For `chat:transcript_created`, leave the chat inactive for 3 minutes.
4. Build fixtures from real deliveries, and treat any field the tables don't list as optional.

**With Event Gateway:** The CLI forwards events to localhost, and you can replay past events to your handler while you work on it, so you don't have to start another chat.

## Other tawk.to limits {#other-limits}

A few other things catch people out in production: the webhook limit, the lack of replay protection, and the personal data these payloads carry.

**Why it happens:** A property can have up to 10 webhooks, and the endpoint URL must support HTTPS. The signature covers only the body and no timestamp is sent, so a captured request still verifies if it's sent again. tawk.to publishes no source IP list. The visitor's `email` is optional, and transcripts can contain personal information and attachment URLs.

**Fix it in your handler:**

1. Treat your record of `X-Hook-Event-Id` values as your replay protection.
2. Match visitors to CRM records by email only when one is present. tawk.to's examples show a visitor name like `V1561719148780935`, so don't assume `name` is a real name.
3. Decide what you keep from each transcript, whether you fetch and store attachments, and who can read them.

**With Event Gateway:** Hookdeck verifies the signature, gives tawk.to one stable URL however your services change, and fans events out to as many destinations as you need, so you don't use up a property's 10 webhooks.

## Conclusion

tawk.to gives you 30 seconds to respond and 12 hours of retries, with no documented way to resend after that. Return quickly, deduplicate on `X-Hook-Event-Id`, route on the `event` field, and use `chat:transcript_created` when you need the conversation.

[Hookdeck Event Gateway](https://hookdeck.com) sits in front of your receiver, verifies every tawk.to signature and holds each event until your service has processed it.

[Get started with Hookdeck](https://dashboard.hookdeck.com/signup) for free and handle tawk.to webhooks reliably in minutes.