Quorentra

Quorentra CRM Creating Contacts from ChatGPT: Building from Zero — Part 21

Series: Building Quorentra CRM from Zero — A Modular, ChatGPT-Native AI CRM

Building conversational Contact capture with Company relationships, email normalization, duplicate detection, dependency resolution, confirmation, audit, and reusable multi-entity workflows.

Quorentra Creating Contacts from ChatGPT: Building from Zero — Part 21
Quorentra Creating Contacts from ChatGPT: Building from Zero — Part 21

1. Introduction

Quorentra can now create two important CRM entities through ChatGPT.

In Part 19, we built conversational:

Opportunity Creation

In Part 20, we added:

Company Creation

and introduced our first dependency-aware workflow:

Opportunity Intent
↓
Resolve Company
↓
Company Missing
↓
Create Company
↓
Resume Opportunity
↓
Create Opportunity

That was an important architectural milestone.

But CRM systems are fundamentally about relationships between organizations and people.

A Company without Contacts tells us:

Which organization are we dealing with?

It does not tell us:

Who are we actually talking to?

That changes in Part 21.

We will allow users to say:

Add Sarah Johnson at Adventure Works. She’s the IT Director and her email is sarah.johnson@adventure-works.com.

Quorentra will turn that natural-language request into a structured Contact while preserving the architecture we have established:

Natural Language
↓
Extract Explicit Facts
↓
Resolve Company
↓
Contact Draft
↓
Normalize
↓
Detect Duplicates
↓
Validate
↓
Prepare
↓
Confirm
↓
Create
↓
Audit

And if Adventure Works does not yet exist:

Contact Intent
↓
Company Missing
↓
Create Company
↓
Resume Contact Draft
↓
Create Contact

By the end of Part 21, Quorentra will have the three fundamental CRM relationship entities:

Company
│
├──────── Contact
│
└──────── Opportunity

That gives us the foundation needed to move next into the operational side of CRM:

Activities
Tasks
Meetings
Notes

2. What Are We Building?

Our first target interaction is:

Add Sarah Johnson at Adventure Works. She’s the IT Director and her email is sarah.johnson@adventure-works.com.

ChatGPT extracts:

Name:
Sarah Johnson
Company:
Adventure Works
Job Title:
IT Director
Email:
sarah.johnson@adventure-works.com

Quorentra resolves:

Adventure Works
↓
company_id

Then creates a Contact draft.

The user sees:

┌────────────────────────────────────────────┐
│ QUORENTRA │
│ Create Contact │
│ │
│ Sarah Johnson │
│ IT Director │
│ │
│ Company │
│ Adventure Works │
│ │
│ Email │
│ sarah.johnson@adventure-works.com │
│ │
│ This will create a new CRM Contact. │
│ │
│ [Cancel] [Create Contact] │
└────────────────────────────────────────────┘

Only after:

Create Contact

does Quorentra create the authoritative Contact.


3. Why Contacts Are More Complicated Than Companies

A Company can often be identified reasonably well by:

Name
Domain

People are more complicated.

Consider:

Sarah Johnson

There may be several Sarah Johnsons.

Even inside one organization.

Therefore Contact identity needs stronger signals.

Useful identifiers include:

Email Address
Company + Name
Phone Number

Each has different reliability.


4. Contact Identity Is Contextual

This is important.

The name:

Sarah Johnson

does not uniquely identify a person globally.

But:

Sarah Johnson
+
Adventure Works
+
sarah.johnson@adventure-works.com

provides a much stronger identity.

Our duplicate-resolution logic should reflect that.


5. Starting Checkpoint

Before implementing Part 21, verify Part 20.

Run:

cd backend
python -m pytest

Then:

cd ..\chatgpt-ui
npm run build

Test:

Create a €90,000 Azure migration opportunity for Adventure Works closing December 15, 2026.

If Adventure Works does not exist, verify:

Company Missing
↓
Company Creation
↓
Company Confirmation
↓
Company Created
↓
Opportunity Resumed
↓
Opportunity Confirmation
↓
Opportunity Created

Part 21 reuses this dependency architecture.


6. Define the Contact Permission

Introduce:

contacts.create

Our growing permission model becomes:

Companies
├── companies.read
├── companies.create
└── companies.update
Contacts
├── contacts.read
├── contacts.create
└── contacts.update
Opportunities
├── opportunities.read
├── opportunities.create
└── opportunities.update

Again:

Read
Create
Update

remain independent capabilities.


7. Example Role Matrix

For the MVP:

RoleReadCreateUpdate
Viewer✓——
Member✓✓✓
Manager✓✓✓
Admin✓✓✓
Owner✓✓✓

Later we can introduce more granular roles.

For now, capability separation matters more than role complexity.


8. Define the Contact Domain

Our Contact model might contain:

id
organization_id
company_id
first_name
last_name
full_name
normalized_full_name
email
normalized_email
phone
normalized_phone
job_title
description
version
created_at
updated_at

The exact schema may evolve.

But this is enough for the MVP.


9. Which Fields Are Required?

We should keep Contact creation lightweight.

For the MVP:

Required:
first_name
last_name
company_id

Optional:

email
phone
job_title
description

However, we should allow the user to initially provide:

full_name

and let ChatGPT structure it into first and last names where reasonably clear.


10. Why Require a Company?

For the current MVP, Contacts belong to Companies.

That gives us:

Company
↓
Contact

rather than disconnected people.

Later Quorentra may support:

Independent Contact
Individual Customer
Freelancer
Prospect without Company

But that is not necessary yet.

Keeping Company mandatory simplifies the initial domain.


11. Field Ownership

Classify fields before implementing the tool.

FieldSource
idSystem
organization_idTenantContext
company_idResolved Company
first_nameUser
last_nameUser
full_nameServer derived
normalized_full_nameServer derived
emailUser
normalized_emailServer derived
phoneUser
normalized_phoneServer derived
job_titleUser
descriptionUser
versionSystem
created_atSystem
updated_atSystem

This classification prevents ChatGPT from controlling fields it should not own.


12. Never Accept Tenant ID

As always:

organization_id

comes from:

TenantContext

not ChatGPT.

The Contact tools must never allow the model to select the tenant.


13. Never Trust Company ID from Natural Language

The user says:

Adventure Works.

They do not say:

company_id =
8cb...

Quorentra resolves:

Adventure Works
↓
company_id

server-side.

ChatGPT works with human-readable references.

Quorentra owns entity identity.


14. Introduce ContactDraft

Reuse the draft architecture.

Conceptually:

ContactDraft
├── id
├── organization_id
├── user_id
├── company_id
├── company_reference
├── first_name
├── last_name
├── email
├── phone
├── job_title
├── description
├── status
├── field_sources
├── dependency_status
├── workflow_id
├── expires_at
├── created_at
└── updated_at

This is temporary application state.

It is not yet a Contact.


15. Why Use a Contact Draft?

Because conversational input may arrive incrementally.

User:

Add Sarah Johnson at Adventure Works.

Quorentra knows:

First Name:
Sarah
Last Name:
Johnson
Company:
Adventure Works

Then ChatGPT may ask:

Do you want to add her email, job title, or phone number?

The user might reply:

She’s the IT Director. Her email is sarah.johnson@adventure-works.com.

The draft can be updated without creating the Contact prematurely.


16. Optional Information Should Stay Optional

Be careful here.

If the required fields are already available, we should not force the user through unnecessary questions.

For example:

Add Sarah Johnson at Adventure Works.

may already be sufficient to create a Contact.

ChatGPT can optionally offer:

I can also add her email, phone number, or job title if you have them.

But it should not turn lightweight CRM capture into a questionnaire.


17. Required Versus Recommended

This distinction is useful.

We can return:

missing_required_fields

and separately:

recommended_fields

For example:

{
"missing_required_fields": [],
"recommended_fields": [
"email",
"job_title"
]
}

The Contact can still be created.


18. Contact Draft Status

Reuse:

incomplete
complete
prepared
cancelled
expired
converted

If:

first_name
last_name
company_id

are available:

status = complete

even if:

email
phone
job_title

are missing.


19. Company Dependency

Suppose the user says:

Add Sarah Johnson at Adventure Works.

But Adventure Works does not exist.

The Contact draft can contain:

company_id = NULL
company_reference = "Adventure Works"
dependency_status = unresolved

This is exactly the dependency pattern from Part 20.


20. The Contact Can Exist as a Draft Before the Company

This gives us:

Contact Intent
↓
Contact Draft
↓
Company Resolution
↓
Company Missing
↓
Pause Contact Draft
↓
Resolve Company Dependency

The user’s Contact information is preserved.

They do not need to repeat it.


21. Name Extraction

User:

Add Sarah Johnson.

ChatGPT can reasonably extract:

first_name = Sarah
last_name = Johnson

But names are not always simple.

Consider:

Juan Carlos de la Vega
Anne-Marie van Dijk
Mohammed bin Rashid

We should not pretend name parsing is universally trivial.


22. MVP Name Strategy

For the MVP, ChatGPT can provide structured:

first_name
last_name

when the intent is clear.

If ambiguous, ask.

For example:

Add Van Helsing at Contoso.

Quorentra may need clarification if it cannot reliably determine the name structure.


23. Do Not Overengineer Name Parsing Yet

Avoid introducing:

Global name parsing library
Cultural name classifier
AI identity resolver

for the MVP.

We need a useful system, not a perfect global identity platform.


24. Full Name

The authoritative Contact can derive:

full_name

from:

first_name
last_name

according to a presentation rule.

For example:

Sarah
+
Johnson
=
Sarah Johnson

Do not make full_name the authoritative source if structured names are available.


25. Normalized Full Name

For duplicate detection:

normalized_full_name

may:

trim whitespace
collapse repeated spaces
convert to lowercase

So:

" Sarah Johnson "

becomes:

"sarah johnson"

26. Email Is a Strong Identity Signal

Suppose:

sarah.johnson@adventure-works.com

already exists.

The user says:

Add Sarah Johnson at Adventure Works with sarah.johnson@adventure-works.com.

That is a strong duplicate signal.

Quorentra should not blindly create another Contact.


27. Normalize Email

Email normalization should happen server-side.

At minimum:

trim whitespace
lowercase

So:

 Sarah.Johnson@Adventure-Works.com 

becomes:

sarah.johnson@adventure-works.com

for matching.


28. Preserve Original Email?

For email addresses, normalized lowercase storage is generally sufficient for CRM use.

We can store:

email =
sarah.johnson@adventure-works.com

and optionally:

normalized_email =
sarah.johnson@adventure-works.com

The duplicate field can still be explicit for clarity and indexing.


29. Do Not Over-Normalize Email

Do not apply provider-specific assumptions such as:

remove dots
remove +tags

because those rules differ by provider.

For example:

john.smith@example.com

and:

johnsmith@example.com

should not automatically be treated as the same address.

Keep normalization conservative.


30. Email Validation

Use structural validation.

For example:

EmailStr

from Pydantic can be useful if already available in the stack.

Invalid:

sarah@

should produce a structured error.


31. Example Validation Error

{
"field": "email",
"code": "INVALID_EMAIL",
"message": "Email address is not valid."
}

ChatGPT can explain:

That email address doesn’t appear to be valid. What email should I use?


32. Phone Number

Phone is optional.

If supplied:

+31 6 12345678

we should normalize it.

Eventually:

E.164

would be ideal.

For the MVP, we can use conservative normalization.


33. Phone Normalization

At minimum:

trim
remove presentation spaces
preserve leading +

But avoid guessing country codes if they are not provided.

Do not transform:

06 12345678

into:

+31 6 12345678

based solely on assumed user location.

That would be an inference.


34. Job Title

Job title is optional.

User:

She’s the IT Director.

ChatGPT can extract:

job_title =
IT Director

No special AI generation is needed.


35. Description

Description remains optional.

User:

Sarah is our main technical contact for the Azure migration.

That can become:

description =
Main technical contact for the Azure migration.

provided the statement comes from the user.

Do not generate an invented biography.


36. Contact Draft Input

Introduce:

create_contact_draft

Conceptually:

class CreateContactDraftInput(BaseModel):
company_reference: str | None = None
first_name: str | None = None
last_name: str | None = None
email: EmailStr | None = None
phone: str | None = None
job_title: str | None = None
description: str | None = None

Again, no:

organization_id
company_id
normalized_email
normalized_phone
version

from ChatGPT.


37. Draft Creation Flow

The application performs:

Receive Explicit Facts
↓
Validate Names
↓
Normalize Email
↓
Normalize Phone
↓
Resolve Company
↓
Detect Dependencies
↓
Detect Duplicates
↓
Determine Missing Fields
↓
Create Draft
↓
Return Structured Result

No Contact is created.


38. Example Complete Draft

User:

Add Sarah Johnson at Adventure Works. She’s the IT Director and her email is sarah.johnson@adventure-works.com.

Assuming Adventure Works exists:

{
"draft_id": "...",
"status": "complete",
"values": {
"company": {
"id": "...",
"name": "Adventure Works"
},
"first_name": "Sarah",
"last_name": "Johnson",
"email": "sarah.johnson@adventure-works.com",
"phone": null,
"job_title": "IT Director",
"description": null
},
"missing_required_fields": [],
"duplicate_matches": []
}

39. Example Incomplete Draft

User:

Add Sarah Johnson.

Quorentra knows:

Sarah Johnson

but Company is required.

Return:

{
"status": "incomplete",
"missing_required_fields": [
"company"
]
}

ChatGPT asks:

Which company is Sarah Johnson associated with?


40. Update Contact Draft

Introduce:

update_contact_draft

Conceptually:

class UpdateContactDraftInput(BaseModel):
draft_id: UUID
company_reference: str | None = None
first_name: str | None = None
last_name: str | None = None
email: EmailStr | None = None
phone: str | None = None
job_title: str | None = None
description: str | None = None

Every update triggers revalidation and duplicate checks.


41. Company Resolution

Reuse the Company resolution service from Part 20.

For:

Adventure Works

Quorentra performs:

Tenant-scoped Company Search
↓
Exact Normalized Match?

If exactly one:

company_id = matched Company

42. Ambiguous Company

Suppose the tenant contains:

Adventure Works Europe
Adventure Works Consulting

and the user says:

Add Sarah Johnson at Adventure Works.

Do not choose arbitrarily.

Return:

Multiple Company matches.

ChatGPT asks which Company the user means.


43. Company Not Found

If no Company exists:

company_reference =
Adventure Works
company_id =
NULL
dependency_status =
unresolved

The Contact draft remains valid temporary state.


44. Offer Company Creation

ChatGPT can say:

Adventure Works isn’t currently in Quorentra. Would you like to create the company first?

This is the exact pattern from Part 20.

If the user declines:

Contact remains draft
No Company created
No Contact created

45. If the User Accepts

Quorentra creates:

CompanyDraft

linked by:

workflow_id

to the Contact draft.

Then:

Prepare Company
↓
Confirm
↓
Create Company

46. Resume Contact After Company Creation

After the authoritative Company exists:

new_company.id

is assigned to:

ContactDraft.company_id

Then:

dependency_status = resolved

and the Contact draft is revalidated.


47. User Does Not Repeat Contact Details

The original:

Sarah Johnson
IT Director
sarah.johnson@adventure-works.com

remains stored in the Contact draft.

That is the value of server-owned workflow state.


48. Duplicate Detection

Before Contact creation, Quorentra should check for likely duplicates.

For the MVP, use deterministic signals.

Strongest:

Exact normalized email

Secondary:

Same Company
+
Exact normalized full name

Optional:

Exact normalized phone

49. Duplicate Priority

A useful hierarchy is:

1. Exact Email
2. Exact Phone
3. Company + Exact Name

This is not perfect identity resolution.

It is sufficient for an MVP.


50. Exact Email Duplicate

Existing:

Sarah Johnson
Adventure Works
sarah.johnson@adventure-works.com

User attempts to add:

Sarah J. Johnson
Adventure Works
sarah.johnson@adventure-works.com

Exact email strongly suggests the existing Contact.

Return the existing Contact rather than blindly creating another one.


51. Same Name, Same Company

Existing:

Sarah Johnson
Adventure Works

New draft:

Sarah Johnson
Adventure Works

but no email is available.

This is a potential duplicate.

Do not assume with absolute certainty that it is the same person.

Two people can share a name.


52. Exact Versus Potential Duplicate

Return structured match types:

EXACT_EMAIL
EXACT_PHONE
SAME_COMPANY_EXACT_NAME

Then assign confidence categories such as:

strong
possible

But keep the actual rule deterministic.


53. Example Duplicate Result

{
"duplicate_matches": [
{
"contact_id": "...",
"name": "Sarah Johnson",
"company_name": "Adventure Works",
"email": "sarah.johnson@adventure-works.com",
"match_reason": "EXACT_EMAIL"
}
]
}

ChatGPT can explain the situation.


54. Exact Email Should Usually Resolve Existing Contact

If:

normalized_email

matches exactly inside the tenant, the default MVP behavior should be:

Use existing Contact

rather than create another.

This prevents obvious duplication.


55. Email Uniqueness Scope

Should email be globally unique?

No.

Tenant A may store:

sarah@example.com

and Tenant B may also store the same person.

That is normal in a multi-tenant CRM.

Any uniqueness constraint must include:

organization_id

56. Tenant-Scoped Email Constraint

A possible database rule is:

UNIQUE (
organization_id,
normalized_email
)

for non-null emails.

Whether to enforce this depends on the CRM domain.

For the MVP, it is a reasonable safeguard.


57. Why Nullable Email Needs Care

Because many Contacts may have:

email = NULL

The database constraint must allow multiple Contacts without emails.

PostgreSQL handles nullable unique values appropriately in standard unique constraints, but confirm the intended semantics in your schema.


58. Do Not Make Name Unique

Never enforce:

UNIQUE (
organization_id,
normalized_full_name
)

Two Contacts can legitimately share the same name.

Name is a duplicate signal, not a unique identity key.


59. Company + Name Is Still Valuable

Although not unique, this query is useful:

organization_id
+
company_id
+
normalized_full_name

It can surface likely duplicates before creation.


60. Phone Duplicate

If phone is supplied and normalized reliably, exact phone matching can provide another signal.

But phone numbers may be:

shared
reassigned
office numbers
switchboards

Therefore phone is useful, but not absolute identity.


61. Duplicate UI

If Quorentra detects an existing Contact, the widget could show:

┌────────────────────────────────────────────┐
│ QUORENTRA │
│ Possible Existing Contact │
│ │
│ Sarah Johnson │
│ IT Director │
│ Adventure Works │
│ │
│ sarah.johnson@adventure-works.com │
│ │
│ A Contact with this email already exists. │
│ │
│ [View Contact] │
└────────────────────────────────────────────┘

In the exact-email case, creation should usually stop.


62. Do Not Hide Duplicate Resolution

ChatGPT should not silently decide:

This is probably the same person.

The backend returns the match.

ChatGPT explains it.

The user can inspect the existing Contact if needed.


63. Prepare Contact Creation

Once:

ContactDraft

is:

complete

and duplicate policy allows creation, call:

prepare_contact_creation

Input:

{
"draft_id": "..."
}

64. Preparation Flow

Load ContactDraft
↓
Verify Tenant
↓
Verify User
↓
Verify contacts.create
↓
Verify Not Expired
↓
Verify Company
↓
Validate Contact
↓
Recheck Duplicates
↓
Create MutationRequest
↓
Mark Draft Prepared
↓
Return Confirmation

Still:

0 Contact rows created

65. Mutation Type

Use:

mutation_type =
contact.create

The proposed values contain:

{
"company_id": "...",
"first_name": "Sarah",
"last_name": "Johnson",
"email": "sarah.johnson@adventure-works.com",
"phone": null,
"job_title": "IT Director",
"description": null
}

66. Confirmation UI

Create:

chatgpt-ui/src/mutations/
└── ContactCreationConfirmation.tsx

Example:

┌────────────────────────────────────────────┐
│ QUORENTRA │
│ Create Contact │
│ │
│ Sarah Johnson │
│ IT Director │
│ │
│ Company │
│ Adventure Works │
│ │
│ Email │
│ sarah.johnson@adventure-works.com │
│ │
│ Phone │
│ — │
│ │
│ This will create a new CRM Contact. │
│ │
│ [Cancel] [Create Contact] │
└────────────────────────────────────────────┘

67. Show the Relationship Clearly

The Company should be prominent.

We are not merely creating:

Sarah Johnson

We are creating:

Sarah Johnson
↓
Adventure Works

The relationship is part of the business meaning.


68. Confirmation Must Show Extracted Values

If ChatGPT interpreted:

She’s the IT Director.

as:

job_title = IT Director

show it.

If the user spots an error, they can correct the draft before creation.


69. Edit Before Confirmation

Suppose the user says:

Actually her title is Director of Infrastructure.

Update:

ContactDraft.job_title

If a MutationRequest had already been prepared:

old MutationRequest
→ superseded

A fresh confirmation is required.


70. Execute Contact Creation

Introduce:

create_contact

Input:

{
"mutation_request_id": "..."
}

No arbitrary Contact fields are accepted during execution.


71. Execution Flow

Load MutationRequest
↓
Verify Tenant
↓
Verify User
↓
Verify contacts.create
↓
Verify Pending
↓
Verify Not Expired
↓
Load ContactDraft
↓
Verify Draft Matches
↓
Revalidate Company
↓
Revalidate Contact
↓
Recheck Duplicates
↓
Create Contact
↓
Create AuditEvent
↓
Mark Mutation Executed
↓
Mark ContactDraft Converted
↓
Commit

72. Why Revalidate Company?

The Company could have changed between preparation and execution.

For example:

archived
deleted
made unavailable

A Contact should not be created against an invalid Company relationship.


73. Why Recheck Email?

Another user could create:

sarah.johnson@adventure-works.com

between preparation and execution.

Execution-time duplicate protection prevents avoidable duplication.


74. Transaction Boundary

Use:

BEGIN
create Contact
create AuditEvent
mark MutationRequest executed
mark ContactDraft converted
COMMIT

If anything fails:

ROLLBACK

75. Initial Version

The Contact begins with:

version = 1

This keeps the domain compatible with future optimistic concurrency.


76. Contact Audit Event

Use:

action =
contact.created

Store:

organization_id
actor_user_id
entity_id
new_values
invocation_source
mutation_request_id
workflow_id
created_at

77. Example Audit Event

{
"action": "contact.created",
"entity_type": "contact",
"entity_id": "...",
"new_values": {
"company_id": "...",
"first_name": "Sarah",
"last_name": "Johnson",
"email": "sarah.johnson@adventure-works.com",
"job_title": "IT Director"
},
"invocation_source": "chatgpt_model"
}

78. Be Careful with Audit Data

Email and phone numbers are personal data.

Do not duplicate sensitive fields across logs unnecessarily.

Your business audit requirements may justify recording certain changes, but operational logging should minimize personal information.

Keep:

Audit Trail

and:

Application Logs

conceptually separate.


79. Authoritative Contact Result

After commit:

{
"success": true,
"contact": {
"id": "...",
"company_id": "...",
"company_name": "Adventure Works",
"first_name": "Sarah",
"last_name": "Johnson",
"full_name": "Sarah Johnson",
"email": "sarah.johnson@adventure-works.com",
"phone": null,
"job_title": "IT Director",
"version": 1
}
}

This is the result ChatGPT trusts.


80. Success Widget

Render:

┌────────────────────────────────────────────┐
│ QUORENTRA │
│ Contact Created │
│ │
│ Sarah Johnson │
│ IT Director │
│ │
│ Adventure Works │
│ sarah.johnson@adventure-works.com │
│ │
│ [View Contact] │
└────────────────────────────────────────────┘

81. Never Announce Success Early

ChatGPT must not say:

Sarah Johnson has been added.

after:

Draft Created

or:

Confirmation Displayed

Only after:

create_contact

returns successful authoritative data may the model state that the Contact exists.


82. Chained Company → Contact Workflow

Now consider:

Add Sarah Johnson at Blue Yonder Airlines. She’s the IT Director.

Suppose Blue Yonder Airlines does not exist.

The workflow becomes:

Contact Intent
↓
Contact Draft
↓
Resolve Company
↓
Company Missing
↓
Offer Company Creation
↓
Company Draft
↓
Confirm Company
↓
Create Company
↓
Attach Company ID
↓
Resume Contact Draft
↓
Confirm Contact
↓
Create Contact

This is almost identical to the Company → Opportunity workflow from Part 20.

That is a sign that our architecture is becoming reusable.


83. Shared Workflow ID

Both operations can share:

workflow_id

For example:

Workflow:
Add Sarah Johnson at Blue Yonder Airlines
├── company.created
└── contact.created

This improves traceability without requiring a full workflow engine.


84. Cancellation of Company Creation

If the user cancels:

Create Blue Yonder Airlines

then:

No Company
No Contact

The Contact draft can remain:

incomplete

until expiry.


85. Resume Later

Later, the user could potentially say:

Continue adding Sarah Johnson.

Quorentra could retrieve the user’s incomplete Contact draft.

This is another benefit of persisted draft state.


86. Existing Company Path

If Blue Yonder Airlines already exists:

Resolve Company
↓
Company Found
↓
Contact Draft Complete
↓
Prepare Contact

No Company workflow is needed.

The dependency architecture only activates when required.


87. Exact Email Existing Contact Path

Suppose Sarah already exists.

User:

Add Sarah Johnson at Adventure Works, sarah.johnson@adventure-works.com.

Quorentra finds:

EXACT_EMAIL

Then instead of creating:

ContactDraft → Contact

it can return:

existing_contact

ChatGPT says:

Sarah Johnson already exists at Adventure Works with that email address.


88. This Is Entity Resolution, Not Creation

That distinction matters.

Sometimes the correct response to:

Add Sarah Johnson.

is not:

Create Contact

but:

Resolve Existing Contact

The user cares about the business outcome, not which internal operation was needed.


89. Possible Duplicate Path

Suppose existing:

Sarah Johnson
Adventure Works
No Email

New:

Sarah Johnson
Adventure Works
sarah.johnson@adventure-works.com

This could be:

Same person with new information

or:

Different person with same name

Do not silently decide.


90. Possible Duplicate UI

Show:

┌────────────────────────────────────────────┐
│ QUORENTRA │
│ Possible Existing Contact │
│ │
│ Sarah Johnson │
│ Adventure Works │
│ │
│ Existing email: — │
│ New email: │
│ sarah.johnson@adventure-works.com │
│ │
│ Is this the same person? │
│ │
│ [View Existing] [Create New] │
└────────────────────────────────────────────┘

Later we can add:

Update Existing

as a governed mutation.


91. Do Not Build Contact Merge Yet

Contact merging is complicated.

It requires decisions about:

Activities
Opportunities
Notes
Tasks
Emails
Meetings
Ownership
Audit

Do not introduce it into the MVP.

For now:

Resolve
Create
or
Ask

is enough.


92. Contact Detail Retrieval

Once Contacts exist, ChatGPT should also be able to retrieve them.

For example:

Show me Sarah Johnson at Adventure Works.

This can use:

get_contact

or:

search_contacts

with tenant-scoped entity resolution.


93. Minimal Search Capability

Support:

Name
Email
Company

queries.

For example:

search_contacts(
query="Sarah Johnson",
company_reference="Adventure Works"
)

But the server still resolves and scopes everything.


94. Contact List by Company

Another useful capability:

Show me the contacts at Adventure Works.

The server resolves:

Adventure Works
↓
company_id

then retrieves tenant-scoped Contacts.

This will make Company views much more useful.


95. Company Detail Evolves

Company detail can now include:

Adventure Works
Contacts
├── Sarah Johnson — IT Director
├── Michael Brown — CIO
└── Lisa Chen — Procurement Manager
Opportunities
├── Azure Migration
└── Microsoft Copilot Deployment

The CRM relationship model is becoming visible.


96. Contact → Opportunity Relationship

For now, Opportunities belong to Companies.

But sales Opportunities often involve specific Contacts.

Eventually we will need:

OpportunityContact

or similar.

This supports:

Decision Maker
Champion
Technical Evaluator
Economic Buyer
Procurement Contact

That is beyond Part 21.


97. Do Not Add Every Relationship Yet

The modular strategy says:

Add only what the next usable capability requires.

For Contact creation we need:

Contact → Company

We do not yet need:

Contact ↔ Opportunity

to finish the Part 21 goal.


98. Contact Draft Repository Tests

Test:

create draft
load own draft
update draft
cancel draft
expire draft
convert draft
cross-user access denied
cross-tenant access denied

99. Name Tests

Test:

Sarah Johnson
Sarah Johnson
SARAH JOHNSON
Sarah Johnson

Verify normalization.

Also test non-trivial names without making unsafe assumptions.


100. Email Tests

Test:

sarah.johnson@example.com
Sarah.Johnson@Example.com

Expected normalized value:

sarah.johnson@example.com

Test invalid email formats too.


101. Phone Tests

Verify:

+31 6 12345678
+31612345678

according to the normalization policy.

Do not infer missing country codes.


102. Company Resolution Tests

Test:

exact Company
case-insensitive Company
ambiguous Company
missing Company
cross-tenant Company

103. Required-Field Tests

Draft:

Sarah Johnson
Adventure Works

Expected:

complete

Draft:

Sarah Johnson

Expected:

missing:
company

Draft:

Adventure Works

Expected missing:

first_name
last_name

104. Duplicate Email Test

Existing:

sarah.johnson@adventure-works.com

Attempt another Contact with the same normalized email.

Expected:

EXACT_EMAIL

No silent duplicate creation.


105. Same Company + Name Test

Existing:

Sarah Johnson
Adventure Works

New draft:

Sarah Johnson
Adventure Works

Expected:

SAME_COMPANY_EXACT_NAME

Potential duplicate surfaced.


106. Same Name Different Company

Existing:

Sarah Johnson
Contoso

New:

Sarah Johnson
Adventure Works

This should not automatically be treated as the same Contact.

Company context matters.


107. Same Email Different Tenant

Tenant A:

sarah@example.com

Tenant B:

sarah@example.com

Both are valid.

Tenant A must never influence Tenant B’s duplicate detection.


108. Permission Tests

Viewer:

create_contact_draft → denied
prepare_contact_creation → denied
create_contact → denied

Authorized Member:

allowed

109. Permission Change Test

Prepare Contact creation.

Change user permission before execution.

Expected:

create_contact → denied

No Contact is created.


110. Preparation Tests

Verify:

incomplete draft cannot prepare
expired draft cannot prepare
invalid Company cannot prepare
strong duplicate policy works
complete valid draft can prepare
preparation creates no Contact

111. Edit-After-Prepare Test

Prepare:

Job Title:
IT Director

Then update:

Director of Infrastructure

Expected:

old MutationRequest invalidated
new confirmation required

112. Execution Tests

Successful execution must:

create exactly one Contact
assign active tenant
assign resolved Company
use confirmed fields
set version = 1
create AuditEvent
mark MutationRequest executed
mark ContactDraft converted
return authoritative Contact

113. Idempotency Test

Execute the same MutationRequest twice.

Expected:

1 Contact
1 AuditEvent
1 logical result

Never:

2 Contacts

114. Transaction Failure Test

Simulate failure after Contact insert but before AuditEvent completion.

Expected:

ROLLBACK

No Contact remains.


115. Company Race Test

Prepare Contact creation.

Archive or remove the Company before execution.

Expected:

Contact creation rejected

116. Email Race Test

Prepare Sarah’s Contact.

Before execution, another user creates the same normalized email.

Expected:

duplicate conflict

No accidental second Contact.


117. Chained Company → Contact Test

User:

Add Sarah Johnson at Blue Yonder Airlines. She’s the IT Director.

Company does not exist.

Expected:

ContactDraft created
Company dependency unresolved
Company creation offered

118. Company Creation Success

Confirm Blue Yonder Airlines.

Expected:

Company created
Company AuditEvent created
ContactDraft.company_id updated
ContactDraft revalidated

The user does not repeat Sarah’s information.


119. Contact Continuation

If Contact draft is now complete:

prepare_contact_creation

can run.

Then the Contact confirmation widget appears.


120. Contact Confirmation

User clicks:

Create Contact

Expected:

Contact created
Contact AuditEvent created
workflow completed

121. Chained Workflow Audit

We now have:

workflow_id = abc123
AuditEvent
├── company.created
└── contact.created

This gives us traceability across the multi-entity operation.


122. Contact Creation from a Complete One-Shot Request

User:

Add Lisa Chen, Procurement Manager at Contoso, lisa.chen@contoso.com, +31 20 123 4567.

ChatGPT extracts:

First Name:
Lisa
Last Name:
Chen
Company:
Contoso
Job Title:
Procurement Manager
Email:
lisa.chen@contoso.com
Phone:
+31 20 123 4567

If Contoso exists and no duplicate is found:

Draft Complete
↓
Prepare
↓
Confirm
↓
Create

No follow-up questions are needed.


123. Minimal Request

User:

Add Lisa Chen at Contoso.

If Contoso exists:

First Name:
Lisa
Last Name:
Chen
Company:
Contoso

are enough.

The Contact can be prepared immediately.

Optional fields remain optional.


124. Conversational Enhancement

After creation, ChatGPT might say:

Lisa Chen has been added to Contoso. If you have her email, phone number, or job title, I can add those later.

That creates a lightweight workflow instead of forcing perfect data capture upfront.


125. This Matters for CRM Adoption

Traditional CRMs often fail because users perceive data entry as administrative overhead.

If every Contact requires a large form:

First Name
Last Name
Company
Title
Department
Email
Phone
Mobile
Address
City
Country
Lead Source
Owner
Status
Notes

users may postpone entering the Contact.

Quorentra should allow:

Add Lisa Chen at Contoso.

and make that useful immediately.


126. Progressive Data Quality

This suggests a broader design principle:

Capture the minimum valid CRM record first, then improve it progressively.

For example:

Day 1
Lisa Chen
Contoso
Day 2
+ Procurement Manager
Day 3
+ lisa.chen@contoso.com
Day 5
+ Buying role
Day 10
+ Meeting history

The CRM record becomes richer through normal work.


127. ChatGPT Can Reduce Data Entry Friction

Users naturally communicate facts in conversation:

I spoke with Lisa Chen, the Procurement Manager at Contoso.

Later, Quorentra can recognize:

Lisa Chen
Procurement Manager
Contoso

and offer:

Lisa Chen isn’t in Quorentra yet. Would you like me to add her?

That is a future capability.

But Part 21 builds the safe creation primitive required for it.


128. Do Not Auto-Create Mentioned People

This is important.

If a user merely says:

Sarah Johnson joined today’s meeting.

Quorentra should not silently create:

Contact: Sarah Johnson

Mention is not necessarily creation intent.

The system should distinguish:

Entity Mention

from:

Creation Intent

129. Explicit Intent Remains Important

Examples of creation intent:

Add Sarah Johnson.

Create Sarah Johnson as a Contact.

Put Sarah Johnson at Adventure Works into the CRM.

These clearly request a mutation.

By contrast:

Sarah Johnson said the project is delayed.

does not.


130. AI Interpretation Must Remain Conservative

A ChatGPT-native CRM should be helpful.

But CRM data can affect:

Sales reporting
Customer communication
Forecasting
Automation
Compliance
AI recommendations

Therefore uncertain facts should not become authoritative silently.


131. Company Relationship Is Authoritative

If the user says:

Add Sarah Johnson at Adventure Works.

then:

Contact.company_id

must reference the authoritative:

Adventure Works.id

not simply store:

company_name =
Adventure Works

Stable relational identity remains essential.


132. Contact Search Tool

Introduce or extend:

search_contacts

with filters such as:

query
company_reference
email
limit

The tool should return minimal useful fields.


133. Example Search Result

{
"contacts": [
{
"id": "...",
"full_name": "Sarah Johnson",
"job_title": "IT Director",
"company_name": "Adventure Works",
"email": "sarah.johnson@adventure-works.com"
}
]
}

This supports both direct retrieval and duplicate resolution.


134. Avoid Exposing Entire Contact Database

As with Companies, ChatGPT should not receive every Contact merely to find one.

Use:

Search
Filters
Limits
Tenant Scope

This improves:

Privacy
Performance
Context efficiency

135. Contact Detail Widget

We can introduce:

ContactDetail.tsx

Example:

┌────────────────────────────────────────────┐
│ QUORENTRA │
│ Sarah Johnson │
│ IT Director │
│ │
│ Adventure Works │
│ │
│ sarah.johnson@adventure-works.com │
│ +31 6 12345678 │
│ │
│ Opportunities │
│ — │
│ │
│ Activities │
│ — │
└────────────────────────────────────────────┘

Some sections are empty today.

That is fine.

We will fill them incrementally.


136. Company Detail Widget

Likewise, Company detail can now include:

Contacts

For example:

Adventure Works
Contacts
3
Sarah Johnson
IT Director
Michael Brown
CIO
Lisa Chen
Procurement Manager

This makes the CRM increasingly navigable through structured ChatGPT UI.


137. The Core CRM Graph

At this stage our domain graph is:

Organization
│
├──────── User
│
├──────── Company
│ │
│ ├──────── Contact
│ │
│ └──────── Opportunity
│
└──────── AuditEvent

This is a small but real CRM domain.


138. Version Update

Part 21 introduces:

Contact Drafts
Contact Creation
Contact Resolution
Contact Duplicate Detection
Email Normalization
Phone Normalization
Company → Contact Dependency Workflow

Update:

app/core/constants.py

from:

APP_VERSION = "0.7.0"

to:

APP_VERSION = "0.8.0"

139. Quorentra 0.8.0

Our modular MVP now looks like:

Platform
├── FastAPI ✓
├── PostgreSQL ✓
├── SQLAlchemy ✓
└── Alembic ✓
Identity
├── Organizations ✓
├── Users ✓
├── Memberships ✓
├── Authentication ✓
└── JWT ✓
Security
├── TenantContext ✓
├── Tenant Isolation ✓
├── RBAC ✓
├── Read Permissions ✓
├── Create Permissions ✓
└── Update Permissions ✓
CRM
├── Companies ✓
├── Contacts ✓
└── Opportunities ✓
Sales
├── Pipeline ✓
├── Opportunity Stages ✓
├── Probability ✓
└── Weighted Pipeline ✓
Interfaces
├── REST ✓
├── MCP ✓
└── ChatGPT ✓
ChatGPT UI
├── Pipeline Widget ✓
├── Company Detail ✓
├── Contact Detail ✓
├── Opportunity List ✓
├── Opportunity Detail ✓
├── Mutation Confirmation ✓
├── Company Creation ✓
├── Contact Creation ✓
├── Opportunity Creation ✓
└── Creation Results ✓
Mutation Governance
├── Mutation Requests ✓
├── Confirmation ✓
├── Expiry ✓
├── Cancellation ✓
├── Idempotency ✓
├── Transactions ✓
├── Optimistic Concurrency ✓
└── Audit Events ✓
Conversational Creation
├── Company Drafts ✓
├── Contact Drafts ✓
├── Opportunity Drafts ✓
├── Entity Resolution ✓
├── Missing-Field Detection ✓
├── Field Provenance ✓
├── Normalization ✓
├── Duplicate Detection ✓
├── Multi-Turn Completion ✓
├── Draft Correction ✓
├── Prepared Creation ✓
└── Safe Execution ✓
Workflow Composition
├── Dependency Detection ✓
├── Missing Company Handling ✓
├── Company → Contact ✓
├── Company → Opportunity ✓
├── Workflow Correlation ✓
└── Resume Original Intent ✓
ChatGPT CRM Operations
├── Read Pipeline ✓
├── Read Companies ✓
├── Read Contacts ✓
├── Read Opportunities ✓
├── Create Company ✓
├── Create Contact ✓
├── Create Opportunity ✓
├── Update Opportunity Stage ✓
├── Create Task -
├── Create Activity -
├── Record Note -
└── Record Meeting -
Activities -
Tasks -
Meetings -
Notes -
AI Intelligence -

140. Acceptance Criteria

Part 21 is complete when:

✓ Part 20 regression suite remains green
✓ contacts.create permission exists
✓ Viewer cannot create Contacts
✓ authorized roles can create Contacts
✓ execution rechecks permission
✓ ContactDraft model exists
✓ ContactDraft migration applies
✓ ContactDraft is tenant-scoped
✓ ContactDraft is user-scoped
✓ ContactDraft supports expiry
✓ ContactDraft supports cancellation
✓ ContactDraft supports conversion
✓ ContactDraft supports workflow_id
✓ first_name is supported
✓ last_name is supported
✓ Company relationship is required
✓ email is optional
✓ phone is optional
✓ job_title is optional
✓ description is optional
✓ TenantContext supplies organization_id
✓ ChatGPT cannot supply organization_id
✓ Company IDs are server-resolved
✓ name normalization works
✓ normalized full name exists
✓ email normalization works
✓ email validation works
✓ email normalization is conservative
✓ phone normalization works
✓ missing country codes are not guessed
✓ create_contact_draft exists
✓ update_contact_draft exists
✓ draft tools create no Contact
✓ missing required fields are server-defined
✓ recommended optional fields can be returned separately
✓ complete minimal Contact can proceed without unnecessary questions
✓ Company resolution reuses Part 20 logic
✓ exact Company resolution works
✓ ambiguous Company requires clarification
✓ missing Company becomes dependency
✓ cross-tenant Company cannot resolve
✓ Contact draft survives missing Company workflow
✓ Contact details do not need to be re-entered
✓ Company creation can resolve Contact dependency
✓ new company_id is attached to ContactDraft
✓ ContactDraft is revalidated after dependency resolution
✓ duplicate detection is tenant-scoped
✓ exact normalized email is detected
✓ exact normalized phone can be detected
✓ Company + normalized name is detected
✓ same name at different Company is not automatically identical
✓ cross-tenant email does not count as duplicate
✓ strong duplicate can resolve existing Contact
✓ possible duplicate is surfaced
✓ possible duplicate is not silently merged
✓ Contact merge is not required for MVP
✓ prepare_contact_creation exists
✓ incomplete Contact cannot prepare
✓ expired Contact cannot prepare
✓ invalid Company cannot prepare
✓ preparation rechecks duplicates
✓ preparation creates no Contact
✓ contact.create MutationRequest exists
✓ MutationRequest stores exact proposed values
✓ confirmation expires
✓ editing draft invalidates old confirmation
✓ Contact confirmation widget exists
✓ Contact name is visible
✓ Company relationship is visible
✓ email is visible when present
✓ phone is visible when present
✓ job title is visible when present
✓ Create Contact action is explicit
✓ Cancel creates no Contact
✓ create_contact accepts mutation_request_id
✓ arbitrary execution-time Contact fields are rejected
✓ execution rechecks tenant
✓ execution rechecks user
✓ execution rechecks permission
✓ execution rechecks request state
✓ execution rechecks expiry
✓ execution rechecks Company
✓ execution rechecks duplicates
✓ execution revalidates Contact
✓ Contact creation is transactional
✓ Contact ID is server-generated
✓ Contact version starts at 1
✓ AuditEvent is transactional
✓ MutationRequest becomes executed
✓ ContactDraft becomes converted
✓ failed transaction rolls back
✓ duplicate execution is idempotent
✓ one MutationRequest creates at most one Contact
✓ one logical AuditEvent is produced
✓ authoritative Contact result is returned
✓ ChatGPT reports success only after authoritative execution
✓ Contact success widget uses authoritative data
✓ search_contacts exists
✓ Contact search is tenant-scoped
✓ Contact search supports name
✓ Contact search supports email
✓ Contact search supports Company
✓ search results are limited
✓ Company detail can surface Contacts
✓ Contact detail can surface Company
✓ Company → Contact chained workflow works
✓ cancellation leaves Contact unresolved
✓ Company creation resumes Contact workflow
✓ Company and Contact AuditEvents can share workflow_id
✓ one-shot Contact creation works
✓ minimal Contact creation works
✓ multi-turn Contact completion works
✓ correction-before-confirmation works
✓ Quorentra reports version 0.8.0

Most importantly:

A user can now add a person to Quorentra naturally, associate that person with an authoritative Company, safely resolve duplicates, create missing Company dependencies when necessary, review the structured Contact, explicitly confirm creation, and receive an auditable authoritative CRM record.


141. What We Have Achieved

Our conversational CRM can now understand:

Add Sarah Johnson at Adventure Works. She’s the IT Director and her email is sarah.johnson@adventure-works.com.

and execute:

Natural Language
↓
Contact Intent
↓
Extract Explicit Facts
↓
Resolve Company
↓
Normalize Contact Data
↓
Duplicate Detection
↓
Contact Draft
↓
Validate
↓
Prepare
↓
Confirmation
↓
Create Contact
↓
Audit
↓
Authoritative CRM State

If the Company is missing:

Contact Intent
↓
Company Missing
↓
Create Company
↓
Resume Contact
↓
Create Contact

The same architecture now supports multiple business entities.


142. The Core CRM Relationship Model

We now have:

                  Company
                 /       \
                /         \
               ▼           ▼
           Contact     Opportunity

That small graph is extremely important.

It represents the basic commercial relationship:

Who is the customer?
↓
Company
Who are we talking to?
↓
Contact
What are we trying to sell?
↓
Opportunity

This is the nucleus of a CRM.


143. But Something Is Still Missing

The CRM now knows:

Adventure Works
Sarah Johnson
IT Director
Azure Migration
€90,000

But it does not know:

What actually happened?

For example:

Called Sarah
Sent proposal
Customer requested revised pricing
Technical workshop completed
Follow-up scheduled
Contract discussion held

These events form the history of the relationship.

That means the next domain we need is:

Activity

144. Why Activities Come Next

A CRM without Activities is essentially a structured address book plus pipeline database.

The real customer relationship is represented by interactions over time.

For example:

Adventure Works
│
├── Sarah Johnson
│
├── Azure Migration
│
└── Timeline
│
├── Call
├── Email
├── Meeting
├── Note
└── Status Change

That timeline becomes increasingly important for both humans and AI.


145. Activity Is the Beginning of CRM Memory

Once Quorentra stores Activities, ChatGPT can eventually answer:

What happened with Adventure Works last week?

When did I last speak with Sarah?

What did the customer say about pricing?

Which opportunities have had no activity for 30 days?

What should I follow up on today?

Those questions require a reliable interaction history.


146. Keep the Next Step Modular

We should not immediately build:

Email synchronization
Calendar synchronization
Meeting transcription
Teams integration
Slack integration
Automatic activity capture

Those are later modules.

First build a minimal:

Activity

domain.

Allow users to record:

Call
Email
Meeting
Note

manually through ChatGPT.

That gives us a running useful system immediately.


147. Example Next Interaction

User:

Record that I called Sarah Johnson at Adventure Works today. We discussed the Azure migration and she asked for revised pricing.

Quorentra should eventually structure:

Activity Type:
Call
Contact:
Sarah Johnson
Company:
Adventure Works
Opportunity:
Azure Migration
Date:
Today
Summary:
Discussed Azure migration. Customer requested revised pricing.

Then:

Resolve Entities
↓
Activity Draft
↓
Validate
↓
Confirm
↓
Create Activity
↓
Timeline

148. Activity Dependencies

This gives us another chance to reuse our architecture.

An Activity may reference:

Company
Contact
Opportunity

For example:

Call
↓
Sarah Johnson
↓
Adventure Works
↓
Azure Migration

Entity resolution becomes increasingly central to Quorentra.


149. AI Value Begins to Increase

Once Activities accumulate, ChatGPT can reason over:

Company
Contact
Opportunity
Activity Timeline

That is where Quorentra begins moving from:

Conversational Data Entry

toward:

Conversational CRM Intelligence

But we should earn that intelligence by first building reliable underlying data.


150. Next Article

In Part 22, we will build:

Recording CRM Activities from ChatGPT — Calls, Emails, Meetings, Notes, Entity Resolution, and the Customer Timeline

We will introduce:

activities.create permission
Activity model
ActivityDraft
Activity types
├── Call
├── Email
├── Meeting
└── Note
Activity timestamp
Activity subject
Activity summary
Company relationship
Contact relationship
Opportunity relationship
Entity resolution
Optional relationships
Missing-field detection
Activity validation
Activity confirmation
Prepared Activity mutations
Idempotent Activity creation
Activity AuditEvents
Company timeline
Contact timeline
Opportunity timeline
Activity widgets
Workflow correlation

Our target interaction will be:

User:
"Record that I called Sarah Johnson at
Adventure Works today about the Azure
migration. She asked for revised pricing."

Quorentra will resolve:

Sarah Johnson
↓
Contact
Adventure Works
↓
Company
Azure Migration
↓
Opportunity

then construct:

Activity
Type:
Call
Date:
Today
Contact:
Sarah Johnson
Company:
Adventure Works
Opportunity:
Azure Migration
Summary:
Discussed the Azure migration.
Customer requested revised pricing.

After confirmation:

Create Activity
↓
Company Timeline
↓
Contact Timeline
↓
Opportunity Timeline

At that point, Quorentra will no longer merely know who the customer is and what we are selling.

It will begin remembering what happened in the relationship.

That is the next major step toward a genuinely useful modular, ChatGPT-native AI CRM.

Quorentra

Contact

Menu

Designed with WordPress