@robylon/whatsapp-react-sdk 1.0.0-staging.1

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.
Files changed (136) hide show
  1. package/CONTRIBUTING.md +133 -0
  2. package/README.md +736 -0
  3. package/dist/cjs/index.js +4 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/cjs/types/components/ChatWidgetPopup.d.ts +8 -0
  6. package/dist/cjs/types/components/ChatbotContainer/ChatbotContainer.d.ts +15 -0
  7. package/dist/cjs/types/components/ChatbotContainer/index.d.ts +1 -0
  8. package/dist/cjs/types/components/ChatbotFloatingButton.d.ts +19 -0
  9. package/dist/cjs/types/components/ErrorBoundary.d.ts +15 -0
  10. package/dist/cjs/types/components/RobylonChatbot.d.ts +28 -0
  11. package/dist/cjs/types/config.d.ts +5 -0
  12. package/dist/cjs/types/constants/errorConstants.d.ts +60 -0
  13. package/dist/cjs/types/constants/fontStyles.d.ts +4 -0
  14. package/dist/cjs/types/core/api.d.ts +10 -0
  15. package/dist/cjs/types/core/config.d.ts +41 -0
  16. package/dist/cjs/types/core/events.d.ts +22 -0
  17. package/dist/cjs/types/core/index.d.ts +4 -0
  18. package/dist/cjs/types/core/state.d.ts +34 -0
  19. package/dist/cjs/types/hooks/useChatbot.d.ts +2 -0
  20. package/dist/cjs/types/hooks/useChatbotEvents.d.ts +12 -0
  21. package/dist/cjs/types/hooks/useChatbotState.d.ts +16 -0
  22. package/dist/cjs/types/hooks/useWhyDidYouUpdate.d.ts +5 -0
  23. package/dist/cjs/types/index.d.ts +6 -0
  24. package/dist/cjs/types/services/ErrorTrackingService.d.ts +38 -0
  25. package/dist/cjs/types/types/events.d.ts +29 -0
  26. package/dist/cjs/types/types/state.d.ts +5 -0
  27. package/dist/cjs/types/types.d.ts +137 -0
  28. package/dist/cjs/types/utils/chatbotSdk.d.ts +23 -0
  29. package/dist/cjs/types/utils/colorUtils.d.ts +1 -0
  30. package/dist/cjs/types/utils/cookieUtils.d.ts +6 -0
  31. package/dist/cjs/types/utils/environment.d.ts +12 -0
  32. package/dist/cjs/types/utils/fetchData.d.ts +53 -0
  33. package/dist/cjs/types/utils/launcherInfo.d.ts +11 -0
  34. package/dist/cjs/types/utils/logger.d.ts +6 -0
  35. package/dist/cjs/types/utils/misc.d.ts +1 -0
  36. package/dist/cjs/types/utils/originalFetchDataFile.d.ts +1 -0
  37. package/dist/cjs/types/utils/proactive.d.ts +25 -0
  38. package/dist/cjs/types/utils/sanitize.d.ts +4 -0
  39. package/dist/cjs/types/utils/systemInfo.d.ts +12 -0
  40. package/dist/cjs/types/utils/textDirection.d.ts +7 -0
  41. package/dist/cjs/types/utils/url.d.ts +8 -0
  42. package/dist/cjs/types/utils/version.d.ts +1 -0
  43. package/dist/cjs/types/vanilla/components/ChatWidgetPopup.d.ts +17 -0
  44. package/dist/cjs/types/vanilla/components/ChatbotContainer.d.ts +45 -0
  45. package/dist/cjs/types/vanilla/components/ChatbotFloatingButton.d.ts +83 -0
  46. package/dist/cjs/types/vanilla/index.d.ts +42 -0
  47. package/dist/esm/index.js +4 -0
  48. package/dist/esm/index.js.map +1 -0
  49. package/dist/esm/types/components/ChatWidgetPopup.d.ts +8 -0
  50. package/dist/esm/types/components/ChatbotContainer/ChatbotContainer.d.ts +15 -0
  51. package/dist/esm/types/components/ChatbotContainer/index.d.ts +1 -0
  52. package/dist/esm/types/components/ChatbotFloatingButton.d.ts +19 -0
  53. package/dist/esm/types/components/ErrorBoundary.d.ts +15 -0
  54. package/dist/esm/types/components/RobylonChatbot.d.ts +28 -0
  55. package/dist/esm/types/config.d.ts +5 -0
  56. package/dist/esm/types/constants/errorConstants.d.ts +60 -0
  57. package/dist/esm/types/constants/fontStyles.d.ts +4 -0
  58. package/dist/esm/types/core/api.d.ts +10 -0
  59. package/dist/esm/types/core/config.d.ts +41 -0
  60. package/dist/esm/types/core/events.d.ts +22 -0
  61. package/dist/esm/types/core/index.d.ts +4 -0
  62. package/dist/esm/types/core/state.d.ts +34 -0
  63. package/dist/esm/types/hooks/useChatbot.d.ts +2 -0
  64. package/dist/esm/types/hooks/useChatbotEvents.d.ts +12 -0
  65. package/dist/esm/types/hooks/useChatbotState.d.ts +16 -0
  66. package/dist/esm/types/hooks/useWhyDidYouUpdate.d.ts +5 -0
  67. package/dist/esm/types/index.d.ts +6 -0
  68. package/dist/esm/types/services/ErrorTrackingService.d.ts +38 -0
  69. package/dist/esm/types/types/events.d.ts +29 -0
  70. package/dist/esm/types/types/state.d.ts +5 -0
  71. package/dist/esm/types/types.d.ts +137 -0
  72. package/dist/esm/types/utils/chatbotSdk.d.ts +23 -0
  73. package/dist/esm/types/utils/colorUtils.d.ts +1 -0
  74. package/dist/esm/types/utils/cookieUtils.d.ts +6 -0
  75. package/dist/esm/types/utils/environment.d.ts +12 -0
  76. package/dist/esm/types/utils/fetchData.d.ts +53 -0
  77. package/dist/esm/types/utils/launcherInfo.d.ts +11 -0
  78. package/dist/esm/types/utils/logger.d.ts +6 -0
  79. package/dist/esm/types/utils/misc.d.ts +1 -0
  80. package/dist/esm/types/utils/originalFetchDataFile.d.ts +1 -0
  81. package/dist/esm/types/utils/proactive.d.ts +25 -0
  82. package/dist/esm/types/utils/sanitize.d.ts +4 -0
  83. package/dist/esm/types/utils/systemInfo.d.ts +12 -0
  84. package/dist/esm/types/utils/textDirection.d.ts +7 -0
  85. package/dist/esm/types/utils/url.d.ts +8 -0
  86. package/dist/esm/types/utils/version.d.ts +1 -0
  87. package/dist/esm/types/vanilla/components/ChatWidgetPopup.d.ts +17 -0
  88. package/dist/esm/types/vanilla/components/ChatbotContainer.d.ts +45 -0
  89. package/dist/esm/types/vanilla/components/ChatbotFloatingButton.d.ts +83 -0
  90. package/dist/esm/types/vanilla/index.d.ts +42 -0
  91. package/dist/index.d.ts +235 -0
  92. package/dist/umd/robylon-chatbot.js +2 -0
  93. package/dist/umd/robylon-chatbot.js.map +1 -0
  94. package/dist/umd/types/components/ChatWidgetPopup.d.ts +8 -0
  95. package/dist/umd/types/components/ChatbotContainer/ChatbotContainer.d.ts +15 -0
  96. package/dist/umd/types/components/ChatbotContainer/index.d.ts +1 -0
  97. package/dist/umd/types/components/ChatbotFloatingButton.d.ts +19 -0
  98. package/dist/umd/types/components/ErrorBoundary.d.ts +15 -0
  99. package/dist/umd/types/components/RobylonChatbot.d.ts +28 -0
  100. package/dist/umd/types/config.d.ts +5 -0
  101. package/dist/umd/types/constants/errorConstants.d.ts +60 -0
  102. package/dist/umd/types/constants/fontStyles.d.ts +4 -0
  103. package/dist/umd/types/core/api.d.ts +10 -0
  104. package/dist/umd/types/core/config.d.ts +41 -0
  105. package/dist/umd/types/core/events.d.ts +22 -0
  106. package/dist/umd/types/core/index.d.ts +4 -0
  107. package/dist/umd/types/core/state.d.ts +34 -0
  108. package/dist/umd/types/hooks/useChatbot.d.ts +2 -0
  109. package/dist/umd/types/hooks/useChatbotEvents.d.ts +12 -0
  110. package/dist/umd/types/hooks/useChatbotState.d.ts +16 -0
  111. package/dist/umd/types/hooks/useWhyDidYouUpdate.d.ts +5 -0
  112. package/dist/umd/types/index.d.ts +6 -0
  113. package/dist/umd/types/services/ErrorTrackingService.d.ts +38 -0
  114. package/dist/umd/types/types/events.d.ts +29 -0
  115. package/dist/umd/types/types/state.d.ts +5 -0
  116. package/dist/umd/types/types.d.ts +137 -0
  117. package/dist/umd/types/utils/chatbotSdk.d.ts +23 -0
  118. package/dist/umd/types/utils/colorUtils.d.ts +1 -0
  119. package/dist/umd/types/utils/cookieUtils.d.ts +6 -0
  120. package/dist/umd/types/utils/environment.d.ts +12 -0
  121. package/dist/umd/types/utils/fetchData.d.ts +53 -0
  122. package/dist/umd/types/utils/launcherInfo.d.ts +11 -0
  123. package/dist/umd/types/utils/logger.d.ts +6 -0
  124. package/dist/umd/types/utils/misc.d.ts +1 -0
  125. package/dist/umd/types/utils/originalFetchDataFile.d.ts +1 -0
  126. package/dist/umd/types/utils/proactive.d.ts +25 -0
  127. package/dist/umd/types/utils/sanitize.d.ts +4 -0
  128. package/dist/umd/types/utils/systemInfo.d.ts +12 -0
  129. package/dist/umd/types/utils/textDirection.d.ts +7 -0
  130. package/dist/umd/types/utils/url.d.ts +8 -0
  131. package/dist/umd/types/utils/version.d.ts +1 -0
  132. package/dist/umd/types/vanilla/components/ChatWidgetPopup.d.ts +17 -0
  133. package/dist/umd/types/vanilla/components/ChatbotContainer.d.ts +45 -0
  134. package/dist/umd/types/vanilla/components/ChatbotFloatingButton.d.ts +83 -0
  135. package/dist/umd/types/vanilla/index.d.ts +42 -0
  136. package/package.json +110 -0
@@ -0,0 +1,60 @@
1
+ export declare const ErrorCodes: {
2
+ readonly MISSING_API_KEY: "MISSING_API_KEY";
3
+ readonly INVALID_API_KEY: "INVALID_API_KEY";
4
+ readonly INVALID_USER_ID: "INVALID_USER_ID";
5
+ readonly CONFIG_FETCH_FAILED: "CONFIG_FETCH_FAILED";
6
+ readonly SDK_INIT_FAILED: "SDK_INIT_FAILED";
7
+ readonly ERROR_TRACKING_INIT_FAILED: "ERROR_TRACKING_INIT_FAILED";
8
+ readonly API_REQUEST_FAILED: "API_REQUEST_FAILED";
9
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
10
+ readonly INVALID_RESPONSE: "INVALID_RESPONSE";
11
+ readonly IFRAME_LOAD_FAILED: "IFRAME_LOAD_FAILED";
12
+ readonly MESSAGE_HANDLER_ERROR: "MESSAGE_HANDLER_ERROR";
13
+ readonly COOKIE_ACCESS_ERROR: "COOKIE_ACCESS_ERROR";
14
+ readonly COMPONENT_RENDER_ERROR: "COMPONENT_RENDER_ERROR";
15
+ readonly STATE_UPDATE_ERROR: "STATE_UPDATE_ERROR";
16
+ };
17
+ export declare const ErrorTypes: {
18
+ readonly INITIALIZATION_ERROR: "INITIALIZATION_ERROR";
19
+ readonly API_ERROR: "API_ERROR";
20
+ readonly RUNTIME_ERROR: "RUNTIME_ERROR";
21
+ readonly COMPONENT_ERROR: "COMPONENT_ERROR";
22
+ };
23
+ export declare const ErrorMessages: {
24
+ readonly MISSING_API_KEY: (providedValue?: any) => string;
25
+ readonly INVALID_API_KEY: (apiKey: string) => string;
26
+ readonly CONFIG_FETCH_FAILED: (details: {
27
+ statusCode?: number;
28
+ error?: string;
29
+ }) => string;
30
+ readonly API_REQUEST_FAILED: (status: number, message: string, endpoint?: string) => string;
31
+ readonly NETWORK_ERROR: (details: {
32
+ url?: string;
33
+ error?: string;
34
+ }) => string;
35
+ readonly IFRAME_LOAD_FAILED: (details: {
36
+ src?: string;
37
+ error?: string;
38
+ }) => string;
39
+ readonly INVALID_RESPONSE: (missingFields: string[]) => string;
40
+ readonly ERROR_TRACKING_INIT_FAILED: (details: {
41
+ apiKey?: string;
42
+ error?: string;
43
+ }) => string;
44
+ readonly SDK_INIT_FAILED: (details: {
45
+ reason?: string;
46
+ config?: Record<string, any>;
47
+ }) => string;
48
+ readonly COOKIE_ACCESS_ERROR: (operation: string, cookieName?: string) => string;
49
+ readonly COMPONENT_RENDER_ERROR: (details: {
50
+ component?: string | null | undefined;
51
+ error: string;
52
+ stack?: string | null;
53
+ }) => string;
54
+ };
55
+ export interface ErrorDetails {
56
+ errorCode: keyof typeof ErrorCodes;
57
+ errorType: keyof typeof ErrorTypes;
58
+ context?: Record<string, any>;
59
+ originalError?: any;
60
+ }
@@ -0,0 +1,4 @@
1
+ export declare const FONT_FAMILY = "system-ui, Inter, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'";
2
+ /** Chat widget popup: same stack as FONT_FAMILY with trailing generic + !important via scoped CSS */
3
+ export declare const CHAT_WIDGET_POPUP_FONT_FAMILY = "system-ui, Inter, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", sans-serif";
4
+ export declare const FONT_LINE_HEIGHT = "21px";
@@ -0,0 +1,10 @@
1
+ export declare const USE_WHATSAPP_MOCK_API = false;
2
+ export declare const normalizeWhatsappGetResponse: (data: any) => any;
3
+ /**
4
+ * Fetches the chatbot configuration from the API
5
+ * @param apiKey The API key for the chatbot
6
+ * @param userId The user ID (optional)
7
+ * @param userToken The user token (optional)
8
+ * @returns The chatbot configuration
9
+ */
10
+ export declare const fetchChatbotConfig: (apiKey: string, userId?: string, userToken?: string) => Promise<any>;
@@ -0,0 +1,41 @@
1
+ import { ChatbotConfig } from "../types";
2
+ import { ProactiveMessage } from "src/types";
3
+ /**
4
+ * Normalizes the configuration properties
5
+ * @param props The configuration properties
6
+ * @returns Normalized configuration properties
7
+ */
8
+ export declare const normalizeProps: (props: {
9
+ api_key: string;
10
+ user_id?: string | null | number;
11
+ user_token?: string;
12
+ user_profile?: Record<string, any>;
13
+ }) => {
14
+ api_key: string;
15
+ user_id: string | null;
16
+ user_token: string | undefined;
17
+ user_profile: Record<string, any>;
18
+ };
19
+ /**
20
+ * Normalizes the user profile by filtering allowed keys and converting values
21
+ * @param userProfile The user profile object
22
+ * @returns Normalized user profile
23
+ */
24
+ export declare const normalizeUserProfile: (userProfile?: Record<string, any>) => any;
25
+ /**
26
+ * Initializes the chatbot configuration
27
+ * @param props The configuration properties
28
+ * @returns The initialized chatbot configuration
29
+ */
30
+ export declare const initializeChatbotConfig: (props: {
31
+ api_key: string;
32
+ user_id?: string | null | number;
33
+ user_token?: string;
34
+ user_profile?: Record<string, any>;
35
+ }) => Promise<ChatbotConfig>;
36
+ /**
37
+ * Normalizes proactive messages from backend to an array form, preserving order.
38
+ * - Accepts undefined, single object, or array of objects
39
+ * - Migrates legacy `content` to `content_multiple`
40
+ */
41
+ export declare const normalizeProactiveMessages: (input: any) => ProactiveMessage[] | undefined;
@@ -0,0 +1,22 @@
1
+ import { ChatbotEvent, ChatbotEventType, AllEventTypes } from "../types/events";
2
+ /**
3
+ * Event emitter interface for handling chatbot events
4
+ */
5
+ export interface EventEmitter {
6
+ emit: (eventType: ChatbotEventType, data?: any) => void;
7
+ onInternalEvent: (eventType: AllEventTypes, additionalData?: Record<string, any>) => void;
8
+ }
9
+ /**
10
+ * Creates an event emitter for handling chatbot events
11
+ * @param props Configuration for the event emitter
12
+ * @returns An event emitter object
13
+ */
14
+ export declare const createEventEmitter: (props: {
15
+ api_key: string;
16
+ user_profile?: Record<string, any>;
17
+ onEvent?: (event: ChatbotEvent) => void;
18
+ chatbotConfig?: {
19
+ isAnonymous?: boolean;
20
+ userId?: string | null | number;
21
+ } | null;
22
+ }) => EventEmitter;
@@ -0,0 +1,4 @@
1
+ export * from "./api";
2
+ export * from "./config";
3
+ export * from "./events";
4
+ export * from "./state";
@@ -0,0 +1,34 @@
1
+ import { ChatbotConfig } from "../types";
2
+ /**
3
+ * Interface for the chatbot state
4
+ */
5
+ export interface ChatbotState {
6
+ isInitialized: boolean;
7
+ isInitializing: boolean;
8
+ error: string | null;
9
+ chatbotConfig: ChatbotConfig | null;
10
+ isIframeVisible: boolean;
11
+ }
12
+ /**
13
+ * Interface for the chatbot state manager
14
+ */
15
+ export interface ChatbotStateManager {
16
+ getState: () => ChatbotState;
17
+ initialize: () => Promise<void>;
18
+ toggleIframeVisibility: () => void;
19
+ closeIframe: () => void;
20
+ updateState: (partialState: Partial<ChatbotState>) => void;
21
+ subscribe: (listener: (state: ChatbotState) => void) => () => void;
22
+ unsubscribe: (listener: (state: ChatbotState) => void) => void;
23
+ }
24
+ /**
25
+ * Creates a state manager for the chatbot
26
+ * @param props Configuration properties
27
+ * @returns A state manager object
28
+ */
29
+ export declare const createChatbotStateManager: (props: {
30
+ api_key: string;
31
+ user_id?: string | null | number;
32
+ user_token?: string;
33
+ user_profile?: Record<string, any>;
34
+ }) => ChatbotStateManager;
@@ -0,0 +1,2 @@
1
+ import { ChatbotConfig, ChatbotState } from "../types";
2
+ export declare const useChatbot: (config: ChatbotConfig) => ChatbotState;
@@ -0,0 +1,12 @@
1
+ import { ChatbotEventType, AllEventTypes, ChatbotEventHandler } from "../types/events";
2
+ interface EventHookProps {
3
+ api_key: string;
4
+ chatbotConfig: any;
5
+ user_profile?: Record<string, any>;
6
+ onEvent?: ChatbotEventHandler;
7
+ }
8
+ export declare const useChatbotEvents: ({ api_key, chatbotConfig, user_profile, onEvent, }: EventHookProps) => {
9
+ emitEvent: (type: ChatbotEventType, data?: any) => void;
10
+ onInternalEvent: (eventType: AllEventTypes, additionalData?: Record<string, any>) => Promise<void>;
11
+ };
12
+ export {};
@@ -0,0 +1,16 @@
1
+ interface ChatbotStateProps {
2
+ api_key: string;
3
+ user_id?: string | null | number;
4
+ user_token?: string;
5
+ user_profile?: Record<string, any>;
6
+ }
7
+ export declare const useChatbotState: (rawProps: ChatbotStateProps) => {
8
+ toggleIframeVisibility: () => void;
9
+ closeIframe: () => void;
10
+ isInitialized: boolean;
11
+ isInitializing: boolean;
12
+ error: string | null;
13
+ chatbotConfig: any;
14
+ isIframeVisible: boolean;
15
+ };
16
+ export {};
@@ -0,0 +1,5 @@
1
+ type PropsWithKeyString = {
2
+ [key: string]: any;
3
+ };
4
+ export declare function useWhyDidYouUpdate(name: string, props: PropsWithKeyString): void;
5
+ export {};
@@ -0,0 +1,6 @@
1
+ export { Chatbot } from "./components/RobylonChatbot";
2
+ export * from "./types";
3
+ export * from "./hooks/useChatbot";
4
+ export { ChatbotRef } from "./types/events";
5
+ import RobylonChatbot from "./vanilla";
6
+ export { RobylonChatbot };
@@ -0,0 +1,38 @@
1
+ export declare enum EventType {
2
+ ERROR = "ERROR",
3
+ INFO = "INFO"
4
+ }
5
+ export interface ErrorEventData {
6
+ message: string;
7
+ stack?: string;
8
+ componentName?: string | null | undefined;
9
+ additionalInfo?: Record<string, any>;
10
+ timestamp: number;
11
+ }
12
+ export interface LogPayload {
13
+ org_id: string;
14
+ event_data: ErrorEventData;
15
+ metadata: Record<string, any>;
16
+ event_type: EventType;
17
+ user_id?: string | number | null;
18
+ }
19
+ declare class ErrorTrackingService {
20
+ private static instance;
21
+ private apiKey;
22
+ private userId;
23
+ private preInitQueue;
24
+ private isInitialized;
25
+ private constructor();
26
+ private handleWindowError;
27
+ private handleUnhandledRejection;
28
+ private setupGlobalHandlers;
29
+ cleanup(): void;
30
+ static getInstance(): ErrorTrackingService;
31
+ initialize(apiKey: string, userId?: string | number | null): void;
32
+ private processPreInitQueue;
33
+ private sendLog;
34
+ trackError(error: Error | string, componentName: string | null | undefined, additionalInfo?: Record<string, any>): Promise<void>;
35
+ trackInfo(message: string, componentName: string | null | undefined, additionalInfo?: Record<string, any>): Promise<void>;
36
+ }
37
+ export declare const errorTracker: ErrorTrackingService;
38
+ export {};
@@ -0,0 +1,29 @@
1
+ export declare enum ChatbotEventType {
2
+ CHATBOT_BUTTON_LOADED = "CHATBOT_BUTTON_LOADED",// Internal SDK event
3
+ CHATBOT_BUTTON_CLICKED = "CHATBOT_BUTTON_CLICKED",// Internal SDK event
4
+ CHATBOT_OPENED = "CHATBOT_OPENED",// Internal SDK event
5
+ CHATBOT_CLOSED = "CHATBOT_CLOSED",// Internal SDK event
6
+ CHATBOT_APP_READY = "CHATBOT_APP_READY",// Internal SDK event
7
+ CHATBOT_LOADED = "CHATBOT_LOADED",// From Robylon Chatbot
8
+ CHAT_INITIALIZED = "CHAT_INITIALIZED",// From Robylon Chatbot
9
+ SESSION_REFRESHED = "SESSION_REFRESHED",// From Robylon Chatbot
10
+ CHAT_INITIALIZATION_FAILED = "CHAT_INITIALIZATION_FAILED",// From Robylon Chatbot
11
+ CHATBOT_READY = "CHATBOT_READY"
12
+ }
13
+ export declare enum InternalEventType {
14
+ CHAT_MOVED = "CHAT_MOVED",// Internal only event
15
+ CHATBOT_TOKEN_EXHAUSTED = "CHATBOT_TOKEN_EXHAUSTED"
16
+ }
17
+ export type AllEventTypes = ChatbotEventType | InternalEventType;
18
+ export interface ChatbotEvent {
19
+ type: ChatbotEventType;
20
+ timestamp: number;
21
+ data?: any;
22
+ }
23
+ export type ChatbotEventHandler = (event: ChatbotEvent) => void;
24
+ export interface ChatbotRef {
25
+ show: () => void;
26
+ hide: () => void;
27
+ toggle: () => void;
28
+ isReady: boolean;
29
+ }
@@ -0,0 +1,5 @@
1
+ export interface ChatbotState {
2
+ isLoading: boolean;
3
+ isInitialized: boolean;
4
+ error: string | null;
5
+ }
@@ -0,0 +1,137 @@
1
+ export declare enum ChatbotInterfaceType {
2
+ WIDGET = "WIDGET",
3
+ POPOVER = "POPOVER",
4
+ EMBED = "EMBED"
5
+ }
6
+ export declare enum WidgetPositionEnums {
7
+ RIGHT = "Right",
8
+ LEFT = "Left"
9
+ }
10
+ export interface WidgetInterfaceProperties {
11
+ position: WidgetPositionEnums;
12
+ side_spacing?: number;
13
+ bottom_spacing?: number;
14
+ }
15
+ export declare enum LauncherType {
16
+ TEXT = "TEXT",
17
+ IMAGE = "IMAGE",
18
+ TEXTUAL_IMAGE = "TEXTUAL_IMAGE"
19
+ }
20
+ export interface ChatbotConfig {
21
+ chatbotId: string;
22
+ userId: string | null | number;
23
+ token?: string;
24
+ userProfile?: Record<string, any>;
25
+ domain: string;
26
+ show_launcher: boolean;
27
+ brand_colour: string;
28
+ image_url?: string;
29
+ chat_interface_config?: {
30
+ chat_bubble_prompts?: string[];
31
+ display_name?: string;
32
+ welcome_message?: string;
33
+ redirect_url?: string;
34
+ };
35
+ isAnonymous?: boolean;
36
+ interface_type?: ChatbotInterfaceType;
37
+ interface_properties?: WidgetInterfaceProperties;
38
+ launcher_type: LauncherType;
39
+ launcher_properties: {
40
+ text?: string;
41
+ };
42
+ images: {
43
+ launcher_image_url?: {
44
+ url: string;
45
+ };
46
+ };
47
+ proactive_message_obj?: ProactiveMessage[] | undefined;
48
+ launcher_delay: {
49
+ enabled: boolean;
50
+ delay: number;
51
+ };
52
+ launcher_size_multiplier?: number;
53
+ redirect_chat_link?: string;
54
+ pre_filled_message?: string;
55
+ widget_type?: string;
56
+ widget_title?: string;
57
+ widget_subtitle?: string;
58
+ title_bar_color?: string;
59
+ button_content?: string;
60
+ powered_by_robylon?: boolean;
61
+ }
62
+ interface RobylonSdkConfig {
63
+ chatbot_id: string;
64
+ user_id: string;
65
+ token?: string;
66
+ user_profile?: {
67
+ email?: string;
68
+ name?: string;
69
+ mobile?: string;
70
+ platform: string;
71
+ OS: string;
72
+ browser: string;
73
+ sdk_version: string;
74
+ };
75
+ }
76
+ export interface ChatbotState {
77
+ isLoading: boolean;
78
+ isInitialized: boolean;
79
+ error: string | null;
80
+ }
81
+ declare global {
82
+ interface Window {
83
+ initializeRobylonSdk: (config: RobylonSdkConfig) => void;
84
+ }
85
+ }
86
+ export declare enum ProactiveSendTimeType {
87
+ WORKING_HOURS = "WORKING_HOURS",
88
+ ALWAYS = "ALWAYS"
89
+ }
90
+ export declare enum DisplayAttributesType {
91
+ "URL" = "URL"
92
+ }
93
+ export declare enum LogicalConditionType {
94
+ AND = "AND",
95
+ OR = "OR"
96
+ }
97
+ export declare enum ConditionType {
98
+ IS = "IS",
99
+ IS_NOT = "IS_NOT",
100
+ CONTAINS = "CONTAINS",
101
+ DOES_NOT_CONTAIN = "DOES_NOT_CONTAIN",
102
+ STARTS_WITH = "STARTS_WITH",
103
+ ENDS_WITH = "ENDS_WITH"
104
+ }
105
+ export declare enum MessageDisplayType {
106
+ BUTTON = "BUTTON",
107
+ TEXT = "TEXT"
108
+ }
109
+ export interface ContentDisplayAttribute {
110
+ type: DisplayAttributesType;
111
+ value: string;
112
+ condition: ConditionType;
113
+ }
114
+ export interface LogicalConditionAttribute {
115
+ logical_condition: LogicalConditionType;
116
+ }
117
+ export interface ProactiveMessage {
118
+ message_id: string;
119
+ org_id: string;
120
+ name?: string;
121
+ content?: string;
122
+ send_time_type?: ProactiveSendTimeType | string;
123
+ created_by_name?: string;
124
+ updated_by_name?: string;
125
+ updated_at?: string;
126
+ created_at?: string;
127
+ delay?: number;
128
+ content_multiple?: {
129
+ message: string;
130
+ content_id?: string;
131
+ message_display_type?: MessageDisplayType;
132
+ message_bubble_bg?: string;
133
+ url_to_go?: string;
134
+ message_display_attributes: (ContentDisplayAttribute | LogicalConditionAttribute)[];
135
+ }[];
136
+ }
137
+ export {};
@@ -0,0 +1,23 @@
1
+ import { ChatbotConfig } from "../types";
2
+ export declare class ChatbotEmbed {
3
+ private config;
4
+ private logoContainer;
5
+ private iframe;
6
+ private bubblePromptContainer;
7
+ private chatBtnImage;
8
+ constructor(config: ChatbotConfig);
9
+ private onCloseListener;
10
+ private validateDomain;
11
+ private createChatBubblContainer;
12
+ private createMessageBubble;
13
+ private createFloatingButton;
14
+ private loadImage;
15
+ private createIframe;
16
+ private adjustIframeWidth;
17
+ private loadSvgInline;
18
+ private toggleIcon;
19
+ private toggleIframe;
20
+ private closeIframe;
21
+ init(): void;
22
+ }
23
+ export declare const initializeRobylonSdk: (config: ChatbotConfig, setIsInitialized: (value: boolean) => void, setError: (error: string | null) => void) => void;
@@ -0,0 +1 @@
1
+ export declare const getBestFontColor: (backgroundColor: string, contrastThreshold?: number) => string;
@@ -0,0 +1,6 @@
1
+ export declare const generateUUID: () => string;
2
+ export declare const getCookie: (name: string) => string | undefined;
3
+ export declare const setCookie: (name: string, value: string, days: number) => void;
4
+ export declare const getLocalStorage: () => string;
5
+ export declare const getSessionStorage: () => string;
6
+ export declare const getCookies: (isTeachmint: boolean) => any;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Checks if code is running in a browser environment
3
+ */
4
+ export declare const isBrowser: () => boolean;
5
+ /**
6
+ * Gets environment configuration
7
+ */
8
+ export declare const getEnvironmentConfig: () => {
9
+ copilotUrl: string;
10
+ environment: string;
11
+ apiUrl: string;
12
+ };
@@ -0,0 +1,53 @@
1
+ import { ChatbotInterfaceType, LauncherType, WidgetPositionEnums, ProactiveMessage } from "../types";
2
+ interface ChatbotResponse {
3
+ user: {
4
+ token: string;
5
+ user_info: {
6
+ email: string;
7
+ user_id: string;
8
+ name: string;
9
+ };
10
+ org_info: {
11
+ org_id: string;
12
+ org_name: string;
13
+ role: string;
14
+ auth_status: string;
15
+ domain: string;
16
+ brand_config: {
17
+ display_name: string;
18
+ redirect_url: string;
19
+ colors?: {
20
+ brand_color: string;
21
+ title_bar_color?: string;
22
+ };
23
+ launcher_logo_url?: string;
24
+ welcome_message: string;
25
+ image_url: string;
26
+ interface_properties: {
27
+ position: WidgetPositionEnums;
28
+ side_spacing: number;
29
+ bottom_spacing: number;
30
+ };
31
+ interface_type: ChatbotInterfaceType;
32
+ launcher_type: LauncherType;
33
+ launcher_properties: {
34
+ text: string;
35
+ };
36
+ images: {
37
+ launcher_image_url: {
38
+ url: string;
39
+ };
40
+ };
41
+ proactive_message_obj?: ProactiveMessage | ProactiveMessage[];
42
+ launcher_delay: {
43
+ enabled: boolean;
44
+ delay: number;
45
+ };
46
+ launcher_size_multiplier?: number;
47
+ };
48
+ show_launcher: boolean;
49
+ };
50
+ };
51
+ }
52
+ export declare const fetchChatbotConfig: (chatbotId: string, userId: string | null | number, token?: string) => Promise<ChatbotResponse>;
53
+ export {};
@@ -0,0 +1,11 @@
1
+ import { SystemInfo } from "./systemInfo";
2
+ interface LauncherInfo {
3
+ current_page_url: string;
4
+ browser_language: string;
5
+ browser_version: string;
6
+ os: string;
7
+ referral_url: string;
8
+ system_info?: SystemInfo;
9
+ }
10
+ export declare const getLauncherInfo: () => LauncherInfo;
11
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const logger: {
2
+ log: (...args: any[]) => void;
3
+ error: (...args: any[]) => void;
4
+ warn: (...args: any[]) => void;
5
+ info: (...args: any[]) => void;
6
+ };
@@ -0,0 +1 @@
1
+ export declare function generateUUID(): string;
@@ -0,0 +1 @@
1
+ export declare const originalFetchData: (url: string, payload: any) => Promise<any>;
@@ -0,0 +1,25 @@
1
+ import { ProactiveMessage, MessageDisplayType } from "src/types";
2
+ export declare const hideProactiveForThisPage: () => void;
3
+ export declare const isProactiveHiddenThisPage: () => boolean;
4
+ export declare const setLastClickedProactive: (params: {
5
+ content_string: string | null;
6
+ message_id: string | null;
7
+ content_id: string | null;
8
+ }) => void;
9
+ export declare const getAndClearLastClickedProactive: () => {
10
+ input_id: null;
11
+ content_string: string | null;
12
+ message_id: string | null;
13
+ content_id?: string | null;
14
+ } | null;
15
+ export interface VisibleContent {
16
+ messageId: string;
17
+ contentIndex: number;
18
+ html: string;
19
+ delayMs: number;
20
+ contentId: string | null;
21
+ messageDisplayType: MessageDisplayType;
22
+ messageBubbleBg?: string;
23
+ urlToGo?: string;
24
+ }
25
+ export declare const evaluateProactiveMessages: (messages?: ProactiveMessage[]) => VisibleContent[];
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Sanitizes HTML while preserving emojis and basic inline formatting.
3
+ */
4
+ export declare const sanitizeHtml: (html?: string) => string;
@@ -0,0 +1,12 @@
1
+ export interface SystemInfo {
2
+ platform: string;
3
+ os: string;
4
+ browser: string;
5
+ sdk_version: string;
6
+ device: string;
7
+ screen_size: {
8
+ width: number;
9
+ height: number;
10
+ };
11
+ }
12
+ export declare const getSystemInfo: () => SystemInfo;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Detects if text contains RTL (Right-to-Left) characters
3
+ * Supports Arabic, Hebrew, Persian/Farsi, Urdu, Yiddish, and other RTL scripts
4
+ * @param text - The text to analyze
5
+ * @returns "rtl" if RTL characters are dominant, "ltr" otherwise
6
+ */
7
+ export declare function detectTextDirection(text?: string): 'rtl' | 'ltr';
@@ -0,0 +1,8 @@
1
+ import { ConditionType, DisplayAttributesType } from "src/types";
2
+ type UrlChangeListener = (href: string) => void;
3
+ export declare const getCurrentHref: () => string;
4
+ export declare const buildLocationKey: () => string;
5
+ export declare const subscribeToUrlChanges: (cb: UrlChangeListener) => (() => void);
6
+ export declare const initUrlObserver: () => void;
7
+ export declare const matchCondition: (type: DisplayAttributesType, value: string, condition: ConditionType, href: string) => boolean;
8
+ export {};
@@ -0,0 +1 @@
1
+ export declare const SDK_VERSION: string;
@@ -0,0 +1,17 @@
1
+ import { ChatbotConfig } from "../../types";
2
+ interface ChatWidgetPopupConfig {
3
+ config: ChatbotConfig;
4
+ onCtaClick: () => void;
5
+ }
6
+ export declare class ChatWidgetPopup {
7
+ private popupElement;
8
+ private config;
9
+ constructor(config: ChatWidgetPopupConfig);
10
+ private createTitleBar;
11
+ private createContent;
12
+ private render;
13
+ getElement(): HTMLDivElement;
14
+ update(config: ChatWidgetPopupConfig): void;
15
+ destroy(): void;
16
+ }
17
+ export {};