AI Agent Chat Panel — Backend Requirements
Summary of Changes
The AI chat panel is now available on both company and jobseeker dashboards as a collapsible side panel. It sends page context with each message so the agent can provide contextual suggestions and actions.
CRITICAL: Backend Schema Changes Required
1. Make companyId optional in StartConversationInput
Currently companyId is String! (required) and has a foreign key to the Company table. Jobseekers don't have a company, so this must be nullable.
# BEFORE
input StartConversationInput {
agentId: String!
userId: String!
companyId: String! # <-- FK to Company table
title: String
}
# AFTER
input StartConversationInput {
agentId: String!
userId: String!
companyId: String # <-- Make nullable, remove FK constraint for jobseekers
title: String
}
Database migration needed: AgentConversation.companyId must be nullable.
2. Make companyId optional in GET_CONVERSATIONS query
# BEFORE
conversations(companyId: String!, ...): ConversationList
# AFTER
conversations(companyId: String, userId: String, ...): ConversationList
When companyId is null, filter by userId instead.
3. Make companyId optional in CreateAgentInput
For jobseeker agents, there's no company. The agent belongs to the user directly.
# BEFORE
input CreateAgentInput {
companyId: String!
...
}
# AFTER
input CreateAgentInput {
companyId: String # nullable — if null, agent belongs to user
userId: String # new field — owner when no company
...
}
4. Make companyId optional in GET_AGENTS query
# Allow fetching agents by userId when no companyId
agents(companyId: String, userId: String, ...): AgentList
5. Accept pageContext and entityId in messages
Add fields to SendMessageInput
input SendMessageInput {
conversationId: String!
content: String!
attachments: [AttachmentInput!]
forcedTools: [String!]
pageContext: String # NEW — e.g. "talents", "pipeline", "js_jobs"
entityId: String # NEW — UUID of entity being viewed
}
Page Context Values
Company pages:
pageContext | Route | Entity |
|---|---|---|
dashboard | /company/dashboard | — |
pipeline | /company/pipeline | — |
talents | /company/resume/talents | — |
talent_detail | /company/resume/talents/:id | talent UUID |
talentpool | /company/resume/talentpool | — |
candidates | /company/resume/candidates | — |
candidate_detail | /company/resume/candidates/:id | candidate UUID |
sharelist | /company/resume/sharelist | — |
jobs | /company/jobs | — |
job_detail | /company/jobs/:id | job UUID |
interviews | /company/interviews | — |
meetings | /company/meetings | — |
team | /company/team | — |
connections | /company/connections | — |
Jobseeker pages:
pageContext | Route | Entity |
|---|---|---|
js_dashboard | /jobseeker/dashboard | — |
js_jobs | /jobseeker/jobs | — |
js_job_detail | /jobseeker/jobs/:id | job UUID |
js_applications | /jobseeker/application | — |
js_interviews | /jobseeker/interviews | — |
js_interview_detail | /jobseeker/interviews/:id | interview UUID |
js_resume | /jobseeker/resume | — |
js_connections | /jobseeker/connections | — |
6. System Prompt Injection by Page Context
When pageContext is provided, inject context into the system prompt:
For list pages:
The user is currently on the "{label}" page.
Prefer tools relevant to this context: {relevant tool names}.
For detail pages (entityId present):
The user is viewing a specific {entity type} (ID: {entityId}).
You can perform actions on this entity.
When the user says "edit this", "contact them", etc., use the entity ID.
For jobseeker pages:
The user is a job seeker on the "{label}" page.
Help them with job search, applications, CV improvement, and interview preparation.
7. Required Tools — Company
Search / Query
| Tool | Description | Priority pages |
|---|---|---|
search_talents | Find talent profiles | talents, talentpool |
search_jobs | Search job listings | jobs |
search_candidates | Pipeline candidates | pipeline, candidates |
get_company_info | Company details | dashboard |
get_pipeline_overview | Pipeline stages & counts | pipeline, dashboard |
get_interviews | Interview list | interviews |
get_meetings | Meeting list | meetings |
get_team_members | Team members & roles | team |
get_connections | Partners & contacts | connections |
rag_search | Knowledge base search | knowledge base |
database_query | Custom SQL query | any (advanced) |
Create / Action
| Tool | Description | Priority pages |
|---|---|---|
create_talent | Add talent profile | talents |
create_job | Post new job | jobs |
extract_cv | Parse CV from file | talents, candidates, talent_detail |
parse_job | Parse job description | jobs, job_detail |
import_talents | Bulk import CSV/PDF | talents |
share_talent | Share talent profile | sharelist, talent_detail |
Entity Actions (detail pages)
| Tool | Description | Pages |
|---|---|---|
edit_talent | Edit talent profile fields | talent_detail |
contact_talent | Send message to talent | talent_detail |
add_to_pipeline | Add to job pipeline | talent_detail |
get_match_score | Calculate job match score | talent_detail, candidate_detail |
edit_job | Edit job posting | job_detail |
duplicate_job | Copy job to other companies | job_detail |
edit_candidate | Edit candidate details | candidate_detail |
update_candidate_status | Change pipeline stage | candidate_detail |
8. Required Tools — Jobseeker
Search / Query
| Tool | Description | Priority pages |
|---|---|---|
search_jobs | Find job listings | js_jobs, js_dashboard |
get_applications | View application status | js_applications, js_dashboard |
get_interviews | Upcoming interviews | js_interviews, js_dashboard |
get_match_score | Job match score | js_job_detail |
get_profile_tips | Profile improvement tips | js_dashboard |
Actions
| Tool | Description | Pages |
|---|---|---|
apply_job | Apply to a job | js_job_detail |
save_job | Save job for later | js_job_detail |
withdraw_application | Withdraw application | js_applications |
improve_cv | Get CV suggestions | js_resume |
create_cv | Build a new CV | js_resume |
prepare_interview | Practice questions & tips | js_interviews, js_interview_detail |
9. Default Agent Auto-Creation
When to create
The frontend auto-creates a default agent when:
- A new company is created (onboarding + add-company flows)
- The chat panel opens and no agents exist for the user/company
Default agent config
{
"name": "AI Assistant",
"type": "RECRUITMENT_ASSISTANT",
"ragEnabled": true,
"llmModel": "eu.amazon.nova-lite-v1:0",
"enabledTools": ["RAG_SEARCH"]
}
Backend recommendation
Make CreateAgent idempotent — if the company/user already has an agent, return the existing one instead of creating a duplicate.
10. Tool Priority by Page Context
When the frontend sends pageContext and no forcedTools, the backend should prefer tools matching that context. This is a hint, not a restriction.
Company
pageContext | Priority tools |
|---|---|
dashboard | get_company_info, get_pipeline_overview, search_jobs |
pipeline | search_candidates, get_pipeline_overview, update_candidate_status |
talents | search_talents, create_talent, extract_cv, import_talents |
talent_detail | edit_talent, contact_talent, add_to_pipeline, get_match_score |
candidates | search_candidates, get_match_score |
candidate_detail | edit_candidate, update_candidate_status, get_match_score |
jobs | search_jobs, create_job, parse_job |
job_detail | edit_job, duplicate_job, search_candidates |
interviews | get_interviews |
meetings | get_meetings |
team | get_team_members |
connections | get_connections |
sharelist | share_talent, search_talents |
Jobseeker
pageContext | Priority tools |
|---|---|
js_dashboard | search_jobs, get_applications, get_interviews, get_profile_tips |
js_jobs | search_jobs, get_match_score |
js_job_detail | apply_job, save_job, get_match_score |
js_applications | get_applications, withdraw_application |
js_interviews | get_interviews, prepare_interview |
js_interview_detail | prepare_interview |
js_resume | improve_cv, create_cv |
11. Implementation Steps (Backend)
- Database migration: Make
AgentConversation.companyIdnullable, adduserIdindex - GraphQL schema: Make
companyIdoptional inStartConversationInput,CreateAgentInput,GET_CONVERSATIONS,GET_AGENTS - Add
pageContextandentityIdfields toSendMessageInput - System prompt builder: Inject page context into the system prompt when provided
- Tool priority resolver: When
pageContextis provided withoutforcedTools, use the priority mapping above to hint which tools to prefer - Implement jobseeker tools:
apply_job,save_job,withdraw_application,improve_cv,create_cv,prepare_interview,get_profile_tips - Implement entity action tools:
edit_talent,contact_talent,add_to_pipeline,edit_job,duplicate_job,edit_candidate,update_candidate_status - Default agent creation: Make
CreateAgentidempotent — return existing agent if one exists for the company/user - Agent ownership model: Support agents owned by userId (jobseekers) in addition to companyId (companies)
12. Frontend Access to Agent Management & Knowledge Base
Company users can still manage agents and knowledge base from the sidebar:
- AI Agents:
/company/chatbot/agents— create, edit, enable/disable agents - Knowledge Base:
/company/chatbot/knowledge— upload documents for RAG
These pages are accessible from the sidebar nav under "AI".
For jobseekers, agent management is not exposed — they use the auto-created default agent.