@enjoys/react-chatbot-plugin 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -4
- package/dist/index.cjs +17 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +384 -5
- package/dist/index.mjs +17 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,14 +12,64 @@ export declare interface ActionContext {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Agent Plugin — enables live human agent takeover of the chat
|
|
16
|
+
*/
|
|
17
|
+
export declare function agentPlugin(options: {
|
|
18
|
+
socketUrl?: string;
|
|
19
|
+
onAgentConnect?: (ctx: PluginContext) => void;
|
|
20
|
+
onAgentDisconnect?: (ctx: PluginContext) => void;
|
|
21
|
+
onAgentMessage?: (text: string, ctx: PluginContext) => void;
|
|
22
|
+
connectMessage?: string;
|
|
23
|
+
disconnectMessage?: string;
|
|
24
|
+
}): ChatPlugin;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* AI Plugin — generates bot responses using external AI providers (OpenAI, Anthropic, custom)
|
|
28
|
+
*/
|
|
29
|
+
export declare function aiPlugin(options: {
|
|
30
|
+
provider?: 'openai' | 'anthropic' | 'custom';
|
|
31
|
+
endpoint?: string;
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
model?: string;
|
|
34
|
+
systemPrompt?: string;
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
shouldRespond?: (text: string) => boolean;
|
|
37
|
+
parseResponse?: (response: unknown) => string;
|
|
38
|
+
timeout?: number;
|
|
39
|
+
}): ChatPlugin;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Analytics Plugin — tracks sessions, messages, forms, timing, and step progression
|
|
16
43
|
*/
|
|
17
44
|
export declare function analyticsPlugin(options?: {
|
|
18
45
|
onTrack?: (event: string, data?: unknown) => void;
|
|
46
|
+
sessionId?: string;
|
|
19
47
|
}): ChatPlugin;
|
|
20
48
|
|
|
21
49
|
export declare const AttachmentIcon: default_2.FC<IconProps>;
|
|
22
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Auth Plugin — manages user authentication and identity
|
|
53
|
+
*/
|
|
54
|
+
export declare function authPlugin(options: {
|
|
55
|
+
type?: 'jwt' | 'session' | 'custom';
|
|
56
|
+
tokenKey?: string;
|
|
57
|
+
storage?: 'local' | 'session';
|
|
58
|
+
onAuth?: (token: string, ctx: PluginContext) => void;
|
|
59
|
+
onAuthExpired?: (ctx: PluginContext) => void;
|
|
60
|
+
validateToken?: (token: string) => boolean;
|
|
61
|
+
}): ChatPlugin;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Auto Reply Plugin — sends automated replies when user is inactive
|
|
65
|
+
*/
|
|
66
|
+
export declare function autoReplyPlugin(options?: {
|
|
67
|
+
timeout?: number;
|
|
68
|
+
message?: string;
|
|
69
|
+
maxReplies?: number;
|
|
70
|
+
onlyWhenOpen?: boolean;
|
|
71
|
+
}): ChatPlugin;
|
|
72
|
+
|
|
23
73
|
export declare const Branding: default_2.FC<BrandingProps>;
|
|
24
74
|
|
|
25
75
|
export declare interface BrandingConfig {
|
|
@@ -4376,6 +4426,22 @@ export declare function buildStyles(theme: Required<ChatTheme>, overrides?: Chat
|
|
|
4376
4426
|
};
|
|
4377
4427
|
};
|
|
4378
4428
|
|
|
4429
|
+
declare interface CampaignConfig {
|
|
4430
|
+
trigger: TriggerType;
|
|
4431
|
+
message: string;
|
|
4432
|
+
delay?: number;
|
|
4433
|
+
maxShows?: number;
|
|
4434
|
+
flowStep?: string;
|
|
4435
|
+
}
|
|
4436
|
+
|
|
4437
|
+
/**
|
|
4438
|
+
* Campaign Plugin — starts flows or shows messages based on user behavior triggers
|
|
4439
|
+
*/
|
|
4440
|
+
export declare function campaignPlugin(options: {
|
|
4441
|
+
campaigns: CampaignConfig[];
|
|
4442
|
+
onTrigger?: (campaign: CampaignConfig, ctx: PluginContext) => void;
|
|
4443
|
+
}): ChatPlugin;
|
|
4444
|
+
|
|
4379
4445
|
declare type ChatAction = {
|
|
4380
4446
|
type: 'TOGGLE_OPEN';
|
|
4381
4447
|
} | {
|
|
@@ -4448,6 +4514,14 @@ export declare interface ChatBotProps {
|
|
|
4448
4514
|
actionHandlers?: Record<string, (data: Record<string, unknown>, ctx: ActionContext) => Promise<FlowActionResult>>;
|
|
4449
4515
|
/** Override built-in form field renderers per field type. Each renderer receives strongly-typed props + the default element. */
|
|
4450
4516
|
renderFormField?: FormFieldRenderMap;
|
|
4517
|
+
/** Fallback message when user types text with no active flow or unmatched input */
|
|
4518
|
+
fallbackMessage?: string | ((text: string) => string | null);
|
|
4519
|
+
/** Keyword routes — match user text to responses or flow steps */
|
|
4520
|
+
keywords?: KeywordRoute[];
|
|
4521
|
+
/** Convenience: auto-respond to common greetings (hello, hi, hey, etc.) */
|
|
4522
|
+
greetingResponse?: string;
|
|
4523
|
+
/** Typing delay in ms before bot sends keyword/fallback replies (default: 0) */
|
|
4524
|
+
typingDelay?: number;
|
|
4451
4525
|
}
|
|
4452
4526
|
|
|
4453
4527
|
export declare const ChatBubbleIcon: default_2.FC<IconProps>;
|
|
@@ -4465,6 +4539,10 @@ export declare interface ChatCallbacks {
|
|
|
4465
4539
|
onFlowEnd?: (collectedData: Record<string, unknown>) => void;
|
|
4466
4540
|
onError?: (error: Error) => void;
|
|
4467
4541
|
onEvent?: (event: string, payload?: unknown) => void;
|
|
4542
|
+
/** Called when user types text the bot couldn't handle */
|
|
4543
|
+
onUnhandledMessage?: (text: string, context: {
|
|
4544
|
+
currentStepId: string | null;
|
|
4545
|
+
}) => void;
|
|
4468
4546
|
}
|
|
4469
4547
|
|
|
4470
4548
|
export declare const ChatContext: Context<ChatContextValue | null>;
|
|
@@ -4473,6 +4551,7 @@ declare interface ChatContextValue {
|
|
|
4473
4551
|
state: ChatState;
|
|
4474
4552
|
dispatch: React.Dispatch<ChatAction>;
|
|
4475
4553
|
props: ChatBotProps;
|
|
4554
|
+
pluginManager?: PluginManager | null;
|
|
4476
4555
|
}
|
|
4477
4556
|
|
|
4478
4557
|
export declare const ChatHeader: default_2.FC<ChatHeaderProps>;
|
|
@@ -4617,6 +4696,54 @@ export declare interface CheckboxFieldRenderProps {
|
|
|
4617
4696
|
|
|
4618
4697
|
export declare const CloseIcon: default_2.FC<IconProps>;
|
|
4619
4698
|
|
|
4699
|
+
/**
|
|
4700
|
+
* Component Plugin — injects custom component messages into chat via events
|
|
4701
|
+
*/
|
|
4702
|
+
export declare function componentPlugin(options?: {
|
|
4703
|
+
components?: Record<string, string>;
|
|
4704
|
+
onRender?: (componentKey: string, ctx: PluginContext) => void;
|
|
4705
|
+
}): ChatPlugin;
|
|
4706
|
+
|
|
4707
|
+
/**
|
|
4708
|
+
* CRM Plugin — pushes user/lead data to CRM systems
|
|
4709
|
+
*/
|
|
4710
|
+
export declare function crmPlugin(options: {
|
|
4711
|
+
endpoint: string;
|
|
4712
|
+
provider?: string;
|
|
4713
|
+
headers?: Record<string, string>;
|
|
4714
|
+
mapFields?: (data: Record<string, unknown>) => Record<string, unknown>;
|
|
4715
|
+
events?: ('submit' | 'flowEnd' | 'login')[];
|
|
4716
|
+
}): ChatPlugin;
|
|
4717
|
+
|
|
4718
|
+
/**
|
|
4719
|
+
* Debug Plugin — exposes internal state and flow progression for debugging
|
|
4720
|
+
*/
|
|
4721
|
+
export declare function debugPlugin(options?: {
|
|
4722
|
+
logState?: boolean;
|
|
4723
|
+
logEvents?: boolean;
|
|
4724
|
+
logMessages?: boolean;
|
|
4725
|
+
groupName?: string;
|
|
4726
|
+
}): ChatPlugin;
|
|
4727
|
+
|
|
4728
|
+
/**
|
|
4729
|
+
* DevTools Plugin — provides a visual debugging panel overlay
|
|
4730
|
+
*/
|
|
4731
|
+
export declare function devtoolsPlugin(options?: {
|
|
4732
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
4733
|
+
shortcutKey?: string;
|
|
4734
|
+
onStateUpdate?: (state: DevToolsState) => void;
|
|
4735
|
+
}): ChatPlugin;
|
|
4736
|
+
|
|
4737
|
+
declare interface DevToolsState {
|
|
4738
|
+
messages: number;
|
|
4739
|
+
events: Array<{
|
|
4740
|
+
type: string;
|
|
4741
|
+
time: number;
|
|
4742
|
+
}>;
|
|
4743
|
+
data: Record<string, unknown>;
|
|
4744
|
+
currentStep: string | null;
|
|
4745
|
+
}
|
|
4746
|
+
|
|
4620
4747
|
export declare const DynamicForm: default_2.FC<DynamicFormProps>;
|
|
4621
4748
|
|
|
4622
4749
|
declare interface DynamicFormProps {
|
|
@@ -4626,6 +4753,17 @@ declare interface DynamicFormProps {
|
|
|
4626
4753
|
renderFormField?: FormFieldRenderMap;
|
|
4627
4754
|
}
|
|
4628
4755
|
|
|
4756
|
+
/**
|
|
4757
|
+
* Email Plugin — triggers emails via external API when chat events occur
|
|
4758
|
+
*/
|
|
4759
|
+
export declare function emailPlugin(options: {
|
|
4760
|
+
endpoint: string;
|
|
4761
|
+
template?: string;
|
|
4762
|
+
headers?: Record<string, string>;
|
|
4763
|
+
triggers?: ('submit' | 'flowEnd' | 'login')[];
|
|
4764
|
+
mapPayload?: (data: Record<string, unknown>) => Record<string, unknown>;
|
|
4765
|
+
}): ChatPlugin;
|
|
4766
|
+
|
|
4629
4767
|
export declare const EmojiIcon: default_2.FC<IconProps>;
|
|
4630
4768
|
|
|
4631
4769
|
export declare const EmojiPicker: default_2.FC<EmojiPickerProps>;
|
|
@@ -4783,10 +4921,22 @@ export declare interface FlowStep {
|
|
|
4783
4921
|
condition?: FlowCondition;
|
|
4784
4922
|
/** Key into ChatBotProps.components — renders a custom React component in this step */
|
|
4785
4923
|
component?: string;
|
|
4924
|
+
/** Free-text input configuration — validates user input before advancing */
|
|
4925
|
+
input?: FlowStepInput;
|
|
4786
4926
|
/** Async action to run when this step is entered (API calls, verification, etc.) */
|
|
4787
4927
|
asyncAction?: FlowAsyncAction;
|
|
4788
4928
|
}
|
|
4789
4929
|
|
|
4930
|
+
/** Configuration for a free-text input step with optional validation */
|
|
4931
|
+
export declare interface FlowStepInput {
|
|
4932
|
+
/** Placeholder text for the input */
|
|
4933
|
+
placeholder?: string;
|
|
4934
|
+
/** Validation rules (reuses form validation) */
|
|
4935
|
+
validation?: FormFieldValidation;
|
|
4936
|
+
/** Transform user input before storing */
|
|
4937
|
+
transform?: 'lowercase' | 'uppercase' | 'trim' | 'email';
|
|
4938
|
+
}
|
|
4939
|
+
|
|
4790
4940
|
export declare interface FormConfig {
|
|
4791
4941
|
id: string;
|
|
4792
4942
|
title?: string;
|
|
@@ -4837,6 +4987,7 @@ export declare type FormFieldRenderProps = TextFieldRenderProps | SelectFieldRen
|
|
|
4837
4987
|
export declare type FormFieldType = 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'checkbox' | 'file' | 'date' | 'time' | 'hidden';
|
|
4838
4988
|
|
|
4839
4989
|
export declare interface FormFieldValidation {
|
|
4990
|
+
required?: boolean;
|
|
4840
4991
|
pattern?: string;
|
|
4841
4992
|
minLength?: number;
|
|
4842
4993
|
maxLength?: number;
|
|
@@ -4855,6 +5006,16 @@ export declare interface HeaderConfig {
|
|
|
4855
5006
|
showRestart?: boolean;
|
|
4856
5007
|
}
|
|
4857
5008
|
|
|
5009
|
+
/**
|
|
5010
|
+
* i18n Plugin — supports multiple languages with dynamic switching
|
|
5011
|
+
*/
|
|
5012
|
+
export declare function i18nPlugin(options: {
|
|
5013
|
+
defaultLocale?: string;
|
|
5014
|
+
translations: Translations;
|
|
5015
|
+
storageKey?: string;
|
|
5016
|
+
onLocaleChange?: (locale: string, ctx: PluginContext) => void;
|
|
5017
|
+
}): ChatPlugin;
|
|
5018
|
+
|
|
4858
5019
|
declare interface IconProps {
|
|
4859
5020
|
size?: number;
|
|
4860
5021
|
color?: string;
|
|
@@ -4863,6 +5024,37 @@ declare interface IconProps {
|
|
|
4863
5024
|
|
|
4864
5025
|
export declare const ImageIcon: default_2.FC<IconProps>;
|
|
4865
5026
|
|
|
5027
|
+
/**
|
|
5028
|
+
* Intent Plugin — detects user intent from text and emits intent events for dynamic routing
|
|
5029
|
+
*/
|
|
5030
|
+
export declare function intentPlugin(options?: {
|
|
5031
|
+
rules?: IntentRule[];
|
|
5032
|
+
onIntentDetected?: (intent: string, text: string, ctx: PluginContext) => void;
|
|
5033
|
+
fallbackIntent?: string;
|
|
5034
|
+
}): ChatPlugin;
|
|
5035
|
+
|
|
5036
|
+
declare interface IntentRule {
|
|
5037
|
+
intent: string;
|
|
5038
|
+
patterns: string[];
|
|
5039
|
+
matchType?: 'contains' | 'exact' | 'regex';
|
|
5040
|
+
}
|
|
5041
|
+
|
|
5042
|
+
/** Route configuration for keyword-based text matching */
|
|
5043
|
+
export declare interface KeywordRoute {
|
|
5044
|
+
/** Patterns to match against user text */
|
|
5045
|
+
patterns: string[];
|
|
5046
|
+
/** Bot response message when matched */
|
|
5047
|
+
response?: string;
|
|
5048
|
+
/** Jump to this flow step when matched */
|
|
5049
|
+
next?: string;
|
|
5050
|
+
/** Case-sensitive matching (default: false) */
|
|
5051
|
+
caseSensitive?: boolean;
|
|
5052
|
+
/** Matching strategy (default: 'contains') */
|
|
5053
|
+
matchType?: 'exact' | 'contains' | 'startsWith' | 'regex';
|
|
5054
|
+
/** Priority — higher wins when multiple routes match (default: 0) */
|
|
5055
|
+
priority?: number;
|
|
5056
|
+
}
|
|
5057
|
+
|
|
4866
5058
|
export declare const Launcher: default_2.FC<LauncherProps>;
|
|
4867
5059
|
|
|
4868
5060
|
declare interface LauncherProps {
|
|
@@ -4875,6 +5067,26 @@ declare interface LauncherProps {
|
|
|
4875
5067
|
zIndex?: number;
|
|
4876
5068
|
}
|
|
4877
5069
|
|
|
5070
|
+
/**
|
|
5071
|
+
* Lead Plugin — captures and stores user information as leads
|
|
5072
|
+
*/
|
|
5073
|
+
export declare function leadPlugin(options: {
|
|
5074
|
+
fields?: string[];
|
|
5075
|
+
endpoint?: string;
|
|
5076
|
+
headers?: Record<string, string>;
|
|
5077
|
+
storageKey?: string;
|
|
5078
|
+
onLeadCaptured?: (lead: Record<string, unknown>, ctx: PluginContext) => void;
|
|
5079
|
+
}): ChatPlugin;
|
|
5080
|
+
|
|
5081
|
+
/**
|
|
5082
|
+
* Logger Plugin — logs all chatbot events for debugging or auditing
|
|
5083
|
+
*/
|
|
5084
|
+
export declare function loggerPlugin(options?: {
|
|
5085
|
+
level?: LogLevel;
|
|
5086
|
+
prefix?: string;
|
|
5087
|
+
logger?: Pick<Console, 'debug' | 'info' | 'warn' | 'error'>;
|
|
5088
|
+
}): ChatPlugin;
|
|
5089
|
+
|
|
4878
5090
|
export declare const LoginScreen: default_2.FC<LoginScreenProps>;
|
|
4879
5091
|
|
|
4880
5092
|
declare interface LoginScreenProps {
|
|
@@ -4884,6 +5096,29 @@ declare interface LoginScreenProps {
|
|
|
4884
5096
|
renderFormField?: FormFieldRenderMap;
|
|
4885
5097
|
}
|
|
4886
5098
|
|
|
5099
|
+
declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
5100
|
+
|
|
5101
|
+
/**
|
|
5102
|
+
* Markdown Plugin — transforms markdown syntax in bot messages to HTML
|
|
5103
|
+
* Lightweight built-in renderer, no external dependencies.
|
|
5104
|
+
*/
|
|
5105
|
+
export declare function markdownPlugin(options?: {
|
|
5106
|
+
enableBold?: boolean;
|
|
5107
|
+
enableItalic?: boolean;
|
|
5108
|
+
enableCode?: boolean;
|
|
5109
|
+
enableLinks?: boolean;
|
|
5110
|
+
enableLists?: boolean;
|
|
5111
|
+
enableLineBreaks?: boolean;
|
|
5112
|
+
}): ChatPlugin;
|
|
5113
|
+
|
|
5114
|
+
/**
|
|
5115
|
+
* Media Plugin — adds support for rich media messages (images, videos, cards)
|
|
5116
|
+
*/
|
|
5117
|
+
export declare function mediaPlugin(options?: {
|
|
5118
|
+
allowedTypes?: ('image' | 'video' | 'audio' | 'card')[];
|
|
5119
|
+
onMediaRender?: (type: string, url: string) => void;
|
|
5120
|
+
}): ChatPlugin;
|
|
5121
|
+
|
|
4887
5122
|
export declare interface MessageAttachment {
|
|
4888
5123
|
name: string;
|
|
4889
5124
|
url: string;
|
|
@@ -4925,11 +5160,13 @@ export declare type MessageSender = 'bot' | 'user' | 'system';
|
|
|
4925
5160
|
export declare const MinimizeIcon: default_2.FC<IconProps>;
|
|
4926
5161
|
|
|
4927
5162
|
/**
|
|
4928
|
-
* Persistence Plugin — saves/restores chat history via
|
|
5163
|
+
* Persistence Plugin — saves/restores full chat history via browser storage
|
|
4929
5164
|
*/
|
|
4930
5165
|
export declare function persistencePlugin(options?: {
|
|
4931
5166
|
storageKey?: string;
|
|
4932
5167
|
storage?: 'local' | 'session';
|
|
5168
|
+
maxMessages?: number;
|
|
5169
|
+
ttl?: number;
|
|
4933
5170
|
}): ChatPlugin;
|
|
4934
5171
|
|
|
4935
5172
|
export declare interface PluginContext {
|
|
@@ -4959,15 +5196,28 @@ export declare class PluginManager {
|
|
|
4959
5196
|
private eventHandlers;
|
|
4960
5197
|
register(plugins: ChatPlugin[]): void;
|
|
4961
5198
|
setContext(ctx: Omit<PluginContext, 'on' | 'emit'>): void;
|
|
5199
|
+
getContext(): PluginContext | null;
|
|
4962
5200
|
private on;
|
|
4963
5201
|
private emit;
|
|
4964
5202
|
init(): Promise<void>;
|
|
4965
5203
|
onMessage(message: ChatMessage): Promise<ChatMessage>;
|
|
4966
5204
|
onSubmit(data: Record<string, unknown>): Promise<void>;
|
|
5205
|
+
/** Emit a lifecycle event to all plugins (open, close, flowEnd, stepChange, quickReply, etc.) */
|
|
5206
|
+
emitEvent(type: string, payload?: unknown): void;
|
|
4967
5207
|
destroy(): Promise<void>;
|
|
4968
5208
|
private dispatchEvent;
|
|
4969
5209
|
}
|
|
4970
5210
|
|
|
5211
|
+
/**
|
|
5212
|
+
* Push Plugin — sends browser push notifications for new messages
|
|
5213
|
+
*/
|
|
5214
|
+
export declare function pushPlugin(options?: {
|
|
5215
|
+
title?: string;
|
|
5216
|
+
icon?: string;
|
|
5217
|
+
onlyWhenHidden?: boolean;
|
|
5218
|
+
requestPermission?: boolean;
|
|
5219
|
+
}): ChatPlugin;
|
|
5220
|
+
|
|
4971
5221
|
export declare const QuickReplies: default_2.FC<QuickRepliesProps>;
|
|
4972
5222
|
|
|
4973
5223
|
declare interface QuickRepliesProps {
|
|
@@ -4994,12 +5244,49 @@ export declare interface RadioFieldRenderProps {
|
|
|
4994
5244
|
error?: string;
|
|
4995
5245
|
}
|
|
4996
5246
|
|
|
5247
|
+
/**
|
|
5248
|
+
* Rate Limit Plugin — prevents spam by limiting message frequency
|
|
5249
|
+
*/
|
|
5250
|
+
export declare function rateLimitPlugin(options?: {
|
|
5251
|
+
limit?: number;
|
|
5252
|
+
window?: number;
|
|
5253
|
+
onLimited?: (remaining: number) => void;
|
|
5254
|
+
warningMessage?: string;
|
|
5255
|
+
}): ChatPlugin;
|
|
5256
|
+
|
|
5257
|
+
/**
|
|
5258
|
+
* Reminder Plugin — sends reminder messages to users after configured delays
|
|
5259
|
+
*/
|
|
5260
|
+
export declare function reminderPlugin(options?: {
|
|
5261
|
+
reminders?: Array<{
|
|
5262
|
+
message: string;
|
|
5263
|
+
delay: number;
|
|
5264
|
+
condition?: string;
|
|
5265
|
+
}>;
|
|
5266
|
+
onReminder?: (message: string) => void;
|
|
5267
|
+
}): ChatPlugin;
|
|
5268
|
+
|
|
4997
5269
|
export declare const RemoveIcon: default_2.FC<IconProps>;
|
|
4998
5270
|
|
|
4999
5271
|
export declare function resolveTheme(theme?: ChatTheme): Required<ChatTheme>;
|
|
5000
5272
|
|
|
5001
5273
|
export declare const RestartIcon: default_2.FC<IconProps>;
|
|
5002
5274
|
|
|
5275
|
+
declare interface ScheduledMessage {
|
|
5276
|
+
message: string;
|
|
5277
|
+
delay: number;
|
|
5278
|
+
repeat?: boolean;
|
|
5279
|
+
interval?: number;
|
|
5280
|
+
}
|
|
5281
|
+
|
|
5282
|
+
/**
|
|
5283
|
+
* Scheduler Plugin — triggers bot messages at scheduled times or intervals
|
|
5284
|
+
*/
|
|
5285
|
+
export declare function schedulerPlugin(options: {
|
|
5286
|
+
messages?: ScheduledMessage[];
|
|
5287
|
+
onScheduledMessage?: (message: string) => void;
|
|
5288
|
+
}): ChatPlugin;
|
|
5289
|
+
|
|
5003
5290
|
export declare const SelectField: default_2.FC<SelectFieldProps>;
|
|
5004
5291
|
|
|
5005
5292
|
declare interface SelectFieldProps {
|
|
@@ -5020,6 +5307,15 @@ export declare interface SelectFieldRenderProps {
|
|
|
5020
5307
|
|
|
5021
5308
|
export declare const SendIcon: default_2.FC<IconProps>;
|
|
5022
5309
|
|
|
5310
|
+
/**
|
|
5311
|
+
* Sound Plugin — plays sound on new bot messages
|
|
5312
|
+
*/
|
|
5313
|
+
export declare function soundPlugin(options?: {
|
|
5314
|
+
src?: string;
|
|
5315
|
+
volume?: number;
|
|
5316
|
+
onlyWhenHidden?: boolean;
|
|
5317
|
+
}): ChatPlugin;
|
|
5318
|
+
|
|
5023
5319
|
/** Props passed to custom components rendered in flow steps */
|
|
5024
5320
|
export declare interface StepComponentProps {
|
|
5025
5321
|
/** The step ID that owns this component */
|
|
@@ -5030,6 +5326,16 @@ export declare interface StepComponentProps {
|
|
|
5030
5326
|
onComplete: (result?: FlowActionResult) => void;
|
|
5031
5327
|
}
|
|
5032
5328
|
|
|
5329
|
+
/**
|
|
5330
|
+
* Sync Plugin — syncs chat data with a backend endpoint
|
|
5331
|
+
*/
|
|
5332
|
+
export declare function syncPlugin(options: {
|
|
5333
|
+
endpoint: string;
|
|
5334
|
+
headers?: Record<string, string>;
|
|
5335
|
+
syncInterval?: number;
|
|
5336
|
+
sessionKey?: string;
|
|
5337
|
+
}): ChatPlugin;
|
|
5338
|
+
|
|
5033
5339
|
export declare const TextField: default_2.FC<TextFieldProps>;
|
|
5034
5340
|
|
|
5035
5341
|
declare interface TextFieldProps {
|
|
@@ -5048,15 +5354,72 @@ export declare interface TextFieldRenderProps {
|
|
|
5048
5354
|
error?: string;
|
|
5049
5355
|
}
|
|
5050
5356
|
|
|
5357
|
+
/**
|
|
5358
|
+
* Theme Plugin — switches themes dynamically and persists preference
|
|
5359
|
+
*/
|
|
5360
|
+
export declare function themePlugin(options?: {
|
|
5361
|
+
defaultMode?: 'light' | 'dark';
|
|
5362
|
+
storageKey?: string;
|
|
5363
|
+
onThemeChange?: (mode: string, ctx: PluginContext) => void;
|
|
5364
|
+
cssVariable?: string;
|
|
5365
|
+
}): ChatPlugin;
|
|
5366
|
+
|
|
5367
|
+
/**
|
|
5368
|
+
* Transfer Plugin — transfers chat to different departments/agents via API
|
|
5369
|
+
*/
|
|
5370
|
+
export declare function transferPlugin(options: {
|
|
5371
|
+
endpoint: string;
|
|
5372
|
+
headers?: Record<string, string>;
|
|
5373
|
+
departments?: string[];
|
|
5374
|
+
onTransfer?: (department: string, ctx: PluginContext) => void;
|
|
5375
|
+
onTransferComplete?: (result: unknown, ctx: PluginContext) => void;
|
|
5376
|
+
transferMessage?: string;
|
|
5377
|
+
}): ChatPlugin;
|
|
5378
|
+
|
|
5379
|
+
declare type Translations = Record<string, Record<string, string>>;
|
|
5380
|
+
|
|
5381
|
+
declare type TriggerType = 'exitIntent' | 'idle' | 'scroll' | 'pageLoad' | 'custom';
|
|
5382
|
+
|
|
5051
5383
|
export declare const TypingIndicator: default_2.FC<TypingIndicatorProps>;
|
|
5052
5384
|
|
|
5053
5385
|
declare interface TypingIndicatorProps {
|
|
5054
5386
|
color: string;
|
|
5055
5387
|
}
|
|
5056
5388
|
|
|
5389
|
+
/**
|
|
5390
|
+
* Typing Plugin — adds configurable typing delay before bot messages are shown
|
|
5391
|
+
*/
|
|
5392
|
+
export declare function typingPlugin(options?: {
|
|
5393
|
+
delay?: number;
|
|
5394
|
+
onTypingStart?: () => void;
|
|
5395
|
+
onTypingEnd?: () => void;
|
|
5396
|
+
}): ChatPlugin;
|
|
5397
|
+
|
|
5398
|
+
/**
|
|
5399
|
+
* Upload Plugin — handles file uploads to external storage (S3, etc.)
|
|
5400
|
+
*/
|
|
5401
|
+
export declare function uploadPlugin(options: {
|
|
5402
|
+
endpoint: string;
|
|
5403
|
+
storage?: 's3' | 'gcs' | 'azure' | 'custom';
|
|
5404
|
+
headers?: Record<string, string>;
|
|
5405
|
+
maxSize?: number;
|
|
5406
|
+
allowedTypes?: string[];
|
|
5407
|
+
onUploadStart?: (file: {
|
|
5408
|
+
name: string;
|
|
5409
|
+
size: number;
|
|
5410
|
+
}) => void;
|
|
5411
|
+
onUploadComplete?: (file: {
|
|
5412
|
+
name: string;
|
|
5413
|
+
url: string;
|
|
5414
|
+
}) => void;
|
|
5415
|
+
onUploadError?: (file: {
|
|
5416
|
+
name: string;
|
|
5417
|
+
}, error: Error) => void;
|
|
5418
|
+
}): ChatPlugin;
|
|
5419
|
+
|
|
5057
5420
|
export declare function useChat(): {
|
|
5058
5421
|
state: ChatState;
|
|
5059
|
-
sendMessage: (text: string) => void
|
|
5422
|
+
sendMessage: (text: string) => Promise<void>;
|
|
5060
5423
|
addBotMessage: (text: string, extras?: Partial<ChatMessage>) => Promise<void>;
|
|
5061
5424
|
handleQuickReply: (value: string, label: string) => void;
|
|
5062
5425
|
handleFormSubmit: (formId: string, data: Record<string, unknown>) => Promise<void>;
|
|
@@ -5073,12 +5436,28 @@ export declare function useChat(): {
|
|
|
5073
5436
|
export declare function useChatContext(): ChatContextValue;
|
|
5074
5437
|
|
|
5075
5438
|
/**
|
|
5076
|
-
*
|
|
5439
|
+
* Validation Plugin — adds advanced validation rules for user inputs
|
|
5440
|
+
*/
|
|
5441
|
+
export declare function validationPlugin(options?: {
|
|
5442
|
+
validators?: Record<string, Validator>;
|
|
5443
|
+
sanitize?: boolean;
|
|
5444
|
+
blockProfanity?: boolean;
|
|
5445
|
+
profanityList?: string[];
|
|
5446
|
+
onValidationFail?: (text: string, error: string) => void;
|
|
5447
|
+
}): ChatPlugin;
|
|
5448
|
+
|
|
5449
|
+
declare type Validator = (text: string) => string | null;
|
|
5450
|
+
|
|
5451
|
+
declare type WebhookEventType = 'message' | 'submit' | 'init' | 'destroy' | 'open' | 'close' | 'flowEnd' | 'stepChange' | 'quickReply' | 'login';
|
|
5452
|
+
|
|
5453
|
+
/**
|
|
5454
|
+
* Webhook Plugin — sends messages/submissions/lifecycle events to an external endpoint
|
|
5077
5455
|
*/
|
|
5078
5456
|
export declare function webhookPlugin(options: {
|
|
5079
5457
|
url: string;
|
|
5080
5458
|
headers?: Record<string, string>;
|
|
5081
|
-
events?:
|
|
5459
|
+
events?: WebhookEventType[];
|
|
5460
|
+
timeout?: number;
|
|
5082
5461
|
}): ChatPlugin;
|
|
5083
5462
|
|
|
5084
5463
|
export declare const WelcomeScreen: default_2.FC<WelcomeScreenProps>;
|