import { BotMessage, ChatCitation, SearchHit, SearchInput, UserIdentificationType as UserIdentificationAPIEnum, UserType as UserTypeAPIEnum, WebWidgetInteractionType as IntegrationTypeAPIEnum } from '../__generated__/graphql'; import { MessageArray, MessageTypename } from './AIChat/AIChatPage/AIChatPage'; import { FeedbackFromForm } from './AIChat/AIChatPage/Feedback/ChatMessageFeedbackForm'; import { ChatMode } from './InkeepWidgetProps'; export interface UserProps { userId?: string; userType?: UserType; userIdentificationType?: UserIdentification; userCohorts?: string[]; userEmail?: string; } export type UserType = `${UserTypeAPIEnum}`; export type UserIdentification = `${UserIdentificationAPIEnum}`; export interface GroupProps { [key: string]: any; organizationId?: string; } export interface ChatSessionProperties { chatSessionId: string | null; chatMode: ChatMode; filters: any; } export interface WidgetWebClientProps { widgetLibraryVersion: string; isModalModeSwitchingEnabled: boolean; chatModeComponentDefault: string; isChatModeToggleEnabled: boolean; chatModeCurrentlySelected: string | null; modalViewComponentDefault: string; modalViewCurrentlySelected: string | null; sharedChatSessionId?: string | null; interactionType: InteractionType; } export type InteractionType = `${IntegrationTypeAPIEnum}`; export interface AIChatMessageSubmittedEvent { eventName: 'chat_message_submitted'; properties: { chatSessionId: string | null; content: string; prefilledAutoSubmitted: boolean; tags: string[]; workflowId?: string; }; } export interface AIChatBotResponseReceivedEvent { eventName: 'chat_message_bot_response_received'; properties: { chatSessionId: string | null; question: string; responseMessage: BotMessage; elapsedTimeToStartStreamedResponse: number; elapsedTimeToCompleteStreamedResponse: number; numberOfCitationsUsedInResponse: number; citationsUsedInResponse: ChatCitation[]; workflowId?: string; }; } export interface AIChatSharedSessionLoadedEvent { eventName: 'chat_shared_session_loaded'; properties: { sharedChatSessionId: string; }; } export interface AIChatSharedSessionContinuedEvent { eventName: 'chat_shared_session_continued'; properties: { sharedChatSessionId: string; newChatSessionId: string; }; } export interface SearchQuerySubmittedEvent { eventName: 'search_query_submitted'; properties: { query: string; }; } export interface SearchQueryResponseReceivedEvent { eventName: 'search_query_response_received'; properties: { query: string; totalHits: number; }; } export interface AIChatThumbsUpFeedbackSubmittedEvent { eventName: 'chat_thumbs_up_feedback_submitted'; properties: { chatSessionAllMessages: MessageArray; chatSessionId: string; question: string; answer: string; answerId: string; workflowId?: string; }; } export interface AIChatThumbsDownFeedbackSubmittedEvent { eventName: 'chat_thumbs_down_feedback_submitted'; properties: FeedbackFromForm & { chatSessionAllMessages: MessageArray; chatSessionId: string; question: string; answer: string; answerId: string; workflowId?: string; }; } export interface AIChatHistoryClearedEvent { eventName: 'chat_history_cleared'; properties: { chatSessionId: string | null; }; } export interface AIChatShareButtonClickedEvent { eventName: 'chat_share_button_clicked'; properties: { sharedChatUrl: string; chatSessionId: string; }; } export interface AIChatMessageCopiedEvent { eventName: 'chat_message_copied'; properties: { chatSessionId: string; messageId: string; authorType: MessageTypename | null; }; } export interface CodeBlockCopiedEvent { eventName: 'chat_code_block_copied'; properties: { chatSessionId: string | null; }; } export interface SearchResultClickedEvent { eventName: 'search_result_clicked'; properties: { searchQuery: string; searchInput: SearchInput; clickedHitPosition: number; clickedHitId: string; clickedHitRootRecordId: string; clickedHitType: string; viewableResults: [SearchHit]; viewableResultsRootRecordIds: [string]; tabResultType: string; defaultTabType: string; }; } export interface SearchResultUpvote { eventName: 'search_result_upvote'; properties: { searchQuery: string; searchInput: SearchInput; upvotedHitPosition: number; upvotedHitId: string; upvotedHitRootRecordId: string; upvotedHitType: string; viewableResults: [SearchHit]; viewableResultsRootRecordIds: [string]; tabResultType: string; defaultTabType: string; }; } export interface SearchResultDownvote { eventName: 'search_result_downvote'; properties: { searchQuery: string; searchInput: SearchInput; downvotedHitPosition: number; downvotedHitId: string; downvotedHitRootRecordId: string; downvotedHitType: string; viewableResults: [SearchHit]; viewableResultsRootRecordIds: [string]; tabResultType: string; defaultTabType: string; }; } export interface CallToActionClickedEvent { eventName: 'call_to_action_clicked'; properties: { mode: 'chat' | 'search'; chatSessionId: string; query: string; }; } export interface AIChatRevisedAnswerSubmittedEvent { eventName: 'chat_revised_answer_submitted'; properties: { chatSessionAllMessages: MessageArray; chatSessionId: string; question: string; answer: string; revisedAnswer: string; originalAvailableCitations: ChatCitation[]; originalUsedCitations: ChatCitation[]; newSelectedCitations: ChatCitation[]; netNewCitations: ChatCitation[]; deselectedCitations: ChatCitation[]; }; } export interface AIChatBotHadInsufficientKnowledgeEvent { eventName: 'chat_bot_had_insufficient_knowledge'; properties: {}; } export interface AIChatResponseCitationClickedEvent { eventName: 'chat_response_citation_clicked'; properties: { citation: ChatCitation | undefined; chatSessionId: string; messageId: string; displayOrder: number; citationType: 'CARD' | 'INLINE'; }; } export interface ModalModeSwitchedEvent { eventName: 'modal_mode_switched'; properties: {}; } export interface AISharedChatLoadedEvent { eventName: 'shared_chat_loaded'; properties: {}; } export type InkeepEvent = AIChatBotHadInsufficientKnowledgeEvent | AIChatBotResponseReceivedEvent | AIChatHistoryClearedEvent | AIChatMessageCopiedEvent | AIChatMessageSubmittedEvent | AIChatResponseCitationClickedEvent | AIChatRevisedAnswerSubmittedEvent | AIChatShareButtonClickedEvent | AIChatSharedSessionContinuedEvent | AIChatSharedSessionLoadedEvent | AIChatThumbsDownFeedbackSubmittedEvent | AIChatThumbsUpFeedbackSubmittedEvent | AISharedChatLoadedEvent | CallToActionClickedEvent | CodeBlockCopiedEvent | ModalModeSwitchedEvent | SearchQueryResponseReceivedEvent | SearchQuerySubmittedEvent | SearchResultClickedEvent; export type InkeepCallbackEvent = InkeepEvent & { commonProperties: ChatSessionProperties & GroupProps & UserProps & WidgetWebClientProps; };