To run a scenario through the API, you need to perform four simple steps: 

  1.  Get an API token
  2. Buy a phone number or verify your own 
  3. Enter a scenario into the Voximplant Kit editor 
  4. Run the scenario

Let’s break down these steps one by one. 

In order to use the API you will need to generate an API token in your personal account. 

Go to Integration, then enter the API Tokens area and click on Add API tokens. Enter the name of the API token in the dropdown window and press Save.

An API token will appear in this section. You can see it or copy it by pressing the respective icon to the left of the token. 



You can make API requests using these authorization parameters:  

  • domain – your account name
  • access_token – API token

After this, you need to buy or add a Voximplant Kit telephone number. This can be done in the Number section.

Then go to Create a Scenario. Enter Scenarios in the top navigation bar and look for the Outbound tab. Click on New Scenario, select a template or a pre-made scenario. 

After you have created a scenario, verified your telephone and received an API token you can run your scenario. 

 

Example of a PHP code

<?php

// Your Voximplant Kit account name
define('KIT_DOMAIN', "YOUR DOMAIN NAME HERE");

// API Token
define('KIT_ACCESS_TOKEN', "YOUR API TOKEN HERE");

// ID of your CallerID number ID
define('KIT_CALLERID_PHONE_ID', "CALLERID PHONE ID HERE");

// Voximplant Kit scenario id
define('KIT_SCENARIO_ID', "SCENARIO ID HERE");

// Voximplant Kit API url
define('KIT_API_URL', "https://kitapi-eu.voximplant.com/api/v3/");

// Client data for using in scenario
$client_data = [
    'phone' => 'CLIENT PHONE NUMBER HERE',
    'client_name' => 'CLIENT NAME HERE'
];

// API Request parameters
$run_scenario_data = [
    'domain' => KIT_DOMAIN,
    'access_token' => KIT_ACCESS_TOKEN,
    'scenario_id' => KIT_SCENARIO_ID,
    'phone_number_id' => KIT_CALLERID_PHONE_ID,
    'phone' => $client_data['phone'],
    'variables' => json_encode([
        'client_name' => $client_data['client_name']
    ])
];

// HTTP Request to run the scenario
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, KIT_API_URL . "scenario/runScenario");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $run_scenario_data);
$returned = curl_exec($ch);
curl_close ($ch);