Initiates Twilio voice calls, returns call/summary responses, and handles API errors via typed client.
// Source: https://github.com/VapiAI/prank-your-dad | License: MIT | Copyright 2025 Vapi
// Provided via justclaw.it.com; keep this notice with the code.
import type { PrankCallRequest, CallApiResponse, CallSummaryResponse } from '@/types';
class ApiError extends Error {
constructor(message: string, public status?: number) {
super(message);
this.name = 'ApiError';
}
}
export async function startPrankCall(request: PrankCallRequest): Promise<CallApiResponse> {
const response = await fetch('/api/prank-call', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(request),
});
const data = await response.json();
if (!response.ok) {
throw new ApiError(data.error || 'Failed to start call', response.status);
}
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key