This plan outlines the expansion of the CRM module to include robust engagement logging (Phase 2) and intelligent automation (Phase 3).
Objective: unified view of all customer interactions (Calls, Emails, Meetings) with specific details for each type.
ActivityModel Enhancements:- Add
outcome(String?): For call results (e.g., "Voicemail", "Connected", "No Answer"). - Add
durationSeconds(Int?): For calls and meetings. - Add
location(String?): For meetings. - Add
attendees(Json?): For meeting participants. - Add
metadata(Json?): For flexible extensions (e.g. email headers, call recording URLs).
- Add
packages/contracts/src/crm/activity.types.ts:- Update
ActivityDtoto include new fields. - Update
CreateActivityInputto support specific payloads forCALL,MEETING,EMAIL.
- Update
PrismaActivityRepoAdapter: Map new fields to Prisma model.- Use Cases:
LogCallUseCase: Specialized use case for calls.LogMeetingUseCase: Specialized use case for meetings.LogEmailUseCase: Specialized use case for emails (manual logging).
- Timeline Aggregation: Ensure
GetTimelineUseCasereturns rich details for each activity type.
- Activity Feed (
Timeline):- Differentiate rendering for Calls, Meetings, Emails, and Notes.
- Show "Call Outcome" and "Duration" badges.
- Action Modals:
- Log Call: Duration slider, Outcome selector, Note.
- Log Meeting: Date/Time picker, Location, Attendees.
- Log Email: Subject, Body, To/CC (Manual logging for now).
Objective: Automate repetitive tasks using Sequences and leverage AI for content generation and decision support.
SequenceModel:name,ownerUserId,createdAt.
SequenceStepModel:sequenceId,stepOrder,type(EMAIL_AUTO, EMAIL_MANUAL, CALL, TASK),dayDelay,templateBody,templateSubject.
SequenceEnrollmentModel:sequenceId,entityId(Lead/Party),currentStep,status,nextExecutionAt.
SequenceRunner:- Polls active enrollments due for execution.
- Auto Email: Sends email via EmailService -> Logs
EMAILActivity -> Advances step. - Manual Email: Creates
EMAIL_DRAFTActivity -> Advances step (upon approval). - Task/Call: Creates
TASKActivity -> Advances step (upon completion).
- Smart Drafting:
GenerateEmailDraftTool: Uses LLM to draft email content based on Deal/Lead context and user prompt.- "Rewrite with AI" button in Email Modal.
- Next Best Action:
RecommendNextStepTool: Analyzes timeline to suggest: "Follow up in 3 days", "Enroll in 'New Lead' Sequence", or "Mark as Lost".
- Enrichment:
ExtractContactInfoTool: Parses email signature from raw text to update Contact details.
- Phase 2 Schema & Contracts (Foundation).
- Phase 2 Backend & UI (Engagement features).
- Phase 3 Schema & Worker (Automation engine).
- Phase 3 AI Tools (Intelligence layer).