Skip to content

Voximplant Management API node.js client library

Notifications You must be signed in to change notification settings

kenptr/apiclient-nodejs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voximplant API client library

Version 1.1.6-p3

Changelog by @kenpottr

  • [1.1.6-p3] Allow passing creds as string (not only filename)
  • [1.1.6-p3] Enables type definition generation

Prerequisites

In order to use Voximplant Node.js SDK, you need the following:

  1. A developer account. If you don't have one, sign up here.
  2. A private API key. There are 2 options to obtain it:
    1. Either generate it in the Voximplant Control panel
    2. Or call the CreateKey HTTP API method with the specified authentication parameters. You'll receive a response with the result field in it. Save the result value in a file (since we don't store the keys, save it securely on your side).
  3. Node.js >=10

How to use

Go to your project folder and install the SDK using npm:

npm i --save @voximplant/apiclient-nodejs

Then import the SDK in your script

const VoximplantApiClient = require("@voximplant/apiclient-nodejs").default;

Next, specify the path to the file with the result value either in the constructor or using the environment.

constructor:

const client = new VoximplantApiClient("/path/to/credentials.json");

env:

export VOXIMPLANT_CREDENTIALS=/path/to/credentials.json

Examples

Start a scenario

const VoximplantApiClient = require("@voximplant/apiclient-nodejs").default;
const client = new VoximplantApiClient();
client.onReady = function(){
  // Start the scripts from the account.
  client.Scenarios.startScenarios({ruleId: '1',
            scriptCustomData: 'mystr'})
        .then(ev=>console.log(ev))
        .catch(err=>console.error(err));
};

Send an SMS

const VoximplantApiClient = require("@voximplant/apiclient-nodejs").default;
const client = new VoximplantApiClient();
client.onReady = function(){
  // Send the SMS message with text "Test message" from the phone number 447443332211 to the phone number 447443332212.
  client.SMS.sendSmsMessage({source: '447443332211',
            destination: '447443332212',
            smsBody: 'Test message'})
        .then(ev=>console.log(ev))
        .catch(err=>console.error(err));
};

Get a call history item

const VoximplantApiClient = require("@voximplant/apiclient-nodejs").default;
const client = new VoximplantApiClient();
client.onReady = function(){
  // Get the first call session history record from the 2012-01-01 00:00:00 UTC to the 2014-01-01 00:00:00 UTC
  client.History.getCallHistory({fromDate: new Date('2012-01-01 00:00:00 GMT'),
            toDate: new Date('2014-01-01 00:00:00 GMT'),
            count: '1',
            timezone: 'Etc/GMT'})
        .then(ev=>console.log(ev))
        .catch(err=>console.error(err));
};

About

Voximplant Management API node.js client library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%