Skip to main content

Data Model: hbf-core-api

TypeScript types exported from src/datamodel/ and re-exported from src/index.ts. These mirror hbf-core's MongoDB document schemas. Consuming services import these types to stay in sync with the shared domain model.

Overview

All interfaces and enums live in src/datamodel/. They are re-exported wholesale from src/index.ts. There is no runtime validation -- the library trusts that hbf-core returns conformant JSON. Types are cast, not parsed.

Utility Types (src/datamodel/util.ts)

ExportKindPurpose
LanguageCodesenumSupported BCP 47 language codes (en, el, es, pt, pt-br, etc.)
Localized<T>typePartial<Record<LanguageCodes, T>> -- localized variant of any type
PartialBy<T, K>typeMakes specific fields of T optional. Used for create/update forms.
getStringURLSearchParamsfunctionConverts a params object to a URL query string, omitting null/undefined/empty values.

Core Domain Interfaces

Tenant (src/datamodel/tenant.ts)

Maps to hbf-core's Tenant MongoDB document.

Interface/TypePurpose
TenantPrimary bot (tenant) document: id, displayName, organizationId, content, powerups, settings, systemSettings, nluAgents, nlpMap, etc.
TenantUsageDtoUsage stats response: totalChatSessions, totalMessages per tenant.
CoreConfigConvenience type for holding a { baseUrl, token } pair.
ComponentTree / ComponentTreeNodeRecursive tree structure describing the runtime pipeline for a tenant.

Key enums in this file:

EnumValues (selected)
MessagingBackendsFACEBOOK, LOCAL, MICROSOFT_WEB_CHAT, MICROSOFT_TEAMS, VIBER, SLACK, INSTAGRAM, WHATSAPP, ZENDESK, API, ...
EventOriginSuperset of MessagingBackends -- adds ITC (inter-tenant communication).
PowerupFAQS, BROADCASTS, FLOWS, LIVECHAT, ANALYTICS, INTEGRATIONS, BILLING, MONITORING, ...

Organization (src/datamodel/organization.ts)

InterfaceFields
Organizationid, displayName, analytics, users, timezone, image, externalId, dataRetentionPeriod, auditLogsRetentionPeriod

User and Subscriber (src/datamodel/user.ts)

ExportKindPurpose
UserinterfacePlatform user: id, email, fullName, isModerator, tenantRoles, organizationRoles
UserFormtypePartialBy<User, "id"> -- create/update form
SubscriberinterfaceEnd-user (bot subscriber): id, handle, fullName, blackboard, customData, discriminator
SubscriberForminterfaceCreate/update payload for subscribers
TeamsMemberinterfaceMicrosoft Teams user representation
TenantRoleenumHBF_TENANT_ADMIN, HBF_TENANT_EDITOR, HBF_TENANT_VIEWER, HBF_TENANT_LIVE_AGENT, HBF_TENANT_LIVE_AGENT_ADMIN
OrganizationRoleenumHBF_ORG_ADMIN, HBF_ORG_EDITOR, HBF_ORG_VIEWER, HBF_ORG_LIVE_AGENT, HBF_ORG_LIVECHAT_ADMIN, HRWIZ_EMPLOYEE
TenantRolesTabletypeMap<string, Map<string, TenantRole[]>>
OrganizationRolesTabletypeMap<string, OrganizationRole[]>
TenantGrants / OrganizationGrantsenumDeprecated. Use TenantRole / OrganizationRole.

Bot Deployment (src/datamodel/botDeployment.ts)

ExportKindPurpose
BotDeploymentinterfaceDeployment of a bot to a channel: id, handle, platform, scope, settings, isPreview
BotDeploymentFormtypePartialBy<BotDeployment, "id" | "handle">
BotDeploymentScopeenumUSER, SYSTEM
BotDeploymentSettingsinterfacelayout + integration settings + language
BotDeploymentLayoutSettingsinterfacePer-platform look-and-feel settings
BotDeploymentIntegrationSettingsinterfacePer-platform channel integration credentials
Per-platform integration interfacesinterfacesMicrosoftTeamsIntegrationSettings, FacebookIntegrationSettings, SlackIntegrationSettings, ViberIntegrationSettings, WebchatIntegrationSettings, InstagramIntegrationSettings, WhatsAppIntegrationSettings, ZendeskIntegrationSettings

The handle field encodes platform-specific identifiers (e.g. <AZURE_BOT_HANDLE>***<AZURE_TENANT_ID> for Teams, <FB_PAGE_ID> for Facebook).

Chat Session (src/datamodel/chat_session.ts)

ExportKindPurpose
ChatSessionDTOinterfaceFull session read model: messages, intents, liveChats, variables, metadata, CSAT surveys
ChatSessionForminterfaceWrite payload for creating/updating sessions
ChatSessionMessageDTOinterfaceIndividual message read model
ChatSessionMessageForminterfaceIndividual message write payload
ChatSessionCSATSurveyinterfaceCSAT survey result embedded in a session
ChatSessionVariableMappinginterfaceSession variable name/value pair
LiveChatSessionDtointerfaceLive chat sub-session: waitingTime, duration, responseTimes, agents
ChatSessionConversationNodeinterfaceNode traversal record: nodeId + appearances
ChatSessionBatchSetStatusCompletedinterfaceBatch status-update payload: { ids: string[] }
ChatSessionStatusesenumACTIVE, COMPLETED
ChatSessionMessageTypeenumTEXT, POSTBACK, ATTACHMENT, TRIGGER
ChatSessionMessageCategoryenumCOMMON, FEEDBACK, FALLBACK, LIVE_CHAT, BACK
LiveChatSenderenumEND_USER, AGENT
LiveChatEventTypeenum18 values covering the full livechat lifecycle (LIVECHAT_INITIALIZED through LIVECHAT_GENERIC_ERROR)

Broadcast (src/datamodel/broadcast.ts)

ExportKindPurpose
BroadcastinterfaceBroadcast document: label, platform, type, status, choices, elastic
BroadcastForminterfaceCreate/update payload
ResponseBroadcastinterfaceIndividual subscriber response to a broadcast
ResponseBroadcastForminterfaceWrite payload for a broadcast response
BroadcastChoiceinterfaceSingle choice in a poll/quiz broadcast
BroadcastTypesenumMESSAGE, POLL, QUIZ, ANALYTICS_REPORT
BroadcastStatusesenumPENDING, SENDING, WAITING, COMPLETE, INACTIVE, ERROR
BroadcastMethodsenumBATCHES, ONE_SHOT

NLU (src/datamodel/nlu.ts)

ExportKindPurpose
NluAgentinterfaceNLU agent config: name, configuration (type + provider settings), threshold, status
TenantNluAgentinterfaceTenant-scoped agent reference with isPrimary flag
NluAgentFormtypeCreate/update form
NLUDetectionDtointerfaceNLU detection result: triggeredIntentName, score, parameters
NluTypesenumDIALOGFLOW, LUIS, WIT, OPEN_AI, HELVIA_NLU
NLUStatusenumCREATED, OUTDATED, SYNCING, TRAINING, FAILED, READY, INITIALIZING

NLP Pipeline (src/datamodel/nlp.ts)

ExportKindPurpose
NLPPipelineinterfaceBase NLP pipeline document: name, language, type, status, trainCount, nlpService
NLPPipelineFormtypeCreate/update form
NLPPipelineTreeHeaderinterfaceLightweight pipeline reference with variables list
NLPProcessDtointerfaceNLP processing result: matchedCorpus, generatedText, extractedParameters
DialogflowNLP, LuisNLP, HelviaNLP, HelviaGPTinterfacesProvider-specific pipeline extensions
NLPTypeenumLUIS_NLP, OPENAI_NLP, HELVIA_NLP, DIALOGFLOW_NLP, HELVIA_GPT
NLPStatusenumCREATED, OUTDATED, TRAINING, FAILED, READY, INITIALIZING

Integration (src/datamodel/integration.ts)

ExportKindPurpose
IntegrationinterfaceBase integration: id, organizationId, name, type, category
OpenAIIntegration, AzureAIIntegration, GeminiAIIntegrationinterfacesLLM provider configs
OIDCIntegrationinterfaceOIDC authentication integration
AzureBlobStorageKbIntegrationinterfaceAzure Blob KB integration
SharePointKbIntegrationinterfaceSharePoint KB integration (see below)
SharepointSubscriptionInfointerfaceLightweight view of a SharePoint integration's subscription state
IntegrationTypeenumOPENID_AUTHENTICATION, MICROSOFT_DYNAMICS_CRM, OPEN_AI_LLM, AZURE_AI_LLM, ZENDESK_LIVECHAT, GENESYS_LIVECHAT, SHAREPOINT_KB, ...
IntegrationCategoryenumAUTHENTICATION, CRM, KB, TICKETING, LIVECHAT, LLM
OIDCGrantTypeenumAUTHORIZATION_CODE, AUTHORIZATION_CODE_PKCE

SharePointKbIntegration extends Integration:

FieldTypeNotes
tenantIdstringAzure AD tenant
siteUrlstringSharePoint site URL (e.g. https://contoso.sharepoint.com/sites/MySite)
driveNamesstring[]Document library names to sync
webhookKeystring?Webhook validation key
allowedContentTypesstring[]?MIME type filter
webhookSubscriptionIdsRecord<string, string>?Map of driveName to Graph subscription ID
webhookSubscriptionExpiriesRecord<string, string>?Map of driveName to expiry ISO timestamp
deltaLinksRecord<string, string>?Map of driveName to Graph delta link
lastSubscriptionRenewalCheckstring?ISO timestamp of last renewal check
syncManagedMetadataboolean?Enable taxonomy/managed-metadata sync (default true, opt-out via false)
syncRbacPermissionsboolean?Enable per-item RBAC permission sync (default true, opt-out via false)

Knowledge Base (src/datamodel/knowledgeBase.ts)

ExportKindPurpose
KnowledgeBaseinterfaceKB document: name, organization, languages, type, integrationId, status
KnowledgeBaseFormtypePartialBy<KnowledgeBase, "id">
KnowledgeBaseLanguageinterfaceLanguage entry with isPrimary flag
TenantAssociationRefinterface{ tenantId, useGenerative }
KnowledgeBaseTypeenumINTERNAL, INTEGRATION, SHARED

Knowledge Base Article (src/datamodel/knowledgeBaseArticle.ts)

ExportKindPurpose
KnowledgeBaseArticleDtointerfaceArticle read model: id, groupId, ordinal, content[], metadata?, createdAt, updatedAt
KnowledgeBaseArticleFormtypePartialBy<KnowledgeBaseArticleDto, "id">
ArticleContentinterfacePer-language content: languageCode, title?, tags?, body?
ArticleMetadatatypeUnion of provider-specific metadata types (currently SharePointArticleMetadata)
SharePointArticleMetadatainterface{ type: SHAREPOINT_KB, managedMetadata?: ManagedMetadataEntry[], permissions?: SharePointPermissions }
ManagedMetadataEntryinterface{ fieldName, termLabel, termGuid } -- single taxonomy term from a managed metadata column
SharePointPermissionsinterface{ permissionsFetchedAt, sharingLinks: SharingLink[], grants: PermissionGrant[] }
SharingLinkinterface{ scope, type, webUrl, expirationDateTime?, grantedTo?: PermissionGrant[] }
PermissionGrantinterface{ displayName, email?, roles: string[], identityType? }

ArticleMetadata is populated during sync when the corresponding subscription toggles (syncManagedMetadata, syncRbacPermissions) are enabled on the integration.

Analytics (src/datamodel/analytics.ts)

ExportPurpose
AnalyticsSummaryDtoEngagement, sessions, interactions, users stats
AnalyticsLiveChatDtoLive chat usage, missed chats, response/duration times
AnalyticsInterviewsDtoInterview session outcomes
AnalyticsDecisionTreesDtoDecision tree traversal counts
AnalyticsAutomatedAnswersDtoAutomated answer usage counts
AnalyticsMissedQuestionsDtoMissed NLU questions + histogram
AnalyticsUserFeedbackDtoFeedback scores per bot/livechat/agent
AnalyticsCSATDtoCSAT overall + section scores + overtime
TenantFilterDtoAnalytics filter: tenant + optional deployment list
AnalyticsTypesenum: SUMMARY, LIVE_CHAT, INTERVIEWS, DECISION_TREES, AUTOMATED_ANSWERS, USER_FEEDBACK, MISSED_QUESTIONS, CSAT

Other Datamodel Files

FileKey exports
src/datamodel/handover.tsHandoverLinkDTO, HandoverLinkForm, HandoverStatuses enum (PENDING, ACTIVE, COMPLETED, MISSED, DECLINED)
src/datamodel/fb_handover.tsFacebook-specific handover types
src/datamodel/messaging_app.tsPer-platform app configuration interfaces (FacebookAppConfiguration, SlackAppConfiguration, etc.)
src/datamodel/tenantSettings.tsTenantSettings, TenantSystemSettings, TenantSecuritySettings (OIDC + pre-auth config), PreAuthTokenProvider (name, aud, jwksUri, refreshTokenEndpoint), TenantSecurityOidcSettings, and nested settings interfaces
src/datamodel/subscription_plan.tsSubscriptionPlan, Subscription
src/datamodel/stats.tsStats ({ lastStatsUpdate, data })
src/datamodel/survey.tsSurvey
src/datamodel/group.tsGroup
src/datamodel/userGroup.tsUserGroup
src/datamodel/blackboard.tsBlackboard (session context) types
src/datamodel/effects.tsConversation effect types
src/datamodel/plugin.tsPlugin<T> integration plugin types
src/datamodel/translation.tsTranslation types
src/datamodel/knowledgeBaseArticle.tsKnowledgeBaseArticleDto, ArticleMetadata, SharePointArticleMetadata (see below)
src/datamodel/knowledgeBaseGroup.tsKnowledgeBaseGroup
src/datamodel/audit_log.tsAuditLog, CreatedByDto
src/datamodel/botContent.tsExports 50+ types including ConversationNode, Activity, ActivityCompiled, BotContent, BotContentCompiled, and various Response types. Referenced by all bot-content-related operations.

Request/Response Pattern

hbf-core list endpoints return:

{ "items": [...], "page": 1, "pageSize": 20, "total": 150 }

HBFCoreApiResponse.getList<T>() reads .items. Consumers call TenantsClient.listPaged() for multi-page iteration.

hbf-core create endpoints return the created ID either in the Location response header (/{resource}/{id}) or in the body as { id: string }. HBFCoreApiResponse.getSavedId(resource) handles both.

Relationship to MongoDB

These interfaces model hbf-core's MongoDB documents directly. There is no ORM mapping -- hbf-core serializes its Spring Data MongoDB documents to JSON, and this library deserializes that JSON into the typed interfaces listed above. Field names use camelCase to match hbf-core's JSON serialization output.