Zum Hauptinhalt springen

Installation

npm install itellicoai

Anforderungen

  • Node.js 18.10.0+
  • Vollständige TypeScript-Unterstützung

API-Schlüssel erhalten

Um das SDK zu verwenden, benötigst du einen API-Schlüssel aus deinem itellicoAI Dashboard:
  1. Navigiere zu Entwickler in der Seitenleiste
  2. Klicke auf API-Schlüssel
  3. Klicke auf API-Schlüssel erstellen
  4. Kopiere den generierten Schlüssel zur Verwendung mit dem SDK
API-Schlüssel Dashboard
API-Schlüssel Dashboard
Speichere deinen API-Schlüssel sicher mit Umgebungsvariablen. Committe ihn niemals in die Versionskontrolle.

Schnellstart

import { Itellicoai } from 'itellicoai';

// Client initialisieren
const client = new Itellicoai({
  apiKey: 'your-api-key',
});

// Einen Agenten erstellen
const agent = await client.agents.create({
  accountId: 'your-account-id',
  name: 'Kundensupport-Agent',
  model: {
    provider: 'openai',
    model: 'gpt-4o-mini',
  },
  voice: {
    provider: 'elevenlabs',
    voiceId: 'EXAVITQu4vr4xnSDxMaL',
  },
  transcriber: {
    provider: 'deepgram',
    model: 'nova-2:general',
    language: 'en-US',
  },
  initialMessage: {
    mode: 'fixed_message',
    message: 'Hallo! Wie kann ich Ihnen heute helfen?',
    delayMs: 1000,
  },
  maxDurationSeconds: 1800,
  tags: ['support', 'kundenservice'],
});

console.log(`Agent erstellt: ${agent.id}`);

SDK-Operationen

Agentenverwaltung

Agenten auflisten

const agents = await client.agents.list();

agents.forEach(agent => {
  console.log(`${agent.name} - ${agent.id}`);
});

Agent abrufen

const agent = await client.agents.retrieve('agent_123abc');

console.log(`Agentenname: ${agent.name}`);
console.log(`Modell: ${agent.model.model}`);

Agent aktualisieren

const updatedAgent = await client.agents.update('agent_123abc', {
  name: 'Aktualisierter Support-Agent',
  instructions: 'Sie sind ein hilfreicher Kundensupport-Agent...',
});

Agent archivieren

import { Itellicoai } from 'itellicoai';


import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'your-api-key',
});

await client.agents.archive('agent_id', { account_id: 'me' });

Konversationen auflisten

import { Itellicoai } from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'your-api-key'
});

const conversations = await client.accounts.listConversations('account_id', {
  limit: 10
});

console.log(`Gesamtanzahl Konversationen: ${conversations.count}`);

conversations.items.forEach((conv: any) => {
  console.log(`Konversations-ID: ${conv.conversation_id}`);
  console.log(`Kontakt: ${conv.contact_number}`);
  console.log(`Dauer: ${conv.duration_seconds}s`);
  console.log(`Status: ${conv.status}`);
  console.log(`Agenten-ID: ${conv.agent_id}`);
});

Telefonnummern auflisten

import { Itellicoai } from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'your-api-key',
});

const phoneNumbers = await client.accounts.phoneNumbers.list('account_id');

console.log(phoneNumbers.count);

Telefonnummer erstellen

import { Itellicoai } from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'your-api-key',
});

const phoneNumber = await client.accounts.phoneNumbers.create('account_id', {
  sipTrunkId: 'sip_trunk_id',
});

console.log(phoneNumber.id);

Telefonnummer abrufen

import { Itellicoai } from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'your-api-key',
});

const phoneNumber = await client.accounts.phoneNumbers.retrieve(
  'account_id',
  'phone_number_id'
);

console.log(phoneNumber.id);

Telefonnummer aktualisieren

import { Itellicoai } from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'your-api-key',
});

const phoneNumber = await client.accounts.phoneNumbers.update(
  'account_id',
  'phone_number_id'
);

console.log(phoneNumber.id);

Telefonnummer löschen

import { Itellicoai } from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'your-api-key',
});

await client.accounts.phoneNumbers.delete(
  'account_id',
  'phone_number_id'
);

Modelle auflisten

import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'My API Key',
});

const response = await client.accounts.providers.listModels('account_id');

console.log(response);

Transcriber auflisten

import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'My API Key',
});

const response = await client.accounts.providers.listTranscribers('account_id');

console.log(response);

Stimmen auflisten

import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'My API Key',
});

const response = await client.accounts.providers.listVoices('account_id', { provider: 'provider' });

console.log(response);

SIP-Trunks auflisten

import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'My API Key',
});

const sipTrunks = await client.accounts.sipTrunks.list('account_id');

console.log(sipTrunks.count);

SIP-Trunk erstellen

import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'My API Key',
});

const sipTrunk = await client.accounts.sipTrunks.create('account_id');

console.log(sipTrunk.id);

SIP-Trunk abrufen

import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'My API Key',
});

const sipTrunk = await client.accounts.sipTrunks.retrieve('sip_trunk_id', { account_id: 'account_id' });

console.log(sipTrunk.id);

SIP-Trunk aktualisieren

import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'My API Key',
});

const sipTrunk = await client.accounts.sipTrunks.update('sip_trunk_id', { account_id: 'account_id' });

console.log(sipTrunk.id);

SIP-Trunk löschen

import Itellicoai from 'itellicoai';

const client = new Itellicoai({
  apiKey: 'My API Key',
});

await client.accounts.sipTrunks.delete('sip_trunk_id', { account_id: 'account_id' });

Nutzungsanalysen abrufen

const response = await client.accounts.analytics.getUsage('account_id');

console.log(response.meta);

Unterkonten auflisten

const subaccounts = await client.accounts.subaccounts.list('account_id');

console.log(subaccounts.count);

Unterkonto erstellen

const account = await client.accounts.subaccounts.create('account_id', {
  name: 'name',
});

console.log(account.id);

Unterkonto abrufen

const account = await client.accounts.subaccounts.retrieve(
  'account_id',
  'subaccount_id'
);

console.log(account.id);

Unterkonto aktualisieren

const account = await client.accounts.subaccounts.update(
  'account_id',
  'subaccount_id'
);

console.log(account.id);

Fehlerbehandlung

import {
  ItellicoAI,
  AuthenticationError,
  NotFoundError,
  RateLimitError,
  APIError,
} from 'itellicoai';

const client = new ItellicoAI({ apiKey: 'your-api-key' });

try {
  const agent = await client.agents.retrieve('agent_123abc');
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Ungültiger API-Schlüssel');
  } else if (error instanceof NotFoundError) {
    console.error('Agent nicht gefunden');
  } else if (error instanceof RateLimitError) {
    console.error('Ratenlimit überschritten');
  } else if (error instanceof APIError) {
    console.error(`API-Fehler: ${error.message}`);
  }
}

Umgebungsvariablen

import { ItellicoAI } from 'itellicoai';

// API-Schlüssel wird automatisch aus der ITELLICO_API_KEY-Umgebungsvariable geladen
const client = new ItellicoAI();

// Oder explizit setzen
const client = new ItellicoAI({
  apiKey: process.env.ITELLICO_API_KEY,
});

TypeScript-Typen

Vollständige TypeScript-Definitionen enthalten:
import type {
  Agent,
  AgentCreateParams,
  AgentUpdateParams,
  Conversation,
  PhoneNumber,
} from 'itellicoai';

const createAgent = async (
  params: AgentCreateParams
): Promise<Agent> => {
  const client = new ItellicoAI();
  return await client.agents.create(params);
};

Ressourcen