Chatbot Config

Configure LINE Chatbot Keyword Triggers

line聊天官方团队
LINE chatbot keyword trigger, LINE fallback response tutorial, set LINE bot auto reply, LINE Messaging API keyword matching, configure LINE unknown message handler, LINE bot default reply best practice, how to add LINE chatbot keywords, LINE keyword trigger regular expression, LINE fallback response example, LINE bot unmatched message handling
keywordfallbacktriggersetupmatchreply

Why keyword triggers still matter in 2025

Although Clova Chat+ (GPT-4o-mini) can already answer free-form questions inside LINE, keyword triggers remain the only native, deterministic way to guarantee an instant, compliant reply the millisecond a shopper types “refund policy” or “track parcel”. Operators who rely solely on generative answers risk 3–5 s latency and occasional hallucinations—unacceptable during flash-sales that convert in under seven seconds according to LINE Shopping 2025-Q3 metrics.

The trade-off is maintenance: every new campaign (coupons, holidays, limited drops) forces you to add, retire or re-prioritise keywords. This article walks through the shortest paths, the hidden side-effects, and a checklist to decide when a keyword is cheaper than fine-tuning the LLM.

Feature snapshot: what the official console actually exposes

LINE’s bot server API offers two layers you can combine:

  1. Exact-keyword webhook – the message text must be identical after Unicode normalisation (NFKC).
  2. Regular-expression pattern – POSIX ERE, max 512 bytes, case-insensitive flag optional.

Both live inside the same channel; the first match wins. There is no built-in “confidence score” or semantic similarity—if you need fuzzy logic you must proxy the request through your own middleware or call Clova Chat+ explicitly. Keep this ceiling in mind before promising marketing “AI understands everything”.

Console path: fastest route on each platform

Provider account (desktop, v10.12)

  1. Open manager.line.biz → log in with the provider that owns the official account.
  2. Select the target account → “Reply settings” → “Bot settings” → “Keyword replies”.
  3. Tap “Add keyword”, choose “Exact” or “Pattern”, enter the string, then link an existing rich message or create a new text reply.
  4. Drag rows to reorder; top-most wins.
  5. Click “Test” → the console pushes a dummy event to your callback URL; 200 OK must return within one second or the UI highlights timeout in red.

Android / iOS management app

The mobile app hides the same menu under “Account home” → “Auto-reply” → “Keyword”. Editing regex on a phone keyboard is painful; reserve this entry for quick toggles (on/off) rather than authoring complex patterns.

Tip: if the “Keyword replies” tile is greyed out, the account is still in “Friend auto-message” only mode. Switch to “Bot enabled” first; the toggle is directly above the keyword list.

Fallback flow: what happens when nothing matches

LINE does not provide a global “else” box. Instead, the final fallback is whatever you code in your webhook: return an empty 200 to stay silent, echo a generic text, or forward the user’s text to Clova Chat+. A pragmatic pattern:

if (exactKeywordHit) {
    return richMessage;
} else if (patternHit) {
    return couponCarousel;
} else {
    // fallback
    return clovaChatPlus.ask(req.text);
}

Measure before and after: an apparel brand observed 18 % more cart checkouts after routing unmatched queries to an LLM instead of a static “Please rephrase”. However, the same move increased server cost 3×; they eventually gated the LLM fallback to users who spent ≥ 1 USD in the previous 30 days.

Side-effect audit: four traps that surface weeks later

  • Emoji normalisation: “🙂” (U+1F642) and “☺” (U+263A) are different code points; if your keyword uses one and the user the other, the match fails. Either include both or switch to regex with a character class.
  • Case folding in Thai: LINE lower-cases Latin but leaves Thai script untouched; if you expect mixed-language input, normalise on your server.
  • Rate limit sharing: keyword replies consume the same 1 000 messages / 1 second quota as push broadcasts. A viral post can exhaust the bucket and delay keyword replies—users perceive this as “bot is dead”.
  • Index fragmentation: after 2 000+ rows the console search slows; an “export → prune → re-import” cycle every quarter restores speed (empirical observation, reproducible by timing the render of the list before/after deletion).

These issues rarely appear in staging because test corpora seldom exceed 100 rows. Schedule a quarterly “keyword health week” where ops, linguistics and customer service jointly prune < 1 % hit rules and reconcile emoji variants.

When NOT to add another keyword

Use the following veto rules to stop keyword inflation:

  1. The expected monthly volume is < 30 unique users—Clova Chat+ can handle this cheaper than human curation time.
  2. The phrase is time-sensitive (“Black Friday 2025 40 % off”) and will expire within 7 days; schedule a broadcast instead so you do not forget to delete the rule.
  3. The query requires PII validation (“Why was my refund 3 000 JPY short?”); always escalate to a human or authenticated webview.

A quick litmus test: if the answer changes more often than your sprint cycle, or needs user authentication, it should not be a keyword. This discipline keeps the rule set stable and reviewable by non-developers.

Mini-case: airline reschedule surge during typhoon

An Asian carrier’s LINE account jumped from 400 to 12 000 messages per hour when Typhoon Mawar hit. Pre-loaded keywords “typhoon”, “cancel”, “reschedule” routed users to a rich menu with rebooking buttons. 92 % of users who triggered the keyword solved their issue without an agent, cutting wait time from 45 min to 3 min. Post-crisis analytics showed 4 % still clicked “Talk to human”—those were edge cases (codeshare flights) the keyword could not cover, validating the fallback design.

The airline now keeps 30 “crisis keywords” permanently disabled but ready to activate via CSV import, cutting contingency deployment from 2 hours to 5 minutes. This example illustrates how deterministic keywords excel under sudden traffic spikes where latency equals reputation.

Testing checklist: ship without surprises

Checkpoint Tool Pass criteria
Unicode equivalence Python unicodedata.normalize('NFKC', txt) Both “①” and “1” fire the keyword
Timeout budget Postman mock server Reply < 1 000 ms at p99
Rate-limit spill k6 load script No 429 under 1 200 msg / s burst
Fallback sanity Randomised 100 nonsense sentences All receive polite fallback, zero crashes

Automate the above in CI so any pull request that touches keyword CSV must pass the four gates before merge. This prevents “works on my laptop” surprises when non-ASCII emoji slip in from marketing decks.

Version differences & migration advice

If your channel was created before July 2023 you may still see “String rule (legacy)” in the export CSV. Legacy rules support wildcards “*” only; they are evaluated AFTER modern regex. Migrate by exporting, converting “*” to “.*”, then re-importing—LINE marks legacy rows inactive once the new file uploads successfully. No downtime occurs because evaluation order preserves the old set until the new set is validated.

Always keep the export CSV under Git; a diff immediately reveals unintended reordering or accidental duplication when multiple operators work concurrently.

Verification & observability in production

Enable “Detailed event log” in the console (bot settings → analytics). The log streams to your webhook an extra header X-Line-Keyword-Id when a match fires. Store this ID together with your own request UUID to build a Grafana panel showing keyword hit ratio. An abrupt drop often signals an accidental reordering or an emoji mismatch introduced by a copy-paste from a Word file.

Supplement this with a nightly BigQuery job that joins X-Line-Keyword-Id with revenue events. Rules whose hit-to-order ratio falls below 0.5 % for two consecutive weeks are flagged for retirement, keeping the rule set lean.

Applicable / non-applicable scale matrix

  • 1 k–10 k followers, ≤ 30 msg / day: keyword first, LLM fallback—cost negligible.
  • 100 k followers, flash sale spikes: combine keyword for top 20 intents, cache the rest—offload to CDN-backed rich menus.
  • 1 M+ followers, regulated (finance, healthcare): keywords only for compliance disclosures; route everything else to authenticated webviews to keep audit trails.

The matrix is empirical: operators who violate the guidance—e.g., managing 1 M+ users with 3 000 hand-curated keywords—report console load times > 10 s and frequent 429 errors during campaigns. Conversely, sub-10 k accounts that over-engineer with middleware latency often pay more for cloud functions than they earn in incremental sales.

Case study 1: indie skincare brand (18 k followers)

Challenge: limited staff, nightly flash “mystery box” drops, customers repeatedly asked “What’s inside tonight?” causing 30 s wait in Clova Chat+.

Implementation: added exact keyword “tonight box” pointing to a rich message with blurred image + tap-to-reveal link; deployed via mobile console 5 min before drop.

Result: 81 % of incoming “tonight” queries resolved by keyword; support tickets dropped from 120 to 23 on drop night. Server cost unchanged.

Reversal: forgot to disable the keyword after drop; next morning users tapping the rich message saw sold-out page, generating 15 complaints. Lesson: schedule keyword expiry alarms in Google Calendar immediately after creation.

Case study 2: regional telecom (1.2 M followers)

Challenge: legally required to provide balance enquiry within 3 s; generative model averaged 2.8 s plus occasional hallucinations of non-existent data.

Implementation: deployed 4 regex patterns covering “balance”, “คงเหลือ” (Thai), “残高” (Japanese), plus emoji variants; webhook responds with prepaid API call encrypted rich message.

Result: p99 latency 0.6 s, zero regulatory warnings in 6 months. Keyword hit rate 9 % of total traffic, but covers 94 % of balance intents.

Reversal: quarterly Unicode update added U+1F4B0 “💰” which teenagers used instead of “balance”; missed it for 3 weeks until observability panel showed drop in hit ratio. Now include top 5 money emoji in character class regex.

Runbook: monitor, diagnose & roll back

1. Anomaly signals

Watch for (a) keyword hit ratio drops > 20 % day-over-day, (b) median response time > 1 000 ms, (c) sudden spike in fallback volume.

2. Localise in 5 min

  1. Compare last deployed CSV hash with Git HEAD—detect accidental reordering.
  2. Search console audit log for “keyword reorder” events.
  3. Export current CSV, run local grep -P against top 100 user messages from BigQuery to confirm matchability.

3. Rollback path

Console supports one-click “Restore last version” up to 30 days; beyond that re-import previous Git-tagged CSV. No downtime, but validation can take 2–3 minutes—communicate “bot maintenance” rich message if necessary.

4. Quarterly chaos drill

Deliberately inject 1 500 msg / s for 60 s using k6; verify 429 responses stay below 0.1 % and keyword fallback still routes to Clova Chat+ without memory leak. Record RTO & RPO metrics; share post-mortem with customer service.

FAQ

Q: Can one keyword trigger two different replies based on user language?

A: No; the first match wins. Workaround: prefix keyword with language code in regex, e.g. ^(EN|TH).*balance, then branch inside webhook.

Q: Is there a limit to how many keywords per account?

A: Official docs mention no hard cap; empirical observation shows UI degrades beyond 2 000 rows.

Q: Do keyword replies count toward 500 free messages?

A: Yes; they share the same metering as push API calls.

Q: Can I A/B test two replies for the same keyword?

A: Not natively; randomise inside your webhook and log variant ID for analysis.

Q: What happens if regex exceeds 512 bytes?

A: Console refuses to save; split into multiple patterns or handle overflow in middleware.

Q: Are keyword matches case-sensitive?

A: Exact match is case-sensitive after NFKC; regex can enable case-insensitive flag.

Q: Can I use look-ahead or look-behind in regex?

A: POSIX ERE does not support them; use capturing groups and post-process instead.

Q: Does deleting a keyword instantly stop matching?

A: Propagation < 30 s; cache is edge-based, so test with fresh device.

Q: Can operators trigger keywords when testing from desktop?

A: Yes, console “Test” button sends real webhook event—ensure production endpoints can handle it or use separate test channel.

Q: Is regex evaluated in multiline mode?

A: No; dot does not match newline, and ^/$ anchor at start/end of entire string only.

Terminology quick reference

NFKC – Unicode normalization form KC, applied by LINE before exact match.

POSIX ERE – Extended Regular Expression syntax supported by console (max 512 B).

Rich message – JSON payload that can contain images, buttons, carousels.

Webhook – HTTPS endpoint you own that LINE POSTs user events to.

Clova Chat+ – Naver’s GPT-4o-mini endpoint for generative replies.

Keyword hit ratio – fraction of user messages that match any keyword rule.

Fallback – code path executed when no keyword matches.

Quota – 1 000 messages / 1 second burst shared by push & keyword replies.

Legacy string rule – pre-2023 wildcard-only rule, evaluated after regex.

Detailed event log – optional header X-Line-Keyword-Id for observability.

Index fragmentation – UI sluggishness after 2 000+ rows (empirical).

Bot enabled – toggle that must be ON before keyword replies become active.

Provider account – top-level LINE Business ID that can own multiple OA.

Channel – individual LINE Official Account with unique access token.

Codeshare flight – airline partnership itinerary not stored in carrier’s own PNR, hence unreachable by keyword-based menu.

Risk & boundary summary

Do not use keywords when:

  • User input is unbounded natural language with high variance (e.g., product reviews).
  • Message requires real-time personal data from external APIs with > 500 ms latency—total round-trip may exceed 1 s LINE timeout.
  • Regime mandates audit trail for every answer change—keywords lack built-in versioning; you must externalise copy in Git.
  • Input language mixes right-to-left and left-to-right scripts without spaces; regex becomes unmaintainable.

Alternatives: Clova Chat+ with prompt chaining, authenticated webview, or human hand-off. Document the veto criteria in your team handbook to prevent “just one more keyword” creep.

Future trend / 2026 outlook

LINE Labs has previewed on-device intent classification in 15.0.0 beta; if shipped, the client will pre-score text before it reaches your server, potentially eliminating the need for simple regex altogether. To future-proof, externalise all copy, tag rules with semantic intent, and keep your webhook contract minimal. Whichever engine sits upstream—POSIX regex today, on-device ML tomorrow—clean metadata will let you swap the evaluator without rewriting the entire bot.

About Author

line聊天官方团队 - LINE team member, dedicated to providing the best communication experience for users.