Skip to main content

Forwarding Webhooks to External Systems

Overview

Some customers run their own systems — a CRM, or a chatbot they already operate — that also want to receive LINE webhooks. LINE allows only a single webhook URL per channel, so the platform receives the webhook first and then forwards it to the destination configured on the OA profile in line_oa.forward_webhook_url.

Forwarding is isolated in its own queue so that a slow or unavailable destination cannot hold up the main webhook processing path.

Business Flow

  1. Receive a payload of webhookId, headers, and body — the same shape used by the line_webhook queue.
  2. getLineOAByWebhookId(webhookId) resolves the owning OA, backed by a Redis cache.
  3. If the OA has no forward_webhook_url configured, log a warning and finish the job with an ack.
  4. Read x-line-signature from the original headers.
  5. POST the entire raw body to forward_webhook_url, attaching the original x-line-signature and setting the host header to match the destination URL. The customer's system can therefore verify the signature exactly as if it had received the webhook straight from LINE.
  6. Errors are logged and swallowed — the handler returns nil and always acks, matching the legacy behaviour. A customer endpoint being down must never leave messages stuck in the queue or push them into the DLQ.

Key Files & Functions

  • internal/lineoa/forward.go
    • Service.SendLineForwardWebhook(ctx, payload) — the complete flow
    • stringHeader() and marshalBody(), the latter re-serialising the body to match Node's JSON.stringify output so the signature still validates downstream
  • internal/lineoa/consumer.goConsumer.HandleLineForwardWebhook
  • internal/line/client.goline.ForwardWebhook(ctx, url, xLineSignature, body)
  • internal/lineoa/service.gogetLineOAByWebhookId(), with the LINE_OA: Redis cache
  • Queue: line_forward_webhook (runtime profile main)

Connections to Other Services

  • Job sourceline-management-webhook-go, which publishes here in parallel with line_webhook.
  • Database — the line_oa table, reading forward_webhook_url and webhook_id.
  • Redis — the OA cache under LINE_OA: and the webhook_config:<webhookId> entry used by webhook-go.
  • Outbound HTTP — a POST to the customer's URL, with no application-level retry; a failure ends the job.
  • No LINE API calls and no database writes.