Skip to content

Karan27q/-AI-First-CRM-HCP-Module-LogInteractionScreen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-First CRM (HCP Module) — Log Interaction Screen

Tech stack (per task):

  • Frontend: React + Redux (Toolkit), Google Inter
  • Backend: Python FastAPI
  • AI Agent: LangGraph
  • LLM: Groq (gemma2-9b-it)
  • DB: Postgres (Docker Compose)

Prereqs

  • Node.js 18+
  • Python 3.10+
  • Docker Desktop

Run (end-to-end)

1) Start Postgres

docker compose up -d

2) Backend (FastAPI + LangGraph)

cd backend
python -m venv .venv
.\.venv\Scripts\pip install -r requirements.txt
copy .env.example .env

Set GROQ_API_KEY in backend/.env.

Run the API (dev mode with reload):

.\.venv\Scripts\uvicorn app.main:app --reload --port 8000

Seed sample HCPs:

Invoke-RestMethod -Method Post -Uri http://127.0.0.1:8000/api/seed

3) Frontend (React + Redux)

cd frontend
npm install
npm run dev

Open http://localhost:5173/.

What’s implemented

  • Structured form matching image.png (Log HCP Interaction).
  • Conversational chat ("AI Assistant") that calls the backend LangGraph agent.
  • Chat → Form autofill:
    • Example input in the AI panel:
      Today I met with Dr. Sharma and discussed Product X efficacy, the sentiment was positive and I shared the brochures.
    • The system automatically:
      • selects HCP Name (e.g. Dr. Sharma) when a match exists in the HCP list,
      • sets Sentiment (Positive / Neutral / Negative),
      • fills Topics Discussed with the clinical/business discussion only,
      • fills Materials Shared (e.g. "Brochure shared"),
      • highlights updated fields on the form so you can review and manually fix anything.
  • Log button → DB:
    • After reviewing/editing the form, press Log to create an interaction row in Postgres via POST /api/interactions.
    • A small status message in the AI panel confirms success or shows validation errors.

LangGraph tools & backend normalization

  • LangGraph tools (minimum 5) defined in backend/app/agent.py:
    • tool_log_interaction (LLM summarization/entity extraction + structured patch)
    • tool_edit_interaction (edit flow, currently routed to same logic)
    • tool_search_hcp (placeholder)
    • tool_fetch_product_info (placeholder)
    • tool_suggest_followups (placeholder)

The backend agent normalizes LLM responses so /api/agent/chat always returns a structured suggested_patch with this field set: hcp_name, interaction_type, attendees, topics_discussed, outcomes, follow_up_actions, materials_shared, samples_distributed, sentiment
— even if the raw model output uses different key names. This keeps the chat-driven autofill robust and predictable.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors