|
| 1 | +# 06 · Empty state with suggestions |
| 2 | + |
| 3 | +Replace the default "Start a conversation" placeholder with an onboarding panel — agent avatar, headline, sub-line, and clickable suggestion chips. Click a chip and it sends as a normal user message; the whole block disappears the moment the conversation begins. |
| 4 | + |
| 5 | +## Snippet |
| 6 | + |
| 7 | +```html |
| 8 | +<script |
| 9 | + src="https://bridle.cleanslice.org/sdk/latest.js" |
| 10 | + data-agent-id="agent-abc-123" |
| 11 | + data-token="<jwt>" |
| 12 | + data-empty-avatar="/avatars/support-agent.png" |
| 13 | + data-empty-title="How can I help?" |
| 14 | + data-empty-subtitle="I can compare plans, schedule a demo, or open a ticket." |
| 15 | + data-suggestions="Compare plans|Book a demo|Open a support ticket" |
| 16 | +></script> |
| 17 | +``` |
| 18 | + |
| 19 | +Programmatic form: |
| 20 | + |
| 21 | +```ts |
| 22 | +Bridle.init({ |
| 23 | + apiUrl, agentId, token, |
| 24 | + emptyAvatar: '/avatars/support-agent.png', |
| 25 | + emptyTitle: 'How can I help?', |
| 26 | + emptySubtitle: 'I can compare plans, schedule a demo, or open a ticket.', |
| 27 | + suggestions: ['Compare plans', 'Book a demo', 'Open a support ticket'], |
| 28 | +}) |
| 29 | +``` |
| 30 | + |
| 31 | +## Live demo |
| 32 | + |
| 33 | +<BridleEmbed |
| 34 | + title="Welcome desk" |
| 35 | + empty-avatar="https://bridle.cleanslice.org/logo.svg" |
| 36 | + empty-title="How can I help?" |
| 37 | + empty-subtitle="Ask me anything about Bridle, or pick one of the prompts below." |
| 38 | + :suggestions="['How do I embed Bridle?', 'How does theming work?', 'What does data-prompt do?']" |
| 39 | +/> |
| 40 | + |
| 41 | +Click a chip — it sends as a user message, the panel switches to the live conversation, and the empty state stays out of the way. |
| 42 | + |
| 43 | +## Behavior |
| 44 | + |
| 45 | +| Condition | Result | |
| 46 | +|-----------|--------| |
| 47 | +| `messages.length === 0` and not typing | Empty state visible | |
| 48 | +| Agent starts replying (`isTyping`) | Empty state hidden (chips don't flash next to a streaming reply) | |
| 49 | +| User sends anything — text, image, or a chip | Empty state hidden — conversation begins | |
| 50 | +| WebSocket not open | Chips disabled — visitors don't fire into a closed connection | |
| 51 | +| All four fields unset | Legacy single-line "Start a conversation" copy | |
| 52 | + |
| 53 | +## Combine with `greeting` and `prompt` |
| 54 | + |
| 55 | +| Field | Job | |
| 56 | +|-------|-----| |
| 57 | +| `emptyAvatar` / `emptyTitle` / `emptySubtitle` / `suggestions` | What the **visitor** sees in an empty chat. Static content. | |
| 58 | +| `greeting` / `greetingDelay` | What the **agent** "says" once typing dots clear. Static, one-shot per session. | |
| 59 | +| `prompt` | What the **agent runtime** receives at handshake. Hidden from the visitor. Drives the agent's reasoning. | |
| 60 | + |
| 61 | +Used together, they tell a coherent story to both sides: |
| 62 | + |
| 63 | +```ts |
| 64 | +Bridle.init({ |
| 65 | + apiUrl, agentId, token, |
| 66 | + |
| 67 | + // Visitor sees: |
| 68 | + emptyAvatar: '/avatars/support-agent.png', |
| 69 | + emptyTitle: 'How can I help?', |
| 70 | + emptySubtitle: 'Ask anything about your subscription.', |
| 71 | + suggestions: ['Upgrade my plan', 'See past invoices', 'Cancel my account'], |
| 72 | + |
| 73 | + // Then the agent "introduces itself" once they open the panel: |
| 74 | + greeting: "Hi! I'm here for your subscription questions. Heads-up: cancellations are processed at the end of the billing cycle.", |
| 75 | + greetingDelay: 2000, |
| 76 | + |
| 77 | + // Background context for the runtime (not shown to visitor): |
| 78 | + prompt: 'Section: account/billing · Plan: pro · Renews: 2026-07-12', |
| 79 | +}) |
| 80 | +``` |
| 81 | + |
| 82 | +## Tips |
| 83 | + |
| 84 | +- **Keep chip text short** — chip text becomes the entire user message. "Pricing?" not "Could you walk me through your pricing model?". Long chips become long user turns in the transcript. |
| 85 | +- **3–5 chips max** — more than that and the empty state grows tall enough to push the input below the fold on mobile. |
| 86 | +- **Avatar at ≥56px** — the panel renders it as a 56×56 circle. Smaller sources scale up and look fuzzy. |
| 87 | +- **Style the chip itself** via [`customCss`](/embed/theming#overriding-internal-classes) targeting `.bridle__suggestion` — see the recipe in [03 · Styles](/examples/styles#styling-image-attachments) (same approach). |
| 88 | + |
| 89 | +## Related |
| 90 | + |
| 91 | +- [Welcome message](/examples/welcome) — what the agent says. |
| 92 | +- [Page Context](/embed/context) — what the agent runtime knows. |
| 93 | +- [Script Tag → Empty state](/embed/script-tag#empty-state) — full reference. |
0 commit comments