# Message Preview

> A message to a customer, or a post, exactly as it goes out: the channel (name and icon; register a brand icon for the logo), the recipient masked (maskRecipient()), the sending account, the reply window (open, closing, closed) for channels 

Component · AI · Pro kit · [Live page](https://ui.twentyfirst.media/pro/components/MessagePreview/)

A message to a customer, or a post, exactly as it goes out: the channel (name and icon; register a brand icon for the logo), the recipient masked (`maskRecipient()`), the sending account, the reply window (open, closing, closed) for channels that only allow free text for a while after the customer's last message, the last messages of the conversation for context, and the text or a pre-approved template with its category and parameters. Posts show their image or video (`media`). Ends with "Goes out once after A".

## Example

```tsx
import { ApprovalCard, MessagePreview, maskRecipient } from "@twentyfirstmedia/pro";

export default function Preview() {
  return (
    <div className="tf-col" style={{ gap: 16 }}>
      <ApprovalCard
        agent="Atlas"
        project="Support"
        family="comms"
        age="6 min"
        title="Reply to a customer on WhatsApp"
        text="Atlas answers in the open reply window; replies need your OK."
      >
        <MessagePreview
          channel="WhatsApp"
          recipient={`${maskRecipient("Erika Lindqvist")} (${maskRecipient("+46 70 123 45 678")})`}
          sender="+49 30 1234 5000"
          window={{ state: "closing", until: "2026-04-16T18:20:00" }}
          context={[
            {
              from: "in",
              at: "2026-04-15T18:20:00",
              text: "Hi, my order 2041 still says processing.",
            },
            {
              from: "out",
              at: "2026-04-15T18:24:00",
              text: "Thanks, I will check with the warehouse.",
            },
            { from: "in", at: "2026-04-16T09:02:00", text: "Any news? I need it by Friday." },
          ]}
          text={
            "Good news: order 2041 left the warehouse this morning and arrives Thursday.\nTracking: NW-55102."
          }
        />
      </ApprovalCard>
      <ApprovalCard
        agent="Social"
        project="Marketing"
        family="marketing"
        age="12 min"
        title="Publish a post on Instagram"
        compact
      >
        <MessagePreview
          channel="Instagram"
          sender="@northwind.studio"
          media={{
            kind: "image",
            src: "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 4'><rect width='4' height='4' opacity='.12'/><circle cx='2' cy='2' r='1' opacity='.2'/></svg>",
            alt: "The new spring collection on a light blue background",
          }}
          text="Spring is here. The new collection is live in the shop."
        />
      </ApprovalCard>
      <div className="tf-panel">
        <MessagePreview
          channel="WhatsApp"
          recipient="Noah B. (…7731)"
          window={{ state: "closed", until: "2026-04-14T11:00:00" }}
          template={{
            name: "order_update",
            language: "en",
            category: "Utility",
            params: ["Noah", "2058", "Thursday"],
          }}
        />
      </div>
    </div>
  );
}
```

## Props

### MessagePreview

| Prop | Type | Notes |
| --- | --- | --- |
| `title?` | `ReactNode` | One line: "Reply to Erika M. on WhatsApp". |
| `channel` | `string` | The channel's name ("WhatsApp", "Instagram", "SMS"). |
| `channelIcon?` | `IconName` | The channel's icon (default `send`); register brand icons to show the logo. |
| `recipient?` | `string` | Already masked, or pass it through `maskRecipient`. |
| `sender?` | `string` | The account it is sent from. |
| `window?` | `{ state: "open" \| "closing" \| "closed"; until?: Date \| string \| number }` | Messaging windows (e.g. 24 hours after the customer's last message). |
| `context?` | `MessagePreviewContext[]` | The last messages, oldest first. |
| `text?` | `string` | Exactly what goes out. |
| `template?` | `{ name: string; category?: string; language?: string; params?: string[] }` | A pre-approved template instead of free text. |
| `media?` | `{ kind: "image" \| "video"; src: string; alt?: string; poster?: string }` | The image or video of a post. |
| `warnings?` | `ReactNode[]` |  |
| `facts?` | `KeyValueItem[]` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### ApprovalCard

| Prop | Type | Notes |
| --- | --- | --- |
| `title` | `ReactNode` | Required |
| `text?` | `ReactNode` |  |
| `children?` | `ReactNode` |  |
| `agent?` | `string` |  |
| `project?` | `string` |  |
| `family?` | `RiskFamily` |  |
| `familyLabel?` | `string` |  |
| `age?` | `string` |  |
| `escalation?` | `ReactNode` |  |
| `trace?` | `ReactNode` |  |
| `note?` | `ReactNode` |  |
| `heading?` | `string` |  |
| `options?` | `ApprovalOption[]` |  |
| `approveLabel?` | `string` |  |
| `onDecide?` | `(key: ApprovalKey, text?: string) => void \| Promise<unknown>` | Called with the answer (and the text of B or D). Return a Promise to keep the card busy until it settles: the answer's button spins and every answer is disabled; a rejection shows an error (a rejected string is shown as is) and keeps the card open. Once it resolves, a card without a `decision` prop collapses to its one-line record; with a plain callback, set `decision` yourself. |
| `decision?` | `ApprovalDecision \| null` | The decision record: shown as one line instead of the card; `null` keeps the card open. |
| `compact?` | `boolean` | Side panels: tighter, the answers in a row, the payload folded behind "Show what runs" (one click, never a summary). |
| `stepUp?` | `boolean` | Money, legal and infrastructure decisions: A and B (the answers that run something) need a fresh passkey. They show "Needs your passkey"; while `onDecide` is pending the pressed answer says "Confirm with passkey". Do the WebAuthn step-up in `onDecide` and reject if it fails. |
| `busy?` | `ApprovalKey \| null` | The answer being sent, when you track it yourself (controlled busy state). |
| `error?` | `ReactNode` | An error to show above the answers (controlled); a rejected `onDecide` shows one by itself. |
| `screen?` | `boolean` | Fills its container, e.g. a deep link on a phone: the content scrolls and A–D stay at the bottom, full width, in thumb reach (with the safe area). |
| `href?` | `string` | Makes the title a link to the full approval (with `linkAs` for a router's link). |
| `linkAs?` | `ElementType` |  |
| `onApprove?` | `() => void` |  |
| `onDeny?` | `() => void` |  |
| `onEdit?` | `(text: string) => void` |  |
| `state?` | `"approved" \| "denied"` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
