Skip to content

Haravan Helpdesk Data Model

Updated: 2026-05-09

Purpose

This document describes key entities and fields for Helpdesk operations, and links script ownership to the canonical script catalog.

Canonical script source of truth: /docs/haravan/ticket-customer-enrichment

Core Entities

  • HD Ticket: ticket lifecycle, enrichment snapshots, route fields, assignment target.
  • HD Customer: organization-level customer profile and Bitrix sync anchor.
  • Contact: person-level identity linked to tickets/customers.
  • Haravan Account Link: identity link between user and Haravan organization.
  • HD Customer Data: external enrichment snapshots (mainly Bitrix).

Script Ownership by Group

GroupMain EntityTypical Responsibilities
IntakeHD TicketCreate tickets from onboarding or agent-side dialogs.
ValidationHD TicketNormalize incoming values without blocking ticket creation.
EnrichmentHD Ticket, HD CustomerResolve orgid/domain and sync customer profile data.
RoutingHD TicketSet/normalize routing fields and agent_group.
AssignmentHD TicketApply assignment rule outcomes to team/agent flow.
ProfileHD Ticket, HD Customer, ContactManual/deep profile sync actions.
IntegrationHD Ticket + external systemsGitLab and automation integrations.
DebugAnyNon-production diagnostics and replay snapshots.

Status Policy

  • Active: used in production runtime.
  • Debug: diagnostics only.
  • Not use: intentionally disabled, kept for traceability.
  • Legacy: historical/migration references.

Field Contracts (Routing + Enrichment)

Important HD Ticket fields for script interaction:

  • customer
  • custom_orgid
  • custom_store_url
  • custom_myharavan_domain
  • custom_customer_segment
  • custom_current_shopplan
  • custom_partner_service
  • custom_customer_lifetime_months
  • agent_group

Legacy fallback-only fields:

  • custom_haravan_profile_orgid
  • custom_my_haravan_domain
  • custom_haravan_myharavan_link
  • custom_haravan_shop_link

Naming Governance

  • Production script names must follow <Type> - <Group> - <Purpose>.
  • Debug script names must follow Debug - {group} - {name}.
  • Any deactivated script must be marked as Not use in the canonical catalog.
  • /docs/haravan/ticket-customer-enrichment
  • /docs/haravan/ticket-workflow-review-summary
  • /docs/haravan/gitlab-assignee-routing-handover

title: Haravan Helpdesk Data Model description: Field guide for AI agents working with haravan.help Frappe Helpdesk data. keywords: haravan.help, frappe helpdesk, hd ticket, hd customer, data model robots: noindex, nofollow

Haravan.help Helpdesk Data Model

This document helps AI agents understand how the production site haravan.help stores Helpdesk data for tickets, customers, contacts, Haravan identities, and Bitrix enrichment.

Operational Snapshot (2026-05-08)

  • Ticket - Auto Customer Sync From OrgID is enabled (After Save) and is the primary automatic enrichment path.
  • Ticket - Normalize Enrichment Routing After Save is enabled (After Save) to keep enrichment/routing fields consistent after late updates.
  • Ticket - Auto Customer Sync Kickoff After Insert is currently disabled.
  • Legacy gate/early enrichment scripts are disabled: Ticket - Require Customer Or Store URL, Ticket - Store URL Enrich.
  • Routing and round-robin scripts are currently disabled: Profile - Ticket Routing, Profile - Ticket Round Robin Assignment.
  • End-to-end workflow and current script status are documented in docs/haravan/ticket-customer-enrichment.md.

The site is a Frappe Helpdesk instance extended by the custom app login_with_haravan. Do not modify Frappe core or Helpdesk core. Use custom fields, hooks, Server Scripts, Form Scripts, and the custom DocTypes from this app.

Data Flow Summary

  1. Customer signs in with Haravan OAuth.
  2. login_with_haravan.oauth.login_via_haravan normalizes the Haravan profile.
  3. The app upserts:
    • User
    • Contact
    • HD Customer
    • Haravan Account Link
  4. Customer creates a Helpdesk ticket in /helpdesk/my-tickets/new.
  5. Ticket is stored as HD Ticket, linked to HD Customer through customer.
  6. Agent-side customer profile can enrich HD Customer, Contact, and ticket fields from Bitrix on demand.

Core Relationships

HD Ticket

HD Ticket is the primary support ticket DocType from Frappe Helpdesk. The native Helpdesk fields are owned by the upstream app; the custom fields below are the fields this project expects or manages.

Important Native Fields

FieldnameTypeDescription
nameDataTicket document ID, often displayed as the ticket number.
subjectDataCustomer-visible issue title.
descriptionText / EditorMain customer issue description. Treat as user-generated content.
statusLink / SelectTicket status used by Helpdesk workflows and list filters.
priorityLink / SelectTicket priority.
ticket_typeLink / SelectHelpdesk ticket type/category when configured.
customerLink -> HD CustomerThe merchant/store/account that owns the ticket. This is the key field for org-level context.
contactLink -> ContactContact person linked to the ticket.
raised_byDataEmail/user that raised the ticket. Used as fallback to find Contact.
agent_groupLink -> HD TeamTeam assignment. Routing scripts can set this from customer segment.
agentLink -> UserAssigned support agent when Helpdesk assignment is used.
creationDatetimeTicket creation timestamp.
modifiedDatetimeLast modification timestamp.

Project Custom Fields On HD Ticket

FieldnameTypeDescription
custom_cc_emailsSmall TextTicket-level CC list. Emails are comma-separated. Used by HDTicketCCMixin to merge CC recipients into acknowledgement and agent reply emails.
custom_responsibleDataEmail of the responsible person resolved from Bitrix user.get by ASSIGNED_BY_ID. Read-only in the app metadata.
custom_product_suggestionLink / DataProduct suggestion used by Helpdesk/GitLab automation. Customer portal template keeps it optional; agent workflows may still require it.
custom_internal_typeSelect / DataInternal ticket classification. When value is Onboarding Service, service-related internal fields become relevant.
custom_service_groupSelectInternal service group for onboarding-service tickets. Hidden from customers in the ticket template.
custom_service_nameSelectInternal service name for onboarding-service tickets. Hidden from customers.
custom_service_lineSelectInternal service line for onboarding-service tickets. Hidden from customers.
custom_service_onboarding_phraseSelectInternal onboarding phrase/stage for service tickets. Hidden from customers.
custom_service_pricingCurrencyInternal service price. Hidden from customers.
custom_service_transaction_idDataInternal payment/transaction reference for service tickets. Hidden from customers.
custom_service_vendorSelectInternal service provider/vendor. Hidden from customers.
custom_service_payment_statusSelectInternal payment status. Hidden from customers.
custom_orgidDataCanonical Haravan org ID cached on ticket by production scripts. Used by Bitrix routing/profile scripts.
custom_haravan_profile_orgidDataHidden legacy Org ID mirror. Read only as fallback for old tickets; new enrichment writes should use custom_orgid.
custom_customer_segmentSelect / DataCustomer segment: SME, Medium, or Enterprise. Copied from HD Customer.custom_customer_segment when available, otherwise resolved from Bitrix enum/fallback enrichment rules.
custom_haravan_profile_statusDataBitrix profile lookup status, for example Complete, Skipped, Missing OrgID, or API Error.
custom_haravan_profile_errorSmall Text / TextLast profile lookup/routing error message.
custom_haravan_profile_checked_atDatetimeLast timestamp when profile/routing script checked the ticket.
custom_haravan_service_planDataCurrent Haravan service/shop plan from Bitrix.
custom_current_shopplanDataSnapshot of current shopplan at ticket creation time (from HD Customer.custom_shopplan_name / Bitrix feed). Nullable, read-only.
custom_partner_serviceDataSnapshot partner/service routing key from Bitrix/Make at ticket creation time. Nullable, read-only.
custom_customer_lifetime_monthsIntSnapshot months from HD Customer.custom_first_paid_date (create-time snapshot; may be refreshed by consistency script after late enrichment events).
custom_shopplanSelect / DataNormalized shop plan bucket such as SME, Medium Grow, or Medium Scale.
custom_haravan_hsi_segmentDataHSI segment from Bitrix company fields.
custom_haravan_routing_reasonSmall Text / TextHuman-readable reason for automatic team routing.

Notes:

  • customer is intentionally visible in the customer ticket template so the portal can choose the correct Haravan organization.
  • custom_cc_emails is hidden from customer portal templates and mainly for agent-created tickets/replies.
  • Service/onboarding fields are internal. Do not expose them in customer-facing UI unless the product requirement explicitly changes.

HD Customer

HD Customer is the Helpdesk-native customer/account entity. For Haravan, one HD Customer normally represents one Haravan organization/store.

Important Native Fields

FieldnameTypeDescription
nameDataDocument ID. In this app it usually follows "{orgname} - {orgid}".
customer_nameDataDisplay name. The app writes "{orgname} - {orgid}".
domainDataStore domain. The app defaults to "{orgid}.myharavan.com" when only org ID is known.
imageAttach ImageOptional customer image/logo if present in Helpdesk.
creationDatetimeCustomer creation timestamp.
modifiedDatetimeLast modification timestamp.

Project Custom Fields On HD Customer

FieldnameTypeDescription
custom_haravan_orgidIntPrimary Haravan organization ID. This is the deterministic lookup key for avoiding duplicate HD Customer records.
custom_myharavanDataMyHaravan domain, usually "{orgid}.myharavan.com".
custom_bitrix_company_idDataMatched Bitrix company ID.
custom_bitrix_company_urlDataDirect URL to the matched Bitrix company.
custom_bitrix_match_confidencePercentConfidence score for the Bitrix match. The app commonly writes 90 or 95.
custom_bitrix_sync_statusDataBitrix sync status, for example matched or not_found.
custom_bitrix_last_synced_atDatetimeLast time company/contact data was synced from Bitrix.
custom_bitrix_last_checked_atDatetimeLast time production metajson/org lookup checked Bitrix, even if no company was found.
custom_bitrix_company_modified_atDatetimeBitrix company modification timestamp when provided by the Bitrix API.
custom_bitrix_not_found_atDatetimeLast time Bitrix lookup did not find a matching company.
custom_customer_segmentSelect / DataCustomer segment used by routing: SME, Medium, or Enterprise.

Notes:

  • Lookup priority should be custom_haravan_orgid first, then exact name.
  • Do not create a competing custom organization DocType for ticket ownership; HD Customer is the canonical Helpdesk entity.
  • custom_customer_segment may exist from production Server Scripts even if it is not declared directly in this app's install hook. The current live segment rule prefers the existing customer value, then Bitrix UF_CRM_1778130421650 mapping (15090 -> SME, 15092 -> Medium, 15094 -> Enterprise), then falls back to Medium for HSI HSI_500+ / 500+ or shopplan Grow / Scale; otherwise it resolves SME.

Contact

Contact is the Frappe contact person entity. It is upserted from Haravan login data when an email exists.

FieldnameTypeDescription
nameDataContact document ID.
first_nameDataName from Haravan profile, or email prefix fallback.
middle_nameDataOptional Haravan middle name.
email_idDataPrimary email. Used to match existing contacts.
phoneDataPhone number if present or later enriched.
mobile_noDataMobile number if present or later enriched.
linksChild TableDynamic Links. Owner/admin Haravan users are linked to HD Customer; staff are not linked for org-wide visibility.
custom_bitrix_contact_idDataMatched Bitrix contact ID.
custom_bitrix_contact_urlDataDirect URL to the matched Bitrix contact.
custom_bitrix_last_synced_atDatetimeLast Bitrix contact sync timestamp.

Visibility rule:

  • Haravan roles owner and admin get a Contact.links row to HD Customer, allowing org-level ticket visibility.
  • Staff or other roles do not get the org-wide HD Customer contact link, so they should see only their own tickets in portal behavior.

Custom DocType from this app. It stores the durable mapping between a Frappe user, a Haravan user, and a Haravan organization.

Autoname is method-based in the controller. Treat records as upserted identity links, not as free-form CRM records.

FieldnameTypeRequiredDescription
userLink -> UserYesFrappe user account.
emailDataYesUser email from Haravan/Frappe.
last_loginDatetimeNoLast successful Haravan OAuth login timestamp.
haravan_useridDataYesHaravan user ID.
haravan_orgidDataYesHaravan organization ID.
haravan_orgnameDataNoHaravan organization/store name.
haravan_orgcatDataNoHaravan organization category from profile claims.
haravan_rolesSmall TextNoHaravan role list serialized as text.
raw_profileCode / JSONNoRaw normalized login profile for troubleshooting. Contains identity data; avoid exposing broadly.
hd_customerLink -> HD CustomerNoHelpdesk customer created or matched for this org.

HD Customer Data

Custom DocType from this app. It stores external data snapshots, mainly from Bitrix company/contact enrichment.

Autoname format:

text
BTRX-{entity_type}-{external_id}
FieldnameTypeRequiredDescription
hd_customerLink -> HD CustomerYesCustomer/account that the external entity belongs to.
contactLink -> ContactNoRelated contact, when the external snapshot is contact-specific.
sourceDataYesExternal source name. Default is bitrix.
entity_typeSelectYesExternal entity type. Allowed values: company, contact.
external_idDataYesID in the external system.
external_urlDataNoDirect URL to the external record.
match_keyDataNoMatching strategy, for example domain_or_haravan_orgid or email_or_phone.
confidencePercentNoMatch confidence.
last_synced_atDatetimeNoLast sync timestamp.
summary_jsonCode / JSONNoJSON snapshot returned by the external API. May contain operational CRM data.

Helpdesk Integrations Settings

This is a Helpdesk settings DocType extended with Bitrix configuration fields. These fields are configuration, not ticket/customer business data.

FieldnameTypeDescription
bitrix_customer_api_sectionSection BreakUI grouping for customer/company API settings.
bitrix_enabledCheckEnables or disables Bitrix customer/company profile lookup.
bitrix_webhook_urlPasswordInbound webhook URL used server-side for Bitrix crm.company.*. Never expose to browser or docs with real secret.
bitrix_responsible_api_sectionSection BreakUI grouping for responsible-user API settings.
bitrix_responsible_webhook_urlPasswordInbound webhook URL used server-side for Bitrix user.get. Never expose the real value.
bitrix_portal_urlDataBitrix portal base URL used to build record links.
bitrix_timeout_secondsIntTimeout for Bitrix API calls. Default in metadata is 15.
bitrix_refresh_ttl_minutesIntCache/refresh TTL. Default in metadata is 60.

Agent Operating Rules

  • Use Frappe APIs or REST resource APIs. Avoid raw SQL unless there is no safer ORM path.
  • If raw SQL is required, use parameterized queries only.
  • Log server-side exceptions with frappe.log_error(), not frappe.logger.
  • API responses should follow:
json
{"success": true, "data": {}, "message": "Human-readable message."}
  • Treat these fields as sensitive or semi-sensitive:
    • Helpdesk Integrations Settings.bitrix_webhook_url
    • Helpdesk Integrations Settings.bitrix_responsible_webhook_url
    • Haravan Account Link.raw_profile
    • HD Customer Data.summary_json
  • Do not translate or rewrite user-generated ticket fields such as subject and description.
  • For Haravan org identity, prefer this lookup order:
    1. HD Customer.custom_haravan_orgid
    2. Haravan Account Link.haravan_orgid
    3. HD Ticket.custom_orgid
    4. HD Customer.domain / custom_myharavan

Quick Query Patterns

Find a customer by Haravan org ID:

python
customer = frappe.db.get_value(
    "HD Customer",
    {"custom_haravan_orgid": int(orgid)},
    ["name", "customer_name", "domain"],
    as_dict=True,
)

Find a ticket's customer profile:

python
ticket = frappe.db.get_value(
    "HD Ticket",
    ticket_name,
    ["name", "customer", "contact", "raised_by", "custom_orgid"],
    as_dict=True,
)

Find Haravan orgs linked to a user:

python
links = frappe.get_all(
    "Haravan Account Link",
    filters={"user": user},
    fields=["haravan_orgid", "haravan_orgname", "haravan_roles", "hd_customer"],
)

Find Bitrix snapshots for a customer:

python
rows = frappe.get_all(
    "HD Customer Data",
    filters={"hd_customer": hd_customer, "source": "bitrix"},
    fields=["entity_type", "external_id", "external_url", "confidence", "last_synced_at"],
)

Source Of Truth In This Repository

AreaFile
Custom field creationlogin_with_haravan/setup/install.py
Haravan -> Helpdesk synclogin_with_haravan/engines/sync_helpdesk.py
Bitrix customer profile enrichmentlogin_with_haravan/engines/customer_enrichment.py
Ticket CC behaviorlogin_with_haravan/overrides/hd_ticket.py
Haravan Account Link schemalogin_with_haravan/login_with_haravan/doctype/haravan_account_link/haravan_account_link.json
HD Customer Data schemalogin_with_haravan/login_with_haravan/doctype/hd_customer_data/hd_customer_data.json
Production routing Server Script templatescripts/deploy_profile_ticket_routing.py
Production metajson/Bitrix enrichment scriptscripts/deploy_bitrix_metajson_enrichment.py

Routing v2 notes

  • Current rollout uses Assignment Rules + consistency scripts.
  • Ticket - Snapshot Enrichment Fields (Before Insert) snapshots create-time enrichment values.
  • Ticket - Normalize Enrichment Routing After Save (After Save) normalizes values for all late flows (email, API, custom lookup) and sets agent_group best-effort without recursive save.
  • Active assignment posture:
    • AR01 - Partner Service Routing is disabled (prevent partner dual model conflict).
    • AR02 - SME 9M Scale active, guarded by empty agent_group.
    • AR03 - SME 9M Grow active, guarded by empty agent_group.
    • AR04 - CS60p Fallback active, guarded by empty agent_group.
    • Partner routing operates through Partner - ... - Support Rotation rules using agent_group.