Zum Hauptinhalt springen

Installation

npm install itellicoai

Voraussetzungen

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

Hol dir deinen API-Schlüssel

Um das SDK zu nutzen, brauchst du einen API-Schlüssel aus deinem itellicoAI-Dashboard:
1

Zu API-Schlüsseln gehen

Gehe zu Entwickler → API-Schlüssel
2

Schlüssel erstellen

Klicke auf API-Schlüssel erstellen
3

Schlüssel kopieren

Kopiere den generierten Schlüssel - er wird nur einmal angezeigt
Speichere deinen API-Schlüssel sicher mit Umgebungsvariablen. Checke ihn niemals in die Versionsverwaltung ein.

Schnellstart

import Itellicoai from 'itellicoai';

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

// Create an agent
const agent = await client.agents.create('your-account-id', {
  name: 'Customer Support Agent',
  model: {
    provider: 'openai',
    model: 'gpt-4o-mini',
  },
  voice: {
    provider: 'elevenlabs',
    voice_id: 'EXAVITQu4vr4xnSDxMaL',
  },
  transcriber: {
    provider: 'deepgram',
    model: 'nova-2:general',
    language: 'en-US',
  },
  initial_message: {
    mode: 'fixed_message',
    message: 'Hello! How can I assist you today?',
    delay_ms: 1000,
  },
  max_duration_seconds: 1800,
  tags: ['support', 'customer-service'],
});

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

SDK-Operationen

Agentenverwaltung

Agenten auflisten

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

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

Agent abrufen

const agent = await client.agents.retrieve('agent_123abc', {
  account_id: 'account_id',
});

console.log(`Agent name: ${agent.name}`);
console.log(`Model: ${agent.model.model}`);

Agent aktualisieren

const updatedAgent = await client.agents.update('agent_123abc', {
  account_id: 'account_id',
  name: 'Updated Support Agent',
  note: 'Updated prompt notes for the support team',
});

Agent archivieren

import Itellicoai from 'itellicoai';

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

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

Gespräche auflisten

import Itellicoai from 'itellicoai';

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

const conversations = await client.accounts.listConversations('account_id');

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

conversations.items.forEach((conv: any) => {
  console.log(`Conversation ID: ${conv.conversation_id}`);
  console.log(`Contact: ${conv.contact_number}`);
  console.log(`Duration: ${conv.duration_seconds}s`);
  console.log(`Status: ${conv.status}`);
  console.log(`Agent 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', {
  sip_trunk_id: '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(
  'phone_number_id',
  { account_id: 'account_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(
  'phone_number_id',
  {
    account_id: 'account_id',
    name: 'Support line',
  }
);

console.log(phoneNumber.id);

Telefonnummer löschen

import Itellicoai from 'itellicoai';

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

await client.accounts.phoneNumbers.delete(
  'phone_number_id',
  { account_id: 'account_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);

Transkribierer auflisten

import Itellicoai from 'itellicoai';

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

const response = await client.accounts.providers.listTranskribierers('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: 'elevenlabs' });

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', {
  name: 'Main SIP trunk',
});

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' });

Nutzungsanalytik abrufen

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

console.log(response.meta);

Subaccounts auflisten

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

console.log(subaccounts.count);

Subaccount erstellen

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

console.log(account.id);

Subaccount abrufen

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

console.log(account.id);

Subaccount aktualisieren

const account = await client.accounts.subaccounts.update(
  'subaccount_id',
  {
    account_id: 'account_id',
    name: 'Updated subaccount name',
  }
);

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', {
    account_id: 'account_id',
  });
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof NotFoundError) {
    console.error('Agent not found');
  } else if (error instanceof RateLimitError) {
    console.error('Rate limit exceeded');
  } else if (error instanceof APIError) {
    console.error(`API error: ${error.message}`);
  }
}

Umgebungsvariablen

import Itellicoai from 'itellicoai';

// API key automatically loaded from ITELLICOAI_API_KEY env var
const client = new Itellicoai();

// Or set explicitly
const client = new Itellicoai({
  apiKey: process.env.ITELLICOAI_API_KEY,
});

TypeScript-Typen

Vollständige TypeScript-Definitionen sind enthalten:
import Itellicoai from 'itellicoai';

const createAgent = async (
  params: Itellicoai.AgentCreateParams
): Promise<Itellicoai.AgentResponse> => {
  const client = new Itellicoai();
  return await client.agents.create('account_id', params);
};

Ressourcen

NPM-Paket

Von NPM installieren

GitHub-Repository

Quellcode auf GitHub ansehen

API-Referenz

REST-API-Dokumentation durchsuchen