import { AccountUsages, CompletionModel, DcChatbot, DcChatbotLean, DcChatbotStatus, DcDocument, OrganizationData, OrganizationUser, User, UserDocument, } from "../CommonTypes"; import { ChatBotAnalyticsData } from "../CommonTypes/AnalyticsData.js"; import { AnalyticsReportStatus } from "../CommonTypes/AnalyticsReportStatus"; import { EnforceDataResidencyError } from "../CommonTypes/EnforceDataResidencyError"; import { PlanData } from "../CommonTypes/PlanData"; import { SessionData } from "../CommonTypes/SessionData.js"; export interface ResponseBase {} export namespace ResTypes { export interface DoesUserExistResponse extends ResponseBase { exists: boolean; correctedEmail: string; } export interface CreateChatBotResponse extends ResponseBase { chatbotId: string; } export interface EditChatBotResponse extends ResponseBase { afterEditChatBot: DcChatbot; } /** * Answer for this kind of response will be provided in a stream * @see StreamableData */ export interface QueryChatBotResponse extends ResponseBase {} export interface GetChatBotsResponse extends ResponseBase { chatbots: DcChatbot[]; publicChatbotIds: string[]; favoriteChatbotIds: string[]; userChatbotIds: string[]; organizationChatBotIds: string[]; pagination: { page: number; pageSize: number; totalCount: number; totalPages: number; hasNextPage: boolean; hasPreviousPage: boolean; }; } export interface GetChatbotResponse extends ResponseBase { chatbot: DcChatbot; } export interface InitChatResponse extends ResponseBase { sessionId: string; } export interface GetChatBotDocumentsResponse extends ResponseBase { documents: DcDocument[]; } export interface GetUserDocumentsResponse extends ResponseBase { documents: UserDocument[]; } export interface GetChatBotForChatResponse extends ResponseBase { chatbot: DcChatbotLean; } export interface DeleteChatBotResponse extends ResponseBase {} export interface UpdateChatBotFavoriteStatusResponse extends ResponseBase {} export interface GetChatBotIdAndStatusesForUserResponse { idAndStatuses: { id: string; status: DcChatbotStatus; }[]; } export interface GetDocumentIdAndStatusesForUserResponse { idAndStatuses: { id: string; status: DcChatbotStatus; }[]; } export interface GetUserInfoResponse extends ResponseBase { user: User; organizationData: OrganizationData; accountUsages: AccountUsages; planData: PlanData; /** * If this is a plan which doesn't have a payment (i.e. admin, expired, free) this will be null. Otherwise, this will be the date when the plan will renew * In case the plan is cancelled but still active, this will be the date when the plan would have been renewed */ planPaymentCycleEndsAt?: Date; planWillRenew: boolean; } export interface SetCompletedOnBoardingResponse extends ResponseBase {} export interface SignupResponse extends ResponseBase {} export interface SendResetPasswordEmailResponse extends ResponseBase {} export interface IsPasswordResetTokenValidResponse extends ResponseBase {} export interface ResetPasswordResponse extends ResponseBase {} export interface UpsertOrganizationUserResponse extends ResponseBase { credentials: { userName: string; password: string; }[]; } export interface SetOrganizationDataResponse extends ResponseBase {} export interface ChangeOranizationUserRoleResponse extends ResponseBase {} export interface GetOrganizationUsersResponse extends ResponseBase { users: OrganizationUser[]; } export interface CreateUserForExternalSignupResponse extends ResponseBase {} export interface GetChatBotForEmbedResponse extends ResponseBase { chatbot: DcChatbotLean; } export interface GetChatBotVisibleUrlResponse extends ResponseBase { visibleUrl: string[]; widgetUrl?: string; } export interface AddDocumentsResponse extends ResponseBase { documentIds: string[]; } export interface DeleteDocumentsResponse extends ResponseBase {} export interface RenameDocumentsResponse extends ResponseBase {} export interface DownloadDocumentResponse extends ResponseBase { fullFileName: string; contentBase64: string; } export interface SigninWithPasswordResponse extends ResponseBase { userId: string; } export interface GetPlansResponse extends ResponseBase { plans: PlanData[]; } export interface GetAccountUsagesResponse extends ResponseBase { usage: AccountUsages; } export interface UpdatePlanResponse extends ResponseBase { redirectUrl: string; } export interface GetBillingPortalUrlResponse extends ResponseBase { redirectUrl: string; } /** * Cancels the renewal upon the next billing date, if the user has a subscription */ export interface CancelSubscriptionResponse extends ResponseBase {} export interface RateAnswerResponse extends ResponseBase {} export interface GetChatbotSessionsResponse extends ResponseBase { sessions: SessionData[]; } export interface GetChatbotAnalyticsResponse extends ResponseBase { years: { /** * i.e: 2023, 2024 */ year: number; months: { /** * zero base index, i.e. 0 is January */ monthNumber: number; analytics: ChatBotAnalyticsData[]; }[]; }[]; } export interface UpsertAzureOpenAiCredentialsResponse extends ResponseBase {} export interface GetAzureOpenAiCredentialsResponse extends ResponseBase { credentials: { maskedKey: string; endpoint: string; model: CompletionModel; }[]; } export interface EditChatBotShareOptionsResponse extends ResponseBase {} export interface EditChatbotLimitsOptionsResponse extends ResponseBase {} export interface EditChatbotVisibleResponse extends ResponseBase {} export interface EditChatbotWidgetUrlResponse extends ResponseBase {} export interface DuplicateChatbotResponse extends ResponseBase { chatbotId: string; } export interface EnforceDataResidencyResponse extends ResponseBase { succesfullyModified: boolean; failureReasons: EnforceDataResidencyError[] } export interface GetOrganizationCssByChatBotIdResponse extends ResponseBase{ customCss: string; } export interface UpsertGoogleDriveIntegrationResponse extends ResponseBase {} export interface RemoveGoogleDriveIntegrationResponse extends ResponseBase{} export interface SetCTAUsedInSessionResponse extends ResponseBase{} export interface SendDeleteAccountEmailResponse extends ResponseBase{} export interface SynchronizeGoogleDriveFoldersResponse extends ResponseBase{ result: { folderDocFileId: string; success: boolean; error?: string; }[]; } export interface ModifyChatSessionContextResponse extends ResponseBase{} export interface GetCompletionModelsResponse extends ResponseBase{ models: { id: CompletionModel; company: string; label: string; creditPerQuestion: number; grade_intelligence: number; grade_speed: number; grade_cost_efficiency: number; eu_resident: boolean; }[] } export interface GenerateApiKeyResponse extends ResponseBase{ apiKey: string; } export interface RevokeApiKeyResponse extends ResponseBase{} export interface GetSessionResponse extends ResponseBase{ session: SessionData; chatbot: DcChatbot; messages: ChatMessage[]; } export interface GetMaskedApiKeyResponse extends ResponseBase{ maskedApiKey: string; expiresAt: Date; } export interface GetChatBotAndSessionBySessionIdResponse extends ResponseBase{ chatbot: DcChatbot; session: SessionData; } export interface GenerateAnalyticsReportResponse extends ResponseBase{ analyticsReportId: string; } export interface ListAnalyticsReportsResponse extends ResponseBase{ analyticsReports: { id: string; requestedAt: Date; status: AnalyticsReportStatus; completedAt?: Date; }[]; } export interface GetAnalyticsReportResponse extends ResponseBase{ report: { id: string; startDate: Date; endDate: Date; requestedAt: Date; completedAt: Date; }, sourceUsage: { docFileId: string; docFileName: string; docFileUrl: string | null; usedTimes: number; sourceRatedUpTimes: number; sourceRatedDownTimes: number; }[]; mostAskedQuestions: { questions: string[]; askedCount: number; }[]; unansweredQuestions: string[]; } export interface GetChatBotPermissionsResponse extends ResponseBase { userPermissions: Array<{ userId: string; email: string; fullName: string; organizationRole: string | null; chatbotAccessLevel: string | null; }>; } export interface UpdateChatBotPermissionsResponse extends ResponseBase { success: boolean; message: string; } export interface GetOverviewResponse extends ResponseBase { summary: { totalChatbots: number; totalSessions: number; totalMessages: number; totalFeedbacks: number; averageHandlingTime: number; totalUsers: number; }; userDemographics: { totalUsers: number; usersByCountry: Array<{ country: string; count: number; percentage: number; }>; usersByDeviceType: Array<{ deviceType: string; count: number; percentage: number; }>; usersByBrowserType: Array<{ browserType: string; count: number; percentage: number; }>; }; topPerformingChatbots: Array<{ chatBotId: string; chatbotName: string; totalSessions: number; totalMessages: number; feedbacks: { total: number; ratedUp: number; ratedDown: number; numberOfIsNotTrue: number; numberOfIsNotHelpful: number; numberOfHasInconsistentLanguage: number; }; averageHandlingTime: number; ctaClickRate: number; }>; mostActiveChatbots: Array<{ chatbotId: string; chatbotName: string; recentSessions: number; lastActivity: string | null; }>; recentActivity: Array<{ chatbotId: string; chatbotName: string; recentSessions: number; lastActivity: string | null; }>; detailedAnalytics: { years: Array<{ year: number; months: Array<{ monthNumber: number; analytics: Array<{ chatBotId: string; chatbotName: string; totalSessions: number; totalMessages: number; feedbacks: { total: number; ratedUp: number; ratedDown: number; numberOfIsNotTrue: number; numberOfIsNotHelpful: number; numberOfHasInconsistentLanguage: number; }; averageHandlingTime: number; ctaClickRate: number; }>; }>; }>; userDemographics: { totalUsers: number; usersByCountry: Array<{ country: string; count: number; percentage: number; }>; usersByDeviceType: Array<{ deviceType: string; count: number; percentage: number; }>; usersByBrowserType: Array<{ browserType: string; count: number; percentage: number; }>; detailedData: any; }; }; } export interface GetTestimonialSubmissionsResponse extends ResponseBase { submissions: { id: string; platform: string; reward: string | null; testimonialText: string | null; submittedAt: Date; rewardApplied: boolean; appliedAt: Date | null; notes: string | null; }[]; } export interface CreateTestimonialSubmissionResponse extends ResponseBase { submission: { id: string; platform: string; reward: string | null; testimonialText: string | null; submittedAt: Date; rewardApplied: boolean; appliedAt: Date | null; notes: string | null; }; } export interface GetPaymentProvidersResponse extends ResponseBase { paymentProviders: { id: string; name: string; enabled: boolean; }[]; } } interface ChatMessage{ question: string; answer: string; questionAskedAt: Date; answerSentAt: Date; sources: { docFileId: string; content: string; name: string; contentType: string; url?: string; googleDrive?: { /** * The id of the folder in Google Drive */ parentFolderGoogleDriveId: string; parentFolderGoogleDriveURL: string; /** * The id of the folder in our system */ parentFolderDocFileId: string; parentFolderName: string; } } }