→ quake_waitSchedule: Every 15m - Checks for new candidates created in Mercury in the last 15 minutes.
The Business Logic (Plain English)
This automated "Traffic Cop" ensures that every new candidate is routed to the correct consultant immediately, preventing ownership disputes and ensuring a fair spread of fresh leads.
The Watchdog (Scheduler): The workflow runs every 15 minutes to check for new candidates entering your Mercury system.
The Historian (Mercury - Placements & Activities): Before assigning the candidate, the agent checks their history. It asks: "Have we successfully placed this person before?" and "Has anyone spoken to them recently?"
The Team Lead (Mercury - System Users): It pulls a live list of your consultants in the relevant sector team.
The Judge (OpenAI): This is the brain. It analyzes the data found in step 2.
Scenario A (Re-allocation): If the candidate was placed by John previously, or John spoke to them last week, the AI selects John. This protects relationship continuity.
Scenario B (Round Robin): If the candidate is brand new (no history), the AI looks at the team list and assigns them to the next person in line, ensuring fair distribution of new leads.
The Assigner (Mercury - Update): Finally, it updates the candidate's record in Mercury, setting the "Owner" field to the selected consultant automatically.
→ quake_waitSchedule: Every 15m - Checks for new candidates created in Mercury in the last 15 minutes.
→ get__api_v1_contactsGet New Candidates - Retrieves the latest batch of candidate records from Mercury.
→ get__api_v1_candidates_{id}_placements
Check Placements
-
Checks if we have placed this candidate before to find the original owner.
→ get__api_v1_contacts_{contactId}_activities
Check Activities
-
Reviews recent call/email history to see if a consultant is already engaging.
→ get__api_v1_systemusersGet Team List - Fetches the list of active consultants to perform the Round Robin if needed.
→ openai_generate_jsonDecide Owner (AI) - AI Logic: If history exists -> Assign Previous Owner. If new -> Assign Round Robin.
→ patch__api_v1_contacts_{contactId}
Update Owner
-
Writes the selected Consultant ID back to the Candidate record in Mercury.