SDKs officiels
Bibliothèques officielles pour Python et JavaScript/TypeScript. Typage complet, async natif, gestion d'erreurs intégrée.
pip install esignalnpm install @esignal/sdkTypeScript natif
Installation
pip install esignal
# Avec extras optionnels
pip install "esignal[async]" # Support asyncio
pip install "esignal[pandas]" # Intégration DataFramesInitialisation
from esignal import Client
# Authentification par clé API
client = Client(api_key="sk_live_xxx")
# Ou via variable d'environnement ESIGNAL_API_KEY
client = Client()Contacts
# Lister les contacts
contacts = client.contacts.list(limit=50, channel="whatsapp")
for c in contacts:
print(c.name, c.phone, c.score)
# Créer un contact
contact = client.contacts.create(
name="Kofi Asante",
phone="+233241234567",
channel="whatsapp",
tags=["VIP", "Accra"]
)
# Récupérer un contact
contact = client.contacts.get("cnt_01J8X4...")Conversations & Messages
# Lister les conversations ouvertes
convs = client.conversations.list(status="open")
# Envoyer un message
msg = client.conversations.send_message(
conversation_id="conv_01J7P3...",
content="Bonjour ! Comment puis-je vous aider ?"
)
# Récupérer l'historique
messages = client.conversations.messages("conv_01J7P3...")Analytics
from datetime import date
# Vue d'ensemble
overview = client.analytics.overview(
from_date=date(2025, 11, 1),
to_date=date(2025, 11, 30)
)
print(f"Revenus: {overview.revenue.attributed:,} XOF")
print(f"Leads: {overview.leads.converted}")
# Forecast IA
forecast = client.analytics.forecast(horizon=90)
for point in forecast.data:
print(point.date, point.revenue, point.lower, point.upper)Webhooks (handler)
from flask import Flask, request
from esignal.webhooks import WebhookHandler
app = Flask(__name__)
handler = WebhookHandler(secret="whsec_xxx")
@handler.on("message.received")
def on_message(event):
print(f"Nouveau message de {event.data.contact.name}")
print(f"Contenu: {event.data.content}")
print(f"Sentiment: {event.data.ai.sentiment}")
@app.route("/webhooks", methods=["POST"])
def webhooks():
handler.process(request.data, request.headers)
return "", 200