Template Messages
Overview
Template Message is a library of ready-made messages that you author once and reuse across multiple channels. Its defining feature is the merge tag system: placeholders that are resolved per recipient at send time, such as the recipient's name, loyalty points, or the value of a custom attribute defined by the organisation.
Beyond plain text, the module supports a Card Builder that accepts an uploaded hero image.
The number of templates an organisation may create is capped by the maxTemplates quota
attached to its plan.
Business Flow
- The template management screen calls
GET /api/template-messageto list templates with pagination, scoped to the current user'slineOaId. - While editing content, the editor calls
GET /api/template-message/merge-tagsto fetch the available merge tags. The response combines system tags (name, LINE display name, and so on) with tags derived from the OA's Attribute Master. TheshowSystemparameter controls whether system tags are included. - New templates are created through
POST /api/template-message(multipart/form-data). The service verifies themaxTemplatesquota and checks for a duplicate name before saving; exceeding the quota returns an error. - Card Builder hero images are uploaded via
POST /api/template-message/upload-image. Because this is a static path, it is registered ahead of/:idso routing resolves to the correct handler. - Other modules that need a picker call
GET /api/template-message/find-all-object. - Standard detail, edit, and delete operations use
GET /api/template-message/:id,PUT /api/template-message/:id(form-data), andDELETE /api/template-message/:id. - At actual send time — from a campaign, an auto-response, or a workflow — merge tags are
substituted by
linemessageapi/mergetag.gowhile the outbound payload is assembled.
Key Files & Functions
Core code lives in internal/modules/templatemessage/, comprising controller.go, service.go,
and dto.go.
| Method | Route | Handler | Policy (metadata) |
|---|---|---|---|
| GET | /api/template-message | ct.findAll | read template-message |
| GET | /api/template-message/merge-tags | ct.getMergeTags | read template-message |
| GET | /api/template-message/find-all-object | ct.findAllObject | — |
| GET | /api/template-message/:id | ct.findOne | read template-message |
| POST | /api/template-message | ct.create | create template-message |
| POST | /api/template-message/upload-image | ct.uploadImage | create template-message |
| PUT | /api/template-message/:id | ct.update | update template-message |
| DELETE | /api/template-message/:id | ct.delete | delete template-message |
Every route is wrapped by modulegate.ModuleGate(d, "template-message").
Connections to Other Services
- Access control — requests must pass
ModuleGate("template-message");PolicyModuleTemplateMessageis declared as per-handler metadata. - Tables —
template_message,attribute_master,system_attribute,line_oa - Redis — caches both the list view and individual template details.
- Storage Service — stores hero images uploaded through the Card Builder.
- Cross-module —
planlimitsfor themaxTemplatesquota, andauthfor user context. - Related modules — Attribute Master (the source of merge tags), Campaign Management, Auto Response, and the LINE Message API (which performs merge tag substitution on send).