<!-- https://unlockos.io/manual/notification-workflow -->

# Notification Workflow Help

## Overview

**Notification Workflows** let your facility manage automated notifications tied to reservations, for both guests and facility owners. Settings like "send a reminder 24 hours before check-in" or "notify the owner when a reservation needs approval" are expressed as a combination of an **anchor event** (when it happens), an **offset** (how many minutes/hours before or after), and a **channel** (how it's delivered).

Open it from the sidebar via "🔔 Notification Workflows" (`/notifications`).

---

## The 4 tabs

| Tab | Description |
|---|---|
| Workflows | List of notifications, ON/OFF toggle, edit, add custom notifications |
| Messages | Create, edit and delete named notification content (subject, email body, SMS text, voice script) |
| History | Delivery status (pending / dispatching / sent / failed / cancelled) for the past 7 days through the next 1 day, plus monthly metered totals |
| Channels | Connection-status cards for LINE / Email / SMS / Voice / Speaker with links to each channel's settings |

---

## Workflows tab

### Standard (canonical) workflows

Every facility starts with these seeded as **disabled (enabled=false)**. Each facility owner turns them on individually. Standard workflows cannot be deleted, but their anchor, offset, and channel can be edited (the workflow key itself is read-only).

**Guest-facing (4 workflows)**

| Workflow | When | Purpose |
|---|---|---|
| Pre-reservation reminder | 24 hours before check-in | Reminds the guest of the upcoming stay |
| Check-in guide | 10 minutes before check-in | Explains how to check in |
| Cleanup request | 5 minutes before check-out | Asks the guest to tidy up before leaving |
| Post-reservation thanks | At check-out | Thank-you message |

**Facility-owner-facing (6 workflows, details below)**

- New reservation created
- Reservation awaiting approval
- Approval still pending after 12 hours (reminder)
- Payment completed
- Reservation cancelled
- Reservation extended

### Recipient (how to route a notification to the owner)

In the edit modal, choosing **"Facility Owner"** in the **Recipient** dropdown sends that workflow to the facility's owner instead of the guest. The workflow list shows a "Facility Owner" badge on any workflow configured this way.

> **Standard workflows cannot change their recipient** (the dropdown is disabled). The 6 standard facility-owner workflows are always locked to "Facility Owner." You can only choose the recipient when creating a new custom workflow.

### Who actually receives it (recipient resolution)

Owner-audience notifications fan out to **everyone** resolved in this order:

1. All **Facility Owners** for that facility
2. If there are no Facility Owners, all **Organization Owners** for the parent organization
3. If neither exists, the delivery is recorded as a failure (visible on the History tab)

The legacy per-facility "manager" assignment (`facility_manager_id`) is not used. Recipients are resolved with the same role model used for login permissions.

### Channel (owner notifications are Email-only for now)

Even if the channel is left as "Auto" in the edit modal, **facility-owner notifications currently always arrive by Email** (an HTML email sent via Resend). Guest-facing "Auto" notifications will route to LINE when the guest is LINE-bound, but owner recipient resolution does not look up a LINE user ID — so even if the owner personally has LINE connected, these notifications will not arrive via LINE (this is planned for a future update).

### Event anchors

Guest-facing workflows fire relative to a **time** (e.g., "N minutes before check-in"). Facility-owner workflows instead fire relative to **something that happened** to the reservation.

| Anchor | Fires when |
|---|---|
| New reservation | The reservation is created |
| Approval pending | An approval-required reservation enters the pending-approval state |
| Payment completed | The guest pays and the reservation is confirmed (see note below) |
| Cancellation | The reservation is cancelled |
| Extension | The reservation's end time is pushed later |

> **"Payment completed" only fires for reservations that were actually paid.** It does not fire for reservations confirmed without payment — manual confirmation, free plans, membership plans, and similar cases are excluded. Pay-at-check-in (postpaid) reservations are also out of scope for this notification: at the moment the reservation becomes confirmed it is still unpaid, so this event never fires for them.

### Auto-cancel for the approval reminder

The "approval still pending after 12 hours" reminder is scheduled to arrive 12 hours after a reservation enters approval-pending status. If the owner approves or declines it before then, the reminder is automatically cancelled — no unnecessary follow-up email is sent.

### Workflow name

The list, the edit modal and the History tab all show the **workflow name**. Standard workflows come with a name already set, and you can rename them to match how your facility talks about them (for example "Check-in guide" → "Entry instructions").

The internal identifier is never shown. It is assigned automatically when a workflow is created and never changes.

### Custom workflows

Beyond the standard set, you can add facility-specific notifications. You can freely choose the name, anchor event, offset, channel, recipient and message. Custom workflows can also be deleted from the list (deleting one keeps its delivery history).

### Linking a message

The **Message** dropdown in the edit modal picks the content this workflow sends. If you have not created any messages yet it reads "No messages available" and offers a link to the Messages tab.

**A workflow with no message cannot be enabled.** Enabling one without content would mark notifications as sent while the recipient receives nothing.

---

## Messages tab

Messages are listed as cards. Each card shows the message name, the workflow it is linked to (or "Unassigned"), an excerpt of the subject, and which languages have content. The pencil icon edits it and the no-entry icon deletes it.

Use **+ New message** to create one. The edit modal has:

| Field | Description |
|---|---|
| Message name | The name shown in the list and in the workflow dropdown (required) |
| Workflow | The workflow to link it to. You can also save it as "Unassigned" and link it later |
| Subject / Body / SMS text / Voice script | Per-channel content, entered per language (Japanese / English) |

The preview shows the content with sample variables expanded.

### One message, one workflow

Messages and workflows are linked **one-to-one**. You can set the link from either screen:

- the **Message** dropdown in the workflow edit modal
- the **Workflow** dropdown in the message edit modal

Choosing a message that already belongs to another workflow opens a **confirmation modal**. If you continue, the original workflow is left with no message and is disabled automatically — no enabled workflow is ever left without content.

Deleting a message does the same thing: the workflow it was linked to ends up unassigned and disabled.

### Available variables

| Variable | Content |
|---|---|
| `{{guest_name}}` | The guest's name |
| `{{start_time}}` | Reservation start time (formatted in the facility's timezone) |
| `{{end_time}}` | Reservation end time (formatted in the facility's timezone) |
| `{{facility_name}}` | Facility name |
| `{{room_name}}` | Room name |
| `{{approval_url}}` | Link to the approval screen (**only used in approval-related owner notifications**) |

`{{approval_url}}` only appears in the two standard "Reservation awaiting approval" and "Approval reminder" notifications. There's no need to include it in guest-facing workflows or other owner workflows.

---

## History tab

Shows delivery status for the past 7 days through the next 1 day: status (pending / dispatching / sent / failed / cancelled), scheduled time, workflow name, channel, attempt count, and cost. Failed rows show an error code with a hint. The current month's metered usage total (SMS sent, speaker plays, etc.) is summarized at the top.

---

## Channels tab

The channels are shown as cards, each linking to its own settings page.

| Channel | Settings page | Cost |
|---|---|---|
| LINE | LINE connection settings | Free |
| Email | Basic settings (confirm sender address) | Free |
| SMS | Twilio integration settings | ¥25/segment (billed directly to the customer under a BYO contract) |
| Voice | Twilio integration settings | ¥60/minute (BYO contract available) |
| Speaker | Speaker channel management (devices and announcement content) | ¥3/play |
| Webhook | [Webhook Notification Channel](webhook-channel.md) | Free |

> **When** a speaker plays is configured on the Workflows tab of this page. The speaker channel management screen only covers registering devices and managing announcement content (the audio that gets read out).

> **The Webhook card only appears when the `notification_webhook_channel` feature flag is enabled for your organization.** Unlike LINE, Email, SMS, Voice, and Speaker, Webhook doesn't notify a person — it feeds events into an external system. See [Webhook Notification Channel](webhook-channel.md) for details.

---

## FAQ

### Q: Is this the same as the "admin notification settings" on the LINE connection page?

A: **No, they are separate features.** The "admin notification settings" on the LINE connection page is the existing feature that notifies the admin via LINE on check-in / check-out / payment failure. The "Facility Owner" workflows here are a newer mechanism scoped to **reservation events** — new reservation, approval pending, payment completed, cancellation, extension — and currently deliver by Email only. Enabling both does not cause duplicate notifications, since they cover different events.

### Q: Can I change the recipient of a standard facility-owner workflow to "Guest"?

A: No. For standard (canonical) workflows, the recipient/anchor combination is part of the workflow's definition and is locked. If you want a similar guest-facing notification, create a new custom workflow instead.

### Q: What happens if a facility has no owner at all?

A: If there is neither a Facility Owner nor an Organization Owner, delivery fails and is recorded as a failure on the History tab. Contact support to have an owner assigned first.

### Q: Is there any way to stop the approval reminder besides disabling the workflow?

A: Approving or declining the reservation automatically cancels the pending reminder — no manual action needed. To stop future reminders for all reservations, toggle the workflow OFF in the workflow list.

### Q: Where do I configure the Webhook channel?

A: Register the endpoint (destination URL and signing secret) from the Webhook card on the Channels tab. Which event triggers a send is configured on the Workflows tab by setting a workflow's channel to "Webhook." See [Webhook Notification Channel](webhook-channel.md) for details.

### Q: Where do I set the time for a speaker announcement?

A: On the **Workflows tab** of this page. Choose "+ New workflow", set the channel to "Speaker", then pick the target device and announcement content. The steps are exactly the same as for LINE or Email. The speaker channel management screen covers only two things: device registration and announcement content.

### Q: If a reservation is cancelled, will the scheduled announcement still play?

A: No. Cancelling a reservation automatically cancels any undelivered speaker notifications tied to it. The one exception is cancelling within the very short window right after dispatch — audio that already reached the speaker itself may still play once.

---

## Related pages

- [LINE Connection](line-connection.md)
- [LINE Notifications](line-notifications.md)
- [Webhook Notification Channel](webhook-channel.md)
- [Speaker Notification Channel](space-speaker.md)
- [Basic Settings](base-settings.md)
- [Booking Management](booking.md)
- [Billing](billing.md)
