Customer and contact relationships
Helpdesk links each request to a contact and, when known, to an HD Customer. A customer represents the organization or person that receives support. A contact represents a person who can raise requests and act for one or more customers. This model lets agents identify the requester, view the right customer context, and apply customer-level access to tickets.
Relationship model
The relationship model separates the person who communicates from the customer whose work is being supported. A ticket keeps both links so the requester remains clear even when several people belong to the same customer.
| Record | Role in the model |
|---|---|
| Contact | Person identified by name and contact details. A contact can have a linked user account and can belong to several customers. |
| HD Customer | Customer record for a company, individual, or partnership. It holds its members and can have one primary contact. |
| HD Customer Member | Membership link between a customer and a contact. The link marks whether the contact is a customer manager. |
| HD Ticket | Support request. Its contact link identifies the requester and its customer link identifies the customer context. |
One contact can belong to many customers. The same customer can have many contacts. The primary contact is one of the customer's members and is also treated as a manager member. The customer record can show that contact's email and mobile number as its primary details. References: helpdesk/…/hd_customer.json• L69-105, helpdesk/…/hd_customer.py• L78-104, helpdesk/…/hd_customer_member.json• L8-27, helpdesk/…/hd_ticket.json• L56-67
Requester and customer assignment
Ticket creation first uses the requester's identity to find a contact. For email intake, the email address in raised_by can match a Contact record. For a portal user, the system resolves the Contact linked to that user's account and does not allow the user to raise a ticket for another contact.
When automatic customer selection is enabled, the contact's memberships guide the customer link. One membership sets the customer automatically. Multiple memberships require a portal user to choose the customer. A non-agent cannot select a customer that is not linked to the contact. Agents can set customer context without this contact-membership restriction.
This sequence keeps the requester and customer distinct while still using their relationship to fill and check ticket context.
flowchart TD
A[Request enters Helpdesk] --> B[Identify requester]
B --> C{Matching Contact?}
C -- No --> D[Keep requester identity without Contact link]
C -- Yes --> E[Set ticket Contact]
E --> F[Find Contact memberships]
F --> G{One Customer?}
G -- Yes --> H[Set ticket Customer]
G -- Multiple Customers --> I[Choose a linked Customer]
G -- None --> J[Leave Customer unset]
I --> K[Validate Contact can use Customer]
H --> K
K --> L[Give agents requester and customer context]
The contact and customer links remain separate on the ticket. This matters when one contact raises tickets for different customers or when a manager needs to see all tickets for a customer rather than only tickets raised by that person. References: helpdesk/…/hd_ticket.py• L274-363, helpdesk/…/hd_ticket.json• L90-100, helpdesk/utils.py• L104-133
Customer membership and access
Customer membership controls what a customer user can read. A normal member can work with the customer's relationship but sees only tickets raised by that contact. A customer manager can see all tickets linked to the customer. The same contact can have manager access for one customer and member access for another.
Agents have broader ticket access based on their agent role and team settings. The customer relationship still gives the agent the context used to understand who raised the request and which customer owns it.
| User relationship | Ticket visibility |
|---|---|
| Contact with no customer manager role | Own tickets. |
| Customer manager | Tickets for customers where the contact is a manager, plus the contact's own tickets elsewhere. |
| Agent | Tickets allowed by agent access and team rules. |
Customer records use the same membership to limit non-agent access. Members and managers can read their customer record, but direct write and delete actions are denied. Customer managers use the supported customer actions for changes. Changing a membership's manager flag also keeps the linked user's customer roles aligned, including when that contact manages another customer. References: helpdesk/…/hd_customer.py• L105-157, helpdesk/…/hd_customer.py• L497-532, helpdesk/…/test_hd_customer.py• L408-460, helpdesk/…/hd_ticket.py• L1335-1455, helpdesk/…/test_hd_ticket.py• L927-985, helpdesk/…/test_hd_ticket.py• L988-1098
Customer context in the agent workspace
The agent desk presents contact information beside the ticket conversation. Agents can use the contact's name, email, phone, and customer links to understand the requester and move to related records. A customer page presents its contacts and their ticket counts, which helps an agent see the people and open work connected to that customer.
The customer page counts open and paused tickets connected through either the contact who raised the request or the ticket contact. This keeps the customer view useful when those two ticket identities differ. The ticket view uses the contact as the direct person context. The customer link supplies the wider customer context for filtering, access, and related-ticket work. For details about customer record views, see Customer records. For contact creation and updates, see Contact management. For the full ticket flow, see Ticket management.
References: desk/…/TicketAgentContact.vue• L1-52 desk/…/TicketContact.vue• L1-50 desk/…/CustomerContactTab.vue• L1-47 desk/…/ContactCustomers.vue• L1-74 helpdesk/…/hd_customer.py• L187-263
Invitations and account links
An existing Contact can be added directly to a customer when it has a linked user account. A person without a usable account link receives an invitation by default. An explicit no-invite path can add the Contact without an account link, but saving a membership does not create a User automatically. References: helpdesk/…/hd_customer.py• L265-367, helpdesk/…/test_hd_customer.py• L34-78
When the person accepts an invitation, Helpdesk reuses or creates the Contact, links the Contact to the User account, and adds the Contact to the customer with the invited member or manager role. This account link lets later requests resolve to the correct Contact. It also lets customer membership drive ticket and customer-record access without treating an email address alone as proof of ownership. References: helpdesk/…/user_invitation.py• L6-35, helpdesk/…/user_invitation.py• L54-70, helpdesk/…/hd_customer.py• L265-367, helpdesk/…/test_hd_customer.py• L141-177
Relationship changes and deletion
Changing membership can change both customer access and the user's customer role. The primary contact must remain a listed member. Removing a contact also clears its primary-contact state and the customer fields copied from it.
Deleting a contact removes its customer memberships and clears the contact link on tickets. The tickets stay unless the deletion request also asks to delete them. Deleting a customer clears related invitations and either preserves tickets without the customer link or deletes the linked tickets. References: helpdesk/…/hd_customer.py• L330-345, helpdesk/…/hd_customer.py• L458-493, helpdesk/…/contact.py• L39-60, helpdesk/…/contact.py• L63-74, helpdesk/…/customer.py• L60-71, helpdesk/…/test_hd_customer.py• L363-406
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the ticket
contactandcustomerrules aligned with the customer-member lookup. A change in one can make portal customer selection invalid or expose the wrong tickets. - Preserve the rule that
primary_contactis also a listed member and a manager. Customer summary email and phone fields depend on that link. - Keep the customer member manager flag and the linked User roles aligned across all customers. A contact can be a manager for one customer and a normal member for another.
- Do not treat a customer manager flag as permission to save or delete a customer directly. Keep manager changes on the supported customer actions.
- When changing invitation fields or accepted-invitation handling, keep the customer, contact, User, and customer-role links consistent. Do not create a User as a side effect of saving a membership.
- When changing deletion behavior, decide separately whether to clear links or delete tickets. This choice affects ticket history and customer context.
- Keep agent desk contact and customer views consistent with the ticket fields. Agents need both the requester and the customer to navigate related work.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A portal contact selects a customer that is not one of its memberships | Ticket save fails instead of creating a ticket with false customer ownership. | Validate the selected customer against the contact's linked customers. |
| A contact belongs to several customers and no customer is selected | Portal ticket creation cannot identify the customer context. | Require a customer choice for the portal flow. |
| A primary contact is not present in the customer member list | Customer save fails and the primary relationship is not stored. | Keep the primary contact within the membership table. |
| A manager flag changes without the linked User role being aligned | The person's ticket visibility and customer-record access can disagree with the membership. | Sync customer roles when membership manager status changes. |
| A customer member tries to save or delete the customer directly | The operation is rejected even if the member has a customer role. | Use the supported customer actions and check membership scope. |
| A contact or customer is deleted with linked tickets | Tickets can lose their requester or customer context, or can be removed by explicit choice. | Use the deletion mode that matches the required history: unlink or delete. |
| A customer manager role changes for one membership while the contact manages another customer | Removing the global manager role too early can reduce access to the other customer. | Keep the manager role while the contact remains a manager elsewhere. |
Key files
| File | Why to read it |
|---|---|
| helpdesk/…/hd_customer.json | Defines the customer record, primary contact, and contact membership relationship. |
| helpdesk/…/hd_customer.py | Explains membership validation, customer roles, access, invitations, and ticket unlink behavior. |
| helpdesk/…/test_hd_customer.py | Shows the supported membership, invitation, role, permission, and deletion outcomes. |
| helpdesk/…/hd_customer_member.json | Defines the customer-to-contact link and manager flag. |
| helpdesk/…/hd_ticket.py | Explains requester resolution, customer selection, and ticket visibility. |
| helpdesk/…/hd_ticket.json | Shows the ticket's separate Contact and Customer links. |
| helpdesk/utils.py | Provides the shared lookup from a user or contact to its customers. |
| helpdesk/…/user_invitation.py | Shows how accepted invitations create account and membership links. |
| desk/…/TicketAgentContact.vue | Shows the requester context presented in the agent ticket view. |
| desk/…/CustomerContactTab.vue | Shows the customer-side view of its contacts. |