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
- Receive a payload of
webhookId,headers, andbody— the same shape used by theline_webhookqueue. getLineOAByWebhookId(webhookId)resolves the owning OA, backed by a Redis cache.- If the OA has no
forward_webhook_urlconfigured, log a warning and finish the job with an ack. - Read
x-line-signaturefrom the original headers. POSTthe entire raw body toforward_webhook_url, attaching the originalx-line-signatureand 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.- 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.goService.SendLineForwardWebhook(ctx, payload)— the complete flowstringHeader()andmarshalBody(), the latter re-serialising the body to match Node'sJSON.stringifyoutput so the signature still validates downstream
internal/lineoa/consumer.go—Consumer.HandleLineForwardWebhookinternal/line/client.go—line.ForwardWebhook(ctx, url, xLineSignature, body)internal/lineoa/service.go—getLineOAByWebhookId(), with theLINE_OA:Redis cache- Queue:
line_forward_webhook(runtime profilemain)
Connections to Other Services
- Job source —
line-management-webhook-go, which publishes here in parallel withline_webhook. - Database — the
line_oatable, readingforward_webhook_urlandwebhook_id. - Redis — the OA cache under
LINE_OA:and thewebhook_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.