Installation
# npm
npm install @codiris/interview-sdk
# yarn
yarn add @codiris/interview-sdk
# pnpm
pnpm add @codiris/interview-sdkRequirements: Node.js 16+ and React 18+ (for React components, optional).
Quick Start
Vanilla JavaScript/TypeScript
import { InterviewClient } from '@codiris/interview-sdk';
// 1. Initialize the client
const client = new InterviewClient({
apiKey: 'your-api-key',
});
// 2. Get a project
const { data: project } = await client.getProject('project-id');
// 3. List interviews
const { data: interviews } = await client.listInterviews(project.id);
console.log(`Found ${interviews.total} interviews`);React
import {
InterviewProvider,
InterviewEmbed,
useInterviews
} from '@codiris/interview-sdk/react';
// 1. Wrap your app with the provider
function App() {
return (
<InterviewProvider apiKey="your-api-key">
<InterviewPage />
</InterviewProvider>
);
}
// 2. Use hooks and components
function InterviewPage() {
return (
<InterviewEmbed
projectId="your-project-id"
onComplete={(interview) => {
console.log('Interview completed:', interview);
}}
/>
);
}Authentication
Getting an SDK Key
- Log in to your Codiris account at talk.codiris.build
- Go to Settings → SDK Keys
- Click Create Key
- Copy the generated key (it won't be shown again)
Using the SDK Key
const client = new InterviewClient({
apiKey: 'int_live_xxxxxxxxxxxxxxxxxxxxx',
});Environment Variables
Store your SDK key securely:
# .env
CODIRIS_INTERVIEW_KEY=int_live_xxxxxxxxxxxxxxxxxxxxxconst client = new InterviewClient({
apiKey: process.env.CODIRIS_INTERVIEW_KEY,
});Your First Interview
Creating a Project
const { success, data: project, error } = await client.createProject({
name: 'Engineering Interviews',
useCase: 'recruitment',
goal: 'Assess technical skills and cultural fit',
audience: 'Software engineers',
});
if (success) {
console.log('Project created:', project.id);
} else {
console.error('Failed:', error);
}Creating an Interview Token
// Create a token/invitation for a candidate
const { data: token } = await client.createToken(project.id, {
inviteeEmail: 'candidate@example.com',
inviteeName: 'John Doe',
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(), // 7 days
});
// Get the interview URL
const interviewUrl = client.getInterviewUrl(project.id, { token: token.token });
console.log('Interview link:', interviewUrl);Fetching Interview Results
const { data: interview } = await client.getInterview('interview-id');
console.log('Candidate:', interview.candidateName);
console.log('Status:', interview.status);
console.log('Duration:', interview.duration, 'seconds');
// Get AI-generated analysis
const { data: results } = await client.getResults('interview-id');
console.log('Analysis:', results);Embedding Interviews
Using the Widget Script
Add the widget to any website with a simple script tag:
<!-- Add to your HTML -->
<script
src="https://talk.codiris.build/widget-loader.js"
data-project-id="your-project-id"
data-position="bottom-right"
data-button-text="Start Interview"
async
></script>Widget Options
data-position- bottom-right, bottom-left, or centerdata-button-text- Custom button labeldata-theme- light or darkdata-auto-start- true to auto-open
React Integration
Provider Setup
Wrap your app with the provider at the root level:
// app.tsx or index.tsx
import { InterviewProvider } from '@codiris/interview-sdk/react';
function App() {
const config = {
apiKey: process.env.REACT_APP_INTERVIEW_API_KEY,
workspaceId: 'optional-workspace-id',
};
return (
<InterviewProvider {...config}>
<Router>
<Routes />
</Router>
</InterviewProvider>
);
}Embedding an Interview
import { InterviewEmbed } from '@codiris/interview-sdk/react';
function InterviewPage({ projectId }) {
return (
<InterviewEmbed
projectId={projectId}
width="100%"
height="600px"
theme="light"
onReady={() => console.log('Interview loaded!')}
onComplete={(interview) => {
console.log('Completed:', interview);
// Redirect to thank you page
}}
/>
);
}Using the Widget Component
import { InterviewWidget } from '@codiris/interview-sdk/react';
function App() {
return (
<div>
{/* Your app content */}
{/* Floating interview button */}
<InterviewWidget
projectId="your-project-id"
position="bottom-right"
buttonText="Take Interview"
onComplete={(interview) => {
console.log('Interview completed:', interview);
}}
/>
</div>
);
}Using Hooks
import { useInterviews, useInterview } from '@codiris/interview-sdk/react';
function InterviewDashboard({ projectId }) {
const { interviews, loading, error } = useInterviews(projectId);
if (loading) return <Spinner />;
if (error) return <Error message={error.message} />;
return (
<div>
<h1>Interviews ({interviews.total})</h1>
{interviews.items.map(interview => (
<InterviewCard key={interview.id} interview={interview} />
))}
</div>
);
}
function InterviewDetails({ interviewId }) {
const { interview, loading } = useInterview(interviewId);
if (loading) return <Spinner />;
return (
<div>
<h2>{interview.candidateName}</h2>
<p>Status: {interview.status}</p>
<p>Duration: {Math.round(interview.duration / 60)} minutes</p>
</div>
);
}