Import Calls - QM

Documentation for importing calls into AlloBrain QM

Introduction

This documentation details the various methods for importing telephone calls into the AlloBrain QM platform. It covers the general method via the API as well as specific use cases for automated import from different sources.

1. General API import method

Endpoint API

The AlloBrain API lets you import audio calls via a dedicated endpoint:

POST https://api.qm.allobrain.com/calls/audio

Authentication

Authentication is performed via an API key in the :

x-api-key: YOUR_ALLOBRAIN_API_KEY

Parameters

Metadata format

Metadata must be in JSON format, structured as an array of objects with key/value pairs:

[
  {"key": "client_phone", "value": "+33XXXXXXXXX"},
  {"key": "call_direction", "value": "inbound"},
  {"key": "site", "value": "xxxx"}
]

Example of a cURL request

curl -X POST https://api.qm.allobrain.com/calls/audio \
  -H "x-api-key: $ALLOBRAIN_API_KEY" \
  -F 'file=@/path/to/call/recording.wav' \
  -F 'campaign_id=VOTRE_ID_DE_CAMPAGNE' \
  -F 'conversation_timestamp=1704067200' \
  -F 'agent_email=john.doe@example.com' \
  -F 'metadata=[{"key":"client_phone","value":"+33XXXXXXXXX"},{"key":"site","value":"xxx"}]'

API responses

CodeDescription200Success - The call has been successfully imported400Query error - Check the parameters provided401Unauthorized - Invalid API key404Resource not found - The specified agent or campaign does not exist409Conflict - The user already exists (when creating an agent)422Validation error - The data format is invalid500Server error - Contact AlloBrain support

Agent management in the AlloBrain QM API

Key points

  1. IMPORTANT: Agents must be created BEFORE importing calls.
  2. Agents are identified by their email address in the system
  3. The agent-call association is made via the agent's email, not via metadata.

Endpoints API

Agent creation

POST <https://api.qm.allobrain.com/users/invite>

Headers required

{
    "x-api-key": "votre-api-key",
    "Content-Type": "application/json"
}

Playload

{
    "email": "email.de.lagent@domaine.com",
    "name": "Prénom Nom",
    "role": "agent",
    "send_invite_email": false
}

Possible answers

  • 200/201Agent successfully created
  • 409Agent already exists (can be considered a success)
  • 4xx/5xxError during creation

Importing a Call with Agent

POST <https://api.qm.allobrain.com/calls/audio>

Headers required

{
    "x-api-key": "votre-api-key"
}

Payload (multipart/form-data)

{
    "campaign_id": "id-de-la-campagne",
    "conversation_timestamp": 1234567890,
    "agent_email": "email.de.lagent@domaine.com",  // IMPORTANT: Email de l'agent ici
    "metadata": "[{\\"key\\":\\"direction\\",\\"value\\":\\"in\\"}, ...]"
}

Sample code

Python

import requests

# Configuration
API_KEY = "votre-api-key"
API_BASE = "<https://api.qm.allobrain.com>"
AGENT_CREATE_URL = f"{API_BASE}/users/invite"

def create_agent(first_name, last_name, email):
    """Crée un agent dans AlloBrain QM."""
    headers = {
        "x-api-key": API_KEY,
        "Content-Type": "application/json"
    }

    agent_data = {
        "email": email,
        "name": f"{first_name} {last_name}".strip(),
        "role": "agent",
        "send_invite_email": False
    }

    try:
        response = requests.post(AGENT_CREATE_URL, headers=headers, json=agent_data)

        if response.status_code in [200, 201]:
            print(f"Agent créé avec succès: {agent_data['name']} ({email})")
            return True, email
        elif response.status_code == 409:
            print(f"L'agent existe déjà: {email}")
            return True, email
        else:
            print(f"Échec de la création: {response.status_code} - {response.text}")
            return False, email
    except Exception as e:
        print(f"Erreur: {e}")
        return False, email

# Exemple d'utilisation
agent_info = {
    'first_name': 'Jean',
    'last_name': 'Dupont',
    'email': 'jean.dupont@exemple.com'
}

success, agent_email = create_agent(
    agent_info['first_name'],
    agent_info['last_name'],
    agent_info['email']
)

if success:
    print(f"Agent prêt à être utilisé: {agent_email}")
else:
    print("Échec de la création de l'agent")