> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbit.devotel.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Author a keyword rule in Settings → Keyword Rules (end-to-end walkthrough)

> Create, order, and test keyword-triggered auto-reply, routing, and consent rules in the /settings/keyword-rules console — exact vs contains vs starts-with matching, oldest-first evaluation, the STOP bypass, and a worked HELP auto-reply.

# Settings → Keyword Rules console

Open **Settings → Keyword Rules**. The console at `/settings/keyword-rules` is where you write the rules that fire on inbound message keywords — auto-replies, routing handoffs, and your own opt-in/opt-out vocabulary. This guide walks a rule from creation to firing, in the order an operator hits each decision, and then shows a HELP-keyword auto-reply built end to end.

> [!NOTE]
>
> Keyword rules are a **tenant-owned control**: your organization decides which triggers exist, what your replies say, and which channels they watch. Orbit enforces the matching and the consent gate-write path; the lawfulness of your messaging stays with you. This guide is not legal advice.

***

## 1. What kinds of triggers the console supports

One console at `/settings/keyword-rules` holds every rule the inbound keyword matcher can fire. Each rule pairs a **keyword + match type + channel** with one of five actions:

| Action | What happens on a match |
| - | - |
| **Auto-Reply** | Sends the response text you wrote back to the contact. |
| **Opt-In** (text-to-join) | Records consent so the contact can join marketing lists and journeys. Confirmation text optional. |
| **Opt-Out** | Unsubscribes the contact from further marketing on the channel. Confirmation text optional. |
| **Forward to Agent** | Hands the turn to a deployed AI agent you pick by ID. |
| **Trigger Flow** | Starts an automation flow you pick by ID, with the inbound message as context. |

**Stop keywords vs custom.** Orbit recognizes the standard opt-out/opt-in vocabulary (`STOP`, `START`, and their localized equivalents) **before** your rules run — that built-in classification is not a rule and is not editable here. Your **Opt-In** and **Opt-Out** actions are for *custom* vocabulary (`JOIN`, `QUIT`, brand-specific words) that writes to the same consent records the built-in handler uses. The seeded alias vocabulary is documented on the [Opt-Out Keyword Alias Table](https://docs.orbit.devotel.io/compliance/opt-out-keyword-alias-table.md); the relationship section below explains why a STOP-style custom rule never fires.

The rules table lists keyword, channel, match type, action, an enabled/disabled status, and a **language/market label** for opt-in/opt-out keywords — an informational hint about where that vocabulary is common, never a routing scope. The console is gated to **owner**, **admin**, and **developer** roles.

***

## 2. Add a rule — channel, match mode, and the action

Select **Create rule**. The dialog carries the full rule contract:

1. **Keyword** — the text or pattern to match (`HELP`, `BOOK`, a regex).
2. **Channel** — one of `sms`, `whatsapp`, `rcs`, or `viber`. A rule only fires on inbound messages on its own channel.
3. **Match type** — how the keyword is compared to the message body:
   * **Exact** — the whole message, trimmed, equals the keyword. Case-insensitive. Use for single-word commands.
   * **Contains** — the keyword appears anywhere in the body. Use for phrases inside free text.
   * **Starts With** — the message begins with the keyword. `HELP` matches `HELP me`, not `PLEASE HELP`.
   * **Regex** — a full pattern compiled case-insensitively. Shapes with catastrophic-backtracking risk (nested quantifiers like `(a+)+`, alternation inside a quantifier like `(a|b|c)+`) are rejected when you save — use a single quantifier or a character class like `[abc]+`.
4. **Action** — pick **Auto-Reply** and fill the response body, or route the match to an agent ID / flow ID, or record Opt-In / Opt-Out with an optional confirmation message.

Rules can be saved disabled and flipped on later — stage a change instead of deleting it. The role check runs server-side; viewer and agent seats see a read-only table.

Live status matters before you rely on a rule: a banner at the top of the console tells you whether this account has a **reply-capable number** (a long code or short code that can receive inbound). Alphanumeric sender IDs cannot receive replies, so no reply-capable number means keyword automation is configured but not yet live — the banner links to **Numbers** to fix that.

***

## 3. Matching — how the matcher resolves multiple rules

Rules are evaluated in **creation order, oldest first, and the first match wins**. One inbound message fires at most one rule.

That makes sequencing your job:

* Create **specific** rules before **general** ones. An `exact: YES` rule beats a `contains: YES` rule for a bare `YES`; the contains rule still catches `yes that works`.
* A broad `contains` or a catch-all regex created early shadows every more specific rule created after it. If a fallback is swallowing keyword traffic, it is older than it should be.
* To re-sequence, delete the broad rule and re-create it — the new rule becomes the newest and evaluates last. A common catch-all is a regex `.*` created after every specific rule.

The list view returns **newest first**, so read it bottom-up to see the true evaluation order. Matching folds case but never accents — `CAFE` and `CAFÉ` are different keywords.

***

## 4. The opt-out relationship — why STOP bypasses your rules

The inbound pipeline classifies each message before it consults your rules:

1. **Built-in consent handling.** The standard opt-out/opt-in vocabulary (multilingual `STOP` / `START` and equivalents) is processed as an opt-out/opt-in directly. Your rules are never asked about those words — a custom `STOP` Auto-Reply rule will never fire, and `STOP` aliases can never be removed by pruning the seeded table.
2. **Keyword rules, oldest first.** The first match executes its action. A custom **Opt-Out** or **Opt-In** rule writes to the same consent and suppression records the built-in handler updates, so your `QUIT` keyword blocks future sends exactly like `STOP` does.
3. **No match → normal routing.** The message continues to the deployed agent for that channel if one exists, otherwise it opens the conversation in the **Inbox**.

When any opt-out fires — built-in or your own — the suppression it writes is scoped to `all`: a `STOP` on an SMS number fences that contact on SMS, WhatsApp, and RCS at once. The propagation happens at the suppression record, not in the alias table. Auto-replies still pass the outbound gate chain (suppression list → duplicate-content guard → frequency cap → dispatch), so a contact who has opted out is never reopened by a keyword reply.

***

## 5. Worked example — a HELP auto-reply tied to compliance

Regulatory senders owe the contact who texts `HELP` the support-handling info back at once. Build it like this:

1. Open **Create rule**.
2. **Keyword:** `HELP` — **Channel:** `sms` — **Match type:** Exact.
3. **Action:** Auto-Reply.
4. **Response text:** `CompanyName support: reply STOP to opt out, or contact us at support@yourcompany.example / +1 (415) 555-0101.`

The exact match confines this to a bare `HELP` in any letter case, which is the carrier-convention shape. Because `HELP` is not in the built-in opt-out vocabulary, the rule fires rather than being bypassed. For ratings-sensitive markets add per-language variants (`AJUDA`, `AYUDA`) as separate rules — the language label next to each keyword in the table is the hint for which market it serves.

To prove the rule fires:

1. **Create the rule** on a channel where you have a reply-capable number.
2. **Send the inbound** — text `HELP` from a handset to that number.
3. **Confirm both directions** — the inbound and the fired reply are ordinary messages. Check the conversation in the **Inbox** and the outbound row in the [Delivery log](https://docs.orbit.devotel.io/guides/delivery-log.md). If only the inbound exists, confirm the rule is enabled and no earlier, broader rule claims the keyword first.

***

## 6. Edge cases — collisions and time-of-day logic

* **Cross-channel collisions.** A rule only fires on its stored channel, but the same keyword on two channels means two rules to maintain. An SMS `JOIN` and a WhatsApp `JOIN` are independent; delete one and the other still stands. Check both when a contact says a keyword "didn't work" on one channel.
* **Same channel, overlapping patterns.** A `contains: INFO` rule shadows an `exact: INFO` rule created after it — the ordering rules from section 3 decide, every time.
* **Time-of-day logic.** Keyword rules do not carry scheduling. If the reply should vary by hour — an after-hours auto-reply, a quiet-hours-safe response — attach **Trigger Flow** instead of Auto-Reply and branch on time inside the flow; the flow's history shows the keyword that started it.
* **Accents and invisible characters.** Matching folds case only. `CAFÉ` ≠ `CAFE`, and a carrier-injected zero-width character inside the body defeats an Exact match. If a rule that "should match" does not, switch to Contains or a regex like `caf[eé]`.
* **Emoji are literal.** An exact rule on `👍` matches a message whose entire body is that emoji. For emoji inside sentences, use Contains.

***

## 7. Audit trail and changing behavior

Every console write leaves three kinds of evidence:

* **Org audit log.** Create, update, and delete on keyword rules each emit an entry under **Settings → Audit Log** with the actor, timestamp, and before/after values — the answer to "who changed what the HELP reply says".
* **Consent history.** A custom Opt-In or Opt-Out rule's firings record on the contact's consent timeline alongside the built-in STOP/START events — pair it with the suppression export for an external audit.
* **Message record.** A fired Auto-Reply leaves the inbound and outbound pair in the conversation thread and Delivery log; a Trigger Flow firing leaves a run in the flow's history. There is no separate rule-hit counter — these records *are* the firing log.

When a rule must change behavior, prefer disable → edit → re-enable over delete-and-recreate so its position in the oldest-first order survives. Reserve delete-and-recreate for deliberate re-sequencing.

***

## See also

* [Auto-reply rules](https://docs.orbit.devotel.io/guides/keyword-auto-reply-rules.md) — the keyword rule surface with the API request/response shapes.
* [Opt-out keyword alias table](https://docs.orbit.devotel.io/compliance/opt-out-keyword-alias-table.md) — the seeded STOP/START vocabulary and how aliases propagate.
* [Opt-out & suppression lists](https://docs.orbit.devotel.io/compliance/opt-out-suppression.md) — the suppression ledger keyword opt-outs write to.
* [Keyword rules recipes](https://docs.orbit.devotel.io/guides/keyword-rules-recipes.md) — common rule-set patterns.
* [SMS keyword → agent escalation](https://docs.orbit.devotel.io/guides/sms-keyword-agent-escalation.md) — routing keywords to deployed AI agents.
* [Delivery log](https://docs.orbit.devotel.io/guides/delivery-log.md) — where fired replies show up.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.