Methods

Objects

REAL-TIME CALL CONTROL: First Steps

Control calls in real-time!

How It Works

To control phone calls in real-time, we need an URL from you.

We will send POST requests to your URL with the current status of the call, and you will reply with commands.

This way, you control calls in real-time!

Summary

    Reference


    Call objects are defined in the reference.

    API init

    require 'vendor/autoload.php'; // Composer
    
    $api = new \CALLR\API\Client;
    $api->setAuth(new \CALLR\API\Authentication\LoginPasswordAuth('login', 'password'));
    
    var callr = require('callr');
    var api = new callr.api(callr.loginPasswordAuth('login', 'password'));
    
    require 'callr'
    api = CALLR::Api.new('login', 'password')
    
    import callr
    api = callr.Api("login", "password")
    
            

    Configure a REAL-TIME URL - Create a REAL-TIME App


    URLs are stored in what we call a "Voice App" (a JSON configuration object).


    You can create as many URL as you like, just create one object per URL!

    Method

    Objects

    • REALTIME10
    • App
    $options = (object) [
        'url' => 'http://yourdomain.com/realtime_callback_url'
    ];
    
    $app = $api->call('apps.create', ['REALTIME10', 'Your app name', $options]);
    // save $app->hash, it will be used next!
    
    var options = {
        url: 'http://yourdomain.com/realtime_callback_url'
    };
    
    api.call('apps.create', 'REALTIME10', 'Your app name', options).success(function(app) {
        // app.hash will be used for realtime call
    });
    
    options = {
        :url => 'http://yourdomain.com/realtime_callback_url'
    }
    
    app = api.call('apps.create', 'REALTIME10', 'Your app name', options)
    
    # save app.hash, it will be used next!
    
    options = {
        'url': 'http://yourdomain.com/realtime_callback_url'
    }
    
    app = api.call('apps.create', 'REALTIME10', 'Your app name', options)
    
    # save app.hash, it will be used next!
    
            

    (Optional) Inbound Calls - Assign a Phone Number to the REAL-TIME App


    You can assign a phone number (DID) to the app.
    For each call we receive on the phone number, we will make a POST request to your URL, so you can control the call.

    $api->call('apps.assign_did', [$app->hash, $did_hash]);
    
    api.call('apps.assign_did', app.hash, did_hash);
    
    result = api.call('apps.assign_did', app.hash, 'DID ID')
    
    result = api.call('apps.assign_did', app.hash, 'DID ID')
    
            

    Make an Outbound Call


    Call any number in the world!

    Method

    Objects

    • Target
    • REALTIME10.Call.Options
    $target = (object) [
        'number' => '+447890123456',
        'timeout' => 30
    ];
    
    $options = (object) [
        'cdr_field' => '42',
        'cli' => 'BLOCKED'
    ];
    
    $result = $api->call('calls.realtime', [$app->hash, $target, $options]);
    
    var target = {
        number: '+33612345678',
        timeout: 30
    };
    
    var callOptions = {
        cdr_field: '42',
        cli: 'BLOCKED'
    };
    
    api.call('calls.realtime', app.hash, target, callOptions).success(function(callid) {
        // success callback
    }).error(function(error) {
        // error callback
    });
    
    target = {
        :number => '+33612345678',
        :timeout => 30
    }
    
    callOptions = {
        :cdr_field => '42',
        :cli => 'BLOCKED'
    }
    
    result = api.call('calls.realtime', app.hash, target, callOptions)
    
    target = {
        'number': '+447890123456',
        'timeout': 30
    }
    
    callOptions = {
        'cdr_field': '42',
        'cli': 'BLOCKED'
    }
    
    result = api.call('calls.realtime', app.hash, target, callOptions)