Send LINE Message (universal)
line_send_messageSend any LINE message to one or multiple users, an audience, or everyone. Automatically selects reply, push, multicast, narrowcast, or broadcast based on target shape.
Instructions
Send any LINE message to any target. Picks the right LINE API automatically (reply / push / multicast / narrowcast / broadcast) based on the shape of target.
Three modes (parameter mode):
send_now (default): Send immediately. Pre-flight validation + Quota Guardian + quiet-hours check are applied.
draft: DO NOT SEND. Return a "handoff package" with audience id, Flex JSON, a LINE OA Manager broadcast URL, and 6 click-through steps. Use this when the user wants to SCHEDULE — LINE OA Manager UI has native scheduling that Messaging API lacks.
dry_run: Validate + estimate cost only. Useful before
confirmflows.
Target shapes (pick one):
{ reply_to: "webhookEventId" } — reply (1 user, free, 30s window)
{ user_id: "U..." } — push to one
{ user_ids: ["U...", "U..."] } — multicast (auto-chunked to 500/call)
{ audience: "name-or-id" } — narrowcast by audience group
{ filter: { ages, genders, areas, ... } } — narrowcast by demographic
{ everyone: true } — broadcast (requires confirm: true)
Message shapes (pick one):
{ text: "..." } — plain text (≤5000 chars)
{ template: "voucher", data: {...} } — pre-built Thai-localized Flex template
{ flex_json: {...}, alt_text: "..." } — raw Flex JSON (advanced)
{ sticker: { package_id, sticker_id } } — LINE sticker
Auto-applied safety:
Pre-flight validation via LINE /validate (catches JSON errors before consuming quota)
Quota Guardian: blocks if projected cost > 95% of remaining quota unless confirm=true
Quiet-hours warning (22:00–08:00 BKK) unless force=true
Reply-token TTL handling: falls back to push if token is expired (with a warning)
Auto-generated X-Line-Retry-Key for safe retries
Returns (varies by mode): send_now → { success, transport, request_id?, recipient_count_estimated, quota, warnings[], next_steps? } draft → { draft: true, oa_manager_url, audience_summary, flex_json_pretty, flex_preview_url, copy_paste_steps[], notes } dry_run → { dry_run: true, transport, validated, projected_recipients, projected_cost_messages, quota, warnings[] }
Examples:
"ส่งข้อความให้คุณ A" → { target: { user_id: "U..." }, message: { text: "..." } }
"ออกแบบโปรวันแม่ + เตรียม schedule" → { target: { audience: "moms" }, message: { template: "promo_simple", data: {...} }, mode: "draft" }
"ส่งโปรให้ผู้หญิง 25-44 กรุงเทพ" → { target: { filter: { genders: ["female"], ages: ["age_25", "age_30"], areas: ["bangkok"] } }, message: {...} }
Errors:
QUOTA_OVER → Reduce audience or wait for monthly reset
QUIET_HOURS → Pass force=true or use mode=draft to schedule
INVALID_MESSAGE → Pre-validation caught a JSON error; check details
AUDIENCE_NOT_READY → Wait ~10 minutes after audience creation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Who to send to. Pick one shape: { reply_to } | { user_id } | { user_ids[] } | { audience } | { filter } | { everyone: true } | |
| message | Yes | What to send. Pick one shape: { text } | { template, data } | { flex_json, alt_text } | { sticker } | |
| mode | No | send_now (default) sends immediately; draft returns a handoff package for LINE OA Manager UI; dry_run validates + estimates without sending. | send_now |
| oa | No | OA id (multi-OA). Omit to use active OA. | |
| confirm | No | Required to be true when projected cost > 95% of remaining quota, or when target.everyone === true. | |
| force | No | Override quiet-hours warning (22:00–08:00 BKK). Defaults false; LINE Thai customers prefer not to be pinged at night. | |
| quiet_push | No | Suppress push notification on recipient device (silent send). Default false. |