@happ-integ/happ-voice
Клиент для Happ Voice Assistant API.
Установка
bash
pnpm add @happ-integ/happ-voiceИспользование
Инициализация
typescript
import { HappClient } from "@happ-integ/happ-voice";
const happ = new HappClient(env.SAAS_ACCESS_TOKEN, {
baseUrl: "https://my.happ.tools/api", // опционально
});Ассистенты
typescript
// Получить всех ассистентов
const assistants = await happ.getAssistants();
// Получить ассистента
const assistant = await happ.getAssistant("assistant-id");
// Создать ассистента
const newAssistant = await happ.createAssistant({
name: "Support Bot",
description: "Customer support assistant",
system_prompt: "You are helpful...",
});
// Обновить ассистента
await happ.updateAssistant("id", {
name: "Updated Name",
});Инициирование звонков
typescript
// Запустить звонок
const call = await happ.initiateCall({
phone_number: "+380501234567",
assistant_id: "assistant-id",
context: {
customer_name: "John",
company: "Acme",
},
});
// call = { id: "call-123", status: "initiated", phone: "+" }
// Получить статус звонка
const status = await happ.getCallStatus("call-123");
// => { id, status, duration, recording_url, transcript, ... }
// Завершить звонок
await happ.endCall("call-123");Звонки
typescript
// Получить все звонки
const calls = await happ.getAllCalls();
// Фильтр и пагинация
const recentCalls = await happ.getAllCalls({
status: "completed",
limit: 10,
offset: 0,
});
// Получить детали звонка
const call = await happ.getCall("call-123");
// Получить транскрипт
const transcript = await happ.getTranscript("call-123");Запись звонков
typescript
// Получить запись
const recording = await happ.getRecording("call-123");
// recording.url — ссылка для скачиванияHealth Check
typescript
const isHealthy = await happ.healthCheck();API
HappClient
typescript
new HappClient(accessToken: string, options?: { baseUrl?: string })Методы Ассистенты
getAssistants(): Promise<any[]>
getAssistant(id): Promise<any>
createAssistant(params): Promise<any>
updateAssistant(id, params): Promise<any>
Методы Звонки
initiateCall(params): Promise<any>
typescript
{
phone_number: string;
assistant_id: string;
context?: Record<string, any>;
}getCallStatus(callId): Promise<any>
endCall(callId): Promise<void>
getAllCalls(options?): Promise<any[]>
getCall(callId): Promise<any>
getTranscript(callId): Promise<string>
getRecording(callId): Promise<any>
Другое
healthCheck(): Promise<boolean>
Получить Access Token
- https://my.happ.tools/settings
- API Settings
- Create API Token
- Скопировать и добавить в Doppler / env
SAAS_ACCESS_TOKEN=xxxxxКогда использовать
- ✅ Voice call integration
- ✅ Outbound calling
- ✅ Call recording и analytics
- ✅ Transcript generation