Installation
Prérequis
Node.js 18.10.0+
Support TypeScript complet
Obtenir Votre Clé API
Pour utiliser le SDK, vous aurez besoin d’une clé API depuis votre tableau de bord itellicoAI :
Accédez à Développeurs depuis la barre latérale
Cliquez sur Clés API
Cliquez sur Créer une Clé API
Copiez la clé générée pour l’utiliser avec le SDK
Stockez votre clé API en toute sécurité en utilisant des variables d’environnement. Ne la commitez jamais dans le contrôle de version.
Démarrage Rapide
import { Itellicoai } from 'itellicoai' ;
// Initialize client
const client = new Itellicoai ({
apiKey: 'your-api-key' ,
});
// Create an agent
const agent = await client . agents . create ({
accountId: 'your-account-id' ,
name: 'Customer Support 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: 'Hello! How can I assist you today?' ,
delayMs: 1000 ,
},
maxDurationSeconds: 1800 ,
tags: [ 'support' , 'customer-service' ],
});
console . log ( `Created agent: ${ agent . id } ` );
Opérations du SDK
Lister les Agents const agents = await client . agents . list ();
agents . forEach ( agent => {
console . log ( ` ${ agent . name } - ${ agent . id } ` );
});
Récupérer un Agent const agent = await client . agents . retrieve ( 'agent_123abc' );
console . log ( `Agent name: ${ agent . name } ` );
console . log ( `Model: ${ agent . model . model } ` );
Mettre à Jour un Agent const updatedAgent = await client . agents . update ( 'agent_123abc' , {
name: 'Updated Support Agent' ,
instructions: 'You are a helpful customer support agent...' ,
});
Archiver un Agent 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' });
Lister les Conversations import { Itellicoai } from 'itellicoai' ;
const client = new Itellicoai ({
apiKey: 'your-api-key'
});
const conversations = await client . accounts . listConversations ( 'account_id' , {
limit: 10
});
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 } ` );
});
Lister les Numéros de Téléphone 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 );
Créer un Numéro de Téléphone 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 );
Obtenir un Numéro de Téléphone 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 );
Mettre à Jour un Numéro de Téléphone 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 );
Supprimer un Numéro de Téléphone import { Itellicoai } from 'itellicoai' ;
const client = new Itellicoai ({
apiKey: 'your-api-key' ,
});
await client . accounts . phoneNumbers . delete (
'account_id' ,
'phone_number_id'
);
Lister les Modèles import Itellicoai from 'itellicoai' ;
const client = new Itellicoai ({
apiKey: 'My API Key' ,
});
const response = await client . accounts . providers . listModels ( 'account_id' );
console . log ( response );
Lister les Transcripteurs import Itellicoai from 'itellicoai' ;
const client = new Itellicoai ({
apiKey: 'My API Key' ,
});
const response = await client . accounts . providers . listTranscribers ( 'account_id' );
console . log ( response );
Lister les Voix 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 );
Lister les Trunks SIP 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 );
Créer un Trunk SIP 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 );
Obtenir un Trunk SIP 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 );
Mettre à Jour un Trunk SIP 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 );
Supprimer un Trunk SIP import Itellicoai from 'itellicoai' ;
const client = new Itellicoai ({
apiKey: 'My API Key' ,
});
await client . accounts . sipTrunks . delete ( 'sip_trunk_id' , { account_id: 'account_id' });
Obtenir les Analyses d’Utilisation const response = await client . accounts . analytics . getUsage ( 'account_id' );
console . log ( response . meta );
Lister les Sous-comptes const subaccounts = await client . accounts . subaccounts . list ( 'account_id' );
console . log ( subaccounts . count );
Créer un Sous-compte const account = await client . accounts . subaccounts . create ( 'account_id' , {
name: 'name' ,
});
console . log ( account . id );
Obtenir un Sous-compte const account = await client . accounts . subaccounts . retrieve (
'account_id' ,
'subaccount_id'
);
console . log ( account . id );
Mettre à Jour un Sous-compte const account = await client . accounts . subaccounts . update (
'account_id' ,
'subaccount_id'
);
console . log ( account . id );
Gestion des Erreurs
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 ( '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 } ` );
}
}
Variables d’Environnement
import { ItellicoAI } from 'itellicoai' ;
// API key automatically loaded from ITELLICO_API_KEY env var
const client = new ItellicoAI ();
// Or set explicitly
const client = new ItellicoAI ({
apiKey: process . env . ITELLICO_API_KEY ,
});
Types TypeScript
Définitions TypeScript complètes incluses :
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 );
};
Ressources