Hirely-Backend / AI_INTERVIEW_UI_INTEGRATION.md
NaikPranav11's picture
Initial clean deployment
1207440
|
Raw
History Blame Contribute Delete
9.17 kB
# AI Interview UI Integration - Complete βœ…
## What Was Added
### 1. API Methods (`frontend/src/services/api.js`)
Added three new methods:
```javascript
async createAIInterviewSession(interviewId)
async getAIInterviewSession(sessionId)
async completeAIInterview(sessionId, data)
```
### 2. Interviews Page Updates (`frontend/src/pages/Interviews.jsx`)
**New Features:**
- "Start AI Interview" button in header (opens modal)
- AI Interview selection modal
- `handleStartAIInterview()` function
- Opens AI interview in new tab
**How it works:**
1. Click "Start AI Interview" button
2. Modal shows all scheduled AI interviews
3. Click on an interview to start
4. Creates session via API
5. Opens `/ai-interview?interview=X&session=Y` in new tab
### 3. Interviews Table Updates (`frontend/src/components/interviews/InterviewsTable.jsx`)
**New Features:**
- Robot icon button for AI interviews
- Only shows for AI type interviews
- Only shows for non-cancelled/non-completed interviews
- Calls `onStartAI` handler
---
## How to Test
### Step 1: Ensure Backend is Running
```bash
cd backend
python api_app.py
```
### Step 2: Ensure Frontend is Running
```bash
cd frontend
npm run dev
```
### Step 3: Test from Interviews Page
1. **Login to the app:**
- Go to `http://localhost:5173`
- Login with admin credentials
2. **Navigate to Interviews page:**
- Click "Interviews" in sidebar
3. **Option A: Use "Start AI Interview" Button**
- Click yellow "Start AI Interview" button in header
- Modal opens showing all scheduled AI interviews
- Click on an interview
- New tab opens with AI interview
4. **Option B: Use Table Action Button**
- Find an AI interview in the table (has robot icon)
- Click the robot icon in Actions column
- New tab opens with AI interview
### Step 4: Complete the Interview
In the new tab:
1. Interview starts automatically
2. Answer questions via text
3. View real-time scores
4. Complete all questions
5. See final score
---
## User Flow Diagram
```
Interviews Page
↓
[Start AI Interview Button] or [Robot Icon in Table]
↓
Create Session (API Call)
↓
Open New Tab: /ai-interview?interview=X&session=Y
↓
AI Interview Component
↓
WebSocket Connection
↓
Interview Flow
↓
Completion Screen
```
---
## Features Added
### 1. Start AI Interview Button
- **Location:** Top of Interviews page
- **Color:** Yellow (stands out)
- **Action:** Opens modal with AI interview list
- **Icon:** Video camera
### 2. AI Interview Selection Modal
- **Shows:** All scheduled AI interviews
- **Filters:** Excludes cancelled/completed
- **Display:** Candidate name, job, date, time, status
- **Action:** Click to start interview
### 3. Table Action Button
- **Location:** Actions column in table
- **Icon:** Robot (Bot)
- **Visibility:** Only for AI interviews
- **Condition:** Not cancelled or completed
- **Action:** Directly starts interview
---
## API Integration
### Create Session Endpoint
```
POST /api/v1/ai-interview/session/create?interview_id=1
Authorization: Bearer <token>
Response:
{
"session_id": "uuid",
"interview_id": 1,
"created_at": "timestamp"
}
```
### Frontend Flow
```javascript
// 1. Create session
const session = await apiService.createAIInterviewSession(interviewId);
// 2. Build URL
const url = `/ai-interview?interview=${interviewId}&session=${session.session_id}`;
// 3. Open in new tab
window.open(url, '_blank');
```
---
## Testing Checklist
### Prerequisites:
- [ ] Backend running on port 8000
- [ ] Frontend running on port 5173
- [ ] Logged in as admin
- [ ] At least one AI interview scheduled
### Test Cases:
#### Test 1: Start from Button
- [ ] Click "Start AI Interview" button
- [ ] Modal opens
- [ ] AI interviews are listed
- [ ] Click an interview
- [ ] New tab opens
- [ ] Interview starts
#### Test 2: Start from Table
- [ ] Find AI interview in table
- [ ] Robot icon is visible
- [ ] Click robot icon
- [ ] New tab opens
- [ ] Interview starts
#### Test 3: No AI Interviews
- [ ] Cancel all AI interviews
- [ ] Click "Start AI Interview" button
- [ ] Modal shows "No AI interviews available"
- [ ] Message suggests scheduling one
#### Test 4: Completed Interview
- [ ] Complete an AI interview
- [ ] Go back to Interviews page
- [ ] Robot icon should not appear for completed interview
- [ ] Interview should not appear in modal
#### Test 5: Error Handling
- [ ] Stop backend
- [ ] Try to start AI interview
- [ ] Error alert appears
- [ ] User stays on Interviews page
---
## Screenshots Guide
### 1. Interviews Page with Button
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ [Schedule Interview] [Start AI Interview]β”‚
β”‚ β”‚
β”‚ Interview List β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Candidate | Role | Type | Actions β”‚ β”‚
β”‚ β”‚ John Doe | Dev | AI | [πŸ€–][✏️][❌]β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
### 2. AI Interview Selection Modal
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Start AI Interview [βœ•]β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Select an AI interview to start β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ [JD] John Doe β”‚ β”‚
β”‚ β”‚ Software Developer β”‚ β”‚
β”‚ β”‚ πŸ“… Feb 12 πŸ• 2:00 PM β”‚ β”‚
β”‚ β”‚ [Start] ──→ β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β”‚ [Cancel] β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
### 3. New Tab Opens
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ AI Interview β”‚
β”‚ Question 1 of 5 β”‚
β”‚ β”‚
β”‚ [Video Preview] β”‚
β”‚ β”‚
β”‚ Q: Tell me about yourself? β”‚
β”‚ β”‚
β”‚ [Text Input Area] β”‚
β”‚ β”‚
β”‚ [Submit Answer] β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
---
## Next Steps
### Immediate (Optional):
1. Add loading state while creating session
2. Add success notification
3. Store interview results in database
4. Create results view page
### Future Enhancements:
1. Copy interview link to clipboard
2. Email interview link to candidate
3. Track interview status (not started, in progress, completed)
4. Show interview results in table
5. Add "View Results" button for completed interviews
---
## Troubleshooting
### Issue: "Start AI Interview" button doesn't work
**Solution:** Check browser console for errors. Ensure backend is running.
### Issue: Modal shows no interviews
**Solution:** Schedule an AI interview first. Check that interview type is "ai_interview".
### Issue: New tab doesn't open
**Solution:** Check browser popup blocker. Allow popups for localhost.
### Issue: Interview doesn't start
**Solution:** Check WebSocket connection. Ensure session was created successfully.
### Issue: Robot icon doesn't appear
**Solution:** Ensure interview type is "AI" and status is not "Cancelled" or "Completed".
---
## Code Changes Summary
### Files Modified:
1. `frontend/src/services/api.js` - Added 3 methods
2. `frontend/src/pages/Interviews.jsx` - Added button, modal, handler
3. `frontend/src/components/interviews/InterviewsTable.jsx` - Added robot icon button
### Lines Added: ~150
### Files Created: 0
### Time Taken: ~30 minutes
---
## Success Criteria
βœ… "Start AI Interview" button visible
βœ… Button opens modal
βœ… Modal shows AI interviews
βœ… Clicking interview opens new tab
βœ… Robot icon appears in table
βœ… Robot icon starts interview
βœ… New tab loads AI interview
βœ… Interview starts automatically
βœ… No console errors
---
**Status:** Complete and Ready for Testing βœ…
**Last Updated:** February 12, 2026
**Next:** Test in browser and store results