On this page

Pre-chat

Lời mời nhận email và biên nhận dưới câu trả lời gốc.

Copy page as MarkdownRead Markdown ↗

Key rules

  • Element prototype là chuẩn để chatty-ui port theo.
  • Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
On this page

Use when / Avoid

Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.

Use instead

Component Use when
PreChatPrompt Implementation React đang chạy.
Element prototype Consumer chuyển sang custom element.

Live preview

Standard

Standard
LightDarkDesktopMobile

Element prototype với token trung tính.

Show code
chatty-pre-chat.element.jsWrap code linesCopy
<chatty-pre-chat skippable></chatty-pre-chat> 

Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A. Surface chưa có React tương ứng ghi Not available bên dưới.

Standard
LightDarkDesktopMobile

Saved-email receipt là state riêng, không đặt cạnh invitation.

Show code
chatty-pre-chat.element.jsWrap code linesCopy
<chatty-pre-chat email="customer@example.com"></chatty-pre-chat>

Element

Element Module
chatty-pre-chat @avada/chatty-ui/elements/pre-chat.js

API

Kind Name Type Default Description
attribute email string '' Saved email; a receipt replaces the invitation when present.
attribute label string 'Get replies by email' Translated invitation.
attribute skip-label string 'Chat anonymously' Translated anonymous option.
attribute confirmation string 'Replies will also go to {{email}}' Translated receipt template; {{email}} marks the saved email.
attribute skippable boolean false Shows the anonymous option.
event chatty-open CustomEvent<{}> Not available Opens contact collection.
event chatty-skip CustomEvent<{}> Not available Requests anonymous chat.
event click MouseEvent Not available Native invitation button click.
part base Not available Not available Contact invitation.

Classic

Current (React), being replaced
LightDarkDesktopMobile

Component React thật; dữ liệu fixture, không gửi request.

Show code
markdown.jsxWrap code linesCopy
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';

const message = {
  id: 'guide-reply',
  senderType: 'bot',
  text: 'The **canvas tote** is lightweight.',
  status: 'sent',
  createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};

export function PreChat() {
  return <PreChatPrompt t={(text) => text} onOpen={() => {}} onSkip={() => {}} />;
}

Token values dưới đây là fallback cục bộ; theme của caller có thể override.

Import / element

Component / element Import / file Scope root
PreChatPrompt @avada/chatty-ui/canonical/PreChatPrompt.jsx PreChatPrompt

Anatomy

Part Element
1 PreChatPrompt

Placement / order

Context Order
Conversation Caller supplies surrounding content

Props

Prop Type Values Default Notes
email See source Caller supplied See source Saved contact email

Sizes

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Invitation button min-height 44px 12px 6px 999px button-label 44px Wrap with available width

Tokens

Part Token Light Dark
Invitation ink --chatty-contact-fg Fallback #1f1f1f Fallback #1f1f1f
Invitation fill --chatty-contact-chip Fallback #fff Fallback #fff

States

State Trigger Visual change (values) ARIA/attribute
Invitation No saved email Email and anonymous actions Native buttons
Saved Email exists Saved email receipt Not available

Behaviour

Interaction Result
Open / Skip Calls onOpen or onSkip

Copy

String i18n key Where
Caller translated Not available PreChatPrompt

Source

File Evidence
Owning React implementation.

AI Mode

Current (React), being replaced
LightDarkDesktopMobile

Component React thật; dữ liệu fixture, không gửi request.

Show code
markdown.jsxWrap code linesCopy
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';

const message = {
  id: 'guide-reply',
  senderType: 'bot',
  text: 'The **canvas tote** is lightweight.',
  status: 'sent',
  createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};

export function PreChat() {
  return <PreChatPrompt t={(text) => text} onOpen={() => {}} onSkip={() => {}} />;
}

Token values dưới đây là fallback cục bộ; theme của caller có thể override.

Import / element

Component / element Import / file Scope root
PreChatPrompt @avada/chatty-ui/canonical/PreChatPrompt.jsx PreChatPrompt

Anatomy

Part Element
1 PreChatPrompt

Placement / order

Context Order
Conversation Caller supplies surrounding content

Props

Prop Type Values Default Notes
email See source Caller supplied See source Saved contact email

Sizes

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Invitation button min-height 44px 12px 6px 999px button-label 44px Wrap with available width

Tokens

Part Token Light Dark
Invitation ink --chatty-contact-fg Fallback #1f1f1f Fallback #1f1f1f
Invitation fill --chatty-contact-chip Fallback #fff Fallback #fff

States

State Trigger Visual change (values) ARIA/attribute
Invitation No saved email Email and anonymous actions Native buttons
Saved Email exists Saved email receipt Not available

Behaviour

Interaction Result
Open / Skip Calls onOpen or onSkip

Copy

String i18n key Where
Caller translated Not available PreChatPrompt

Source

File Evidence
Owning React implementation.

Do / Don't

Accessibility

Surface Role / name Keyboard / focus Live region Contrast pair / ratio
Classic Native content semantics Tab to action; Enter or Space activates Not available See neutral token preview
AI Mode Native content semantics Tab to action; Enter or Space activates Not available See neutral token preview