Skip to content

FreeClimbAPI/nodejs-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@freeclimb/sdk

@freeclimb/sdk - the NodeJS client package for the FreeClimb API

FreeClimb is a cloud-based application programming interface (API) that puts the power of the Vail platform in your hands. FreeClimb simplifies the process of creating applications that can use a full range of telephony features without requiring specialized or on-site telephony equipment. Using the FreeClimb REST API to write applications is easy! You have the option to use the language of your choice or hit the API directly. Your application can execute a command by issuing a RESTful request to the FreeClimb API. The base URL to send HTTP requests to the FreeClimb REST API is: /apiserver. FreeClimb authenticates and processes your request.

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0.0
  • Package version:
  • Build package: org.openapitools.codegen.languages.TypeScriptClientCodegen For more information, please visit https://www.freeclimb.com/support/

Installing

npm install @freeclimb/sdk@3.9.0
or 
yarn add @freeclimb/sdk@3.9.0

Getting Started

import freeclimb from '@freeclimb/sdk';

const configuration = freeclimb.createConfiguration({
  accountId: 'YOUR_ACCOUNT_ID',
  apiKey: 'YOUR_API_KEY'
});
const apiInstance = new freeclimb.DefaultApi(configuration);

apiInstance.listApplications().then(applications => console.log('got applications', applications))

Detailed SDK documentation

For more details on how to use the individual methods on the sdk - go here

Using PerCL

The Performance Command Language (PerCL) defines a set of instructions, written in JSON format, that express telephony actions to be performed in response to an event on the FreeClimb platform. FreeClimb communicates with the application server when events associated with the application occur, so the webserver can instruct FreeClimb how to handle such events using PerCL scripts. PerCL commands are a part of the model schema and can be serialized into JSON like so:

import { Say, Play, GetDigits, PerclScript } from '@freeclimb/sdk'

const say = new Say({ text: 'Hello, World' })
const play = new Play({ file: "Example File" })
const getDigits = new GetDigits({ actionUrl: "Example Action URL", prompts: [say, play] })
const perclScript = new PerclScript({ commands: [getDigits] })

console.log(perclScript.toJSON())

Documentation for verifying request signature

  • To verify the request signature, we will need to use the verifyRequestSignature method within the Request Verifier class

    RequestVerifier.verifyRequestSignature(requestBody, requestHeader, signingSecret, tolerance)

    This is a method that you can call directly from the request verifier class, it will throw exceptions depending on whether all parts of the request signature is valid otherwise it will throw a specific error message depending on which request signature part is causing issues

    This method requires a requestBody of type string, a requestHeader of type string, a signingSecret of type string, and a tolerance value of type number

    Example code down below

    import { RequestVerifier } from "./utils/RequestVerifier";
    
    export function RequestVerifierExample() {
      const tolerance: number = 5 * 60;
    
      const requestBody: string = '{"accountId":"YOUR_ACCOUNT_ID","callId":"YOUR_CALL_ID","callStatus":"YOUR_CALL_STATUS","conferenceId":null,"direction":"YOUR_CALL_DIRECTION,"from":"FROM_EXAMPLE","parentCallId":null,"queueId":null,"requestType":"YOUR_REQUEST_TYPE","to":"TO_EXAMPLE"}';
    
      const signingSecret: string = "YOUR_SIGNING_SECRET";
    
      const requestHeader: string = "t=YOUR_TIMESTAMP,v1=YOUR_HASH_EXAMPLE,v1=YOUR_HASH_EXAMPLE";
      
      RequestVerifier.verifyRequestSignature(
        requestBody,
        requestHeader,
        signingSecret,
        tolerance
      );
    }