1-877-506-0747

Twilio Voice thinQ Wrapper Library

The thinQ Twilio Wrapper Library is written to help developers who use Twilio Voice utilize Least Cost Routing functionality into the product, instantly saving 30-50% on calling costs.

How Does the Twilio Voice Wrapper Work?

A wrapper class wraps all Twilio-related operations such as Service Initialization, Making a Call, Generating Twiml callback response, etc. It provides a rich set of configuration parameters. That's it! Developers can initialize this wrapper class object with their specific details (incl. Twilio credentials) and just do what they want in a breeze.

How Do I Get Started?

After registering for your free account, simply choose the programming language of your choice to begin implementation.

PHP Library For Twilio Wrapper

Class

There's one primary class named TwilioWrapper that wraps all major functions.

Initialization


$wrapperObj = new TwilioWrapper($twilio_account_sid, $twilio_account_token, $thinQ_id, $thinQ_token);
				            

Configuration Parameters

  • $twilio_account_sid:

    You can get Twilio account sid from your Twilio account dashboard.
  • $twilio_account_token:

    You can get Twilio account token from your Twilio account dashboard.
  • $thinQ_id:

    ThinQ id that you received when you signed up thinq.com.
  • $thinQ_token:

    ThinQ token that you received when you signed up thinq.com.

Initiate a call to the thinQ line


$result = $wrapperObj->call($from, $to, $options);
				                
Return Value: Twilio call object if success, or relevant error message otherwise.

Quick Start Guide

There are two main ways to use our wrapper and they both utilize the Composer package manager. If you are already using Composer:
  1. Add the following to the “require” section of your composer.json file:
    "require": {
      "thinq/twilio-thinqlcr": "~2.0"
    }
  2. Alternatively use the command:
    php composer.phar require thinq/twilio-thinqlcr
  3. Run the command:
    php composer.phar install
  4. Use the sample demo code below to use our library with Twilio.

If you’re new to Composer:

  1. Download Composer and place it in your PATH. For more help with Composer, please visit their website.
  2. Download our source code from Github and put it in to your project root.
  3. Run the command “php composer.phar install” in your project root (where composer.json is located).
  4. Use the sample demo code below to use our library with Twilio.
    
    <?php
     require_once __DIR__ . '/vendor/autoload.php';
     
     use TwilioWithThinQLCR\TwilioWrapper;
     
     $twilio_account_sid = "SDIFUSDO4IFSDF4OSDF2OIDJSFOISDF";
     $twilio_auth_token  = "adsf987asd9f876sad98f7as9d8fsa9";
     $thinQ_id = "12345";
     $thinQ_token = "daf98dsf9g876sd987fg6d78fsg897dsf6g";
     $from_number = "19198900000";
     $to_number = "11234567890";
     $twiML = "http://example.com/xml/twilio-custom.xml";
     
     $wrapperObj = new TwilioWrapper($twilio_account_sid, $twilio_auth_token, $thinQ_id, $thinQ_token);
     
     $newCall = $wrapperObj->call($from_number, $to_number, array('url'=>$twiML));
     
     echo "Call sid: " . $newCall->sid . PHP_EOL;
    ?>
    				                
    Source code is on @github.

.NET (C#) Library For Twilio Wrapper

The current version of our library works Twilio SDK 5.X.  For Twilio SDK 4.X, please see our GitHub page. The easiest way to install our wrapper is to use the NuGet package manager. If you are using Visual Studio, type the following command into the Package Manager Console:
Install-Package ThinQ.TwilioWithThinQLCR
If you are the using .NET Core command line tools, you can run the following command from within your project directory:
dotnet add package ThinQ.TwilioWithThinQLCR
There are two ways to utilize our LCR technology wrappers:
  • Using our wrapper class
  • Using our extended callOptions class

Wrapper Class

There's one primary class named TwilioWrapper that wraps all major functions.

Initialization


TwilioWrapper wrapper = new TwilioWrapper(twilio_account_sid, twilio_account_token, thinQ_id, thinQ_token);

Configuration Parameters

  • twilio_account_sid:

    You can get Twilio account sid from your Twilio account dashboard.
  • twilio_account_token:

    You can get Twilio account token from your Twilio account dashboard.
  • thinQ_id:

    ThinQ id that you received when you signed up at thinq.com.
  • thinQ_token:

    ThinQ token that you received when you signed up at thinq.com.

Initiate a call to the thinQ line


CallResource call = wrapper.call(<to phone number>, <from phone number>);
				            
Return Value: Twilio CallResource if success, or relevant exception otherwise.

Quick Start Guide

Here's some simple demo code.

using System;
using TwilioWithThinQLCR;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

namespace Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            //
            // Example using the thinQ wrapper
            //

            // Create a wrapper object, passing in your Twilio SID, Twilio Token, thinQ ID and thinQ Token.
            TwilioWrapper wrapper = new TwilioWrapper("twilioSid", "twilioToken", "thinqAccountId", "thinqToken");

            // Call the createCall method on the wrapper as normal.
            var call2 = wrapper.createCall(new PhoneNumber("19195551234"), new PhoneNumber("19198900000"), url: new Uri("http://twilio.example.com/xml/twilio-custom.xml"));
            Console.WriteLine("Call2 sid: " + call2.Sid);
            Console.ReadLine();

            //
            // Example using the thinQ wrapper and callOptions.
            //

            // Create a wrapper object, psasing in your Twilio SID, Twilio Token, thinQ ID and thinQ Token.
            TwilioWrapper wrapper2 = new TwilioWrapper("twilioSid", "twilioToken", "thinqAccountId", "thinqToken");

            // Create a callOptions object, passing in your to and from numbers.
            CreateCallOptions callOptions2 = new CreateCallOptions(new PhoneNumber("19195551234"), new PhoneNumber("19198900000"));
            // Populate your callOptions object with any additional parameters like normal.
            callOptions2.Url = new Uri("http://twilio.example.com/twilio.xml");

            // Call the createCall method on the wrapper as normal.
            CallResource call3 = wrapper2.createCall(callOptions);
            Console.WriteLine("Call sid: " + call3.Sid);
            Console.ReadLine();
        }
    }
}

Using CreateCallOptionsWithThinQLCR Class

We have extended the Twilio CreateCallOptions class to create our CreateCallOptionsWithThinQLCR class which maps all the Twilio functionality while using our LCR.

Initialization


CreateCallOptionsWithThinQLCR callOptions = new CreateCallOptionsWithThinQLCR("thinQ_id", "thinQ_token", <to phone number>, <from phone number>);

Configuration Parameters

  • thinQ_id:

    ThinQ id that you received when you signed up at thinq.com.
  • thinQ_token:

    ThinQ token that you received when you signed up at thinq.com.

Usage

Create the options object as above and populate it as normal. Remember to initialize the Twilio rest client with your Twilio credentials as per the Twilio docs. Return Value: CreateCallOptionsWithThinQLCR object if success, or relevant exception otherwise.

Quick Start Guide

Here's some simple demo code.

using System;
using TwilioWithThinQLCR;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

namespace Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            //
            // Example using a callOptions object
            //

            // Initialize the Twilio rest client using your Twilio SID and Token.
            TwilioClient.Init("twilioSid", "twilioToken");

            // Create a thinQ callOptions object, passing in your thinQ ID and ThinQ Token.
            CreateCallOptionsWithThinQLCR callOptions = new CreateCallOptionsWithThinQLCR("thinqAccountId", "thinqToken", new PhoneNumber("19195551234"), new PhoneNumber("19198900000"));
            // Populate your callOptions object with any additional parameters like normal.
            callOptions.Url = new Uri("http://twilio.example.com/xml/twilio-custom.xml");

            // Create your call as you normally would.
            var call = CallResource.Create(callOptions);
            Console.WriteLine("Call sid: " + call.Sid);
            Console.ReadLine();
        }
    }
}
Source code is on @github.

Python Library For Twilio Wrapper

Class

There's one primary class named TwilioWrapper that wraps all major functions.

Initialization


wrapper = TwilioWrapper(twilio_account_sid, twilio_auth_token, thinQ_id, thinQ_token)
				            

Configuration Parameters

  • twilio_account_sid:

    You can get Twilio account sid from your Twilio account dashboard.
  • twilio_account_token:

    You can get Twilio account token from your Twilio account dashboard.
  • thinQ_id:

    ThinQ id that you received when you signed up at thinq.com.
  • thinQ_token:

    ThinQ token that you received when you signed up at thinq.com.

Initiate a call to the thinQ line


call = wrapper.call(to, from, url)
				            
Return Value: Twilio call object if success, or relevant error message otherwise.

Installation

If using PIP, you can install our package using:
pip install twilio_thinqlcr

Quick Start Guide

Here's some simple demo code.

from twilio_thinQLCR import TwilioWrapper

twilio_account_sid = "SDIFUSDO4IFSDF4OSDF2OIDJSFOISDF"
twilio_auth_token  = "adsf987asd9f876sad98f7as9d8fsa9"
thinQ_id = "12345"
thinQ_token = "daf98dsf9g876sd987fg6d78fsg897dsf6g"

wrapper = TwilioWrapper(twilio_account_sid, twilio_auth_token, thinQ_id, thinQ_token)
# wrapper.call(to-number, from-number, twiML URL)
call = wrapper.call("12345678901", "18765432101", "http://example.com/twilio.xml")
print "Call sid: " + str(call.sid)
				            
Source code is on @github.

Java Library For Twilio Wrapper

Class

There's one primary class named TwilioWrapperLibrary that wraps all major functions, and one builder class named TwilioWrapperLibraryBuilder that is a utility class to build the library object.

Initialization


TwilioWrapperLibrary library = new TwilioWrapperLibraryBuilder()
.twilio(twilio_account_sid, twilio_account_token)
.thinQ(thinQ_id, thinQ_token)
.buildLibrary();
				            

Configuration Parameters

  • twilio_account_sid:

    You can get your Twilio account sid from your Twilio account dashboard.
  • twilio_account_token:

    You can get your Twilio account token from your Twilio account dashboard.
  • thinQ_id:

    ThinQ id that you received when you signed up thinq.com.
  • thinQ_token:

    ThinQ token that you received when you signed up thinq.com.

Initiate a call to the thinQ line


String result = library.call(from, to);
				            
Return Value: Proper twilio call Sid if success, or relevant error message otherwise.

Quick Start Guide

Here's some simple demo code.

public class Main {
    public static void main(String[] args) throws TwilioRestException {
        String twilio_account_sid = "asdf1234_yourTwilioAcctSidHere";
        String twilio_account_token = "lkjh0987_yourTwilioAcctTokenHere";
        String thinQ_id = "numeric_thinQ_id";
        String thinQ_token = "qwerty1013_thinQ_token";
        String twiml_url = "http://demo.twilio.com/docs/voice.xml";
        String to_number = "19195551212";
        String from_number = "19195551212";

        TwilioWrapperLibrary library = new TwilioWrapperLibraryBuilder()
                // set twilio account sid, account token
                .twilio(twilio_account_sid, twilio_account_token)
                // set thinQ details
                .thinQ(thinQ_id, thinQ_token)
                // wrap and build the library
                .buildLibrary();
        ArrayList params = new ArrayList();
        params.add(new BasicNameValuePair("Url", twiml_url));
        params.add(new BasicNameValuePair("To", to_number));
        params.add(new BasicNameValuePair("From", from_number));

        Call result = library.call(params); //return value is call sid if success, otherwise error message.
        System.out.println("result: " + result.getSid());
    }
}
				            
Source code is on @github.

Ruby Library For Twilio Wrapper

Class

There's one primary class named TwilioWithThinq::TwilioWrapper that wraps all major functions.

Initialization


wrapper = TwilioWithThinq::TwilioWrapper.new  twilio_account_sid, twilio_account_token, thinQ_id, thinQ_token
				            

Configuration Parameters

  • twilio_account_sid:

    You can get Twilio account sid from your Twilio account dashboard.
  • twilio_account_token:

    You can get Twilio account token from your Twilio account dashboard.
  • thinQ_id:

    ThinQ id that you received when you signed up at thinq.com.
  • thinQ_token:

    ThinQ token that you received when you signed up at thinq.com.

Initiate a call to the thinQ line


call_sid = wrapper.call from, to
				            
Return Value: Proper twilio call Sid if success, or relevant error message otherwise.

Installation

If using gems, add this to your gemspec:
s.add_dependency 'twilio_thinqlcr', '~>1.0'

Quick Start Guide

Here's some simple demo code.

require "twilio_thinqlcr"

twilio_account_sid = "ACa5a21802beff96f147d40bf98c957038"
twilio_account_token = "7852c807435af28d468344ca57a49d2a"
thinQ_id = "11001"
thinQ_token = "0c82a54f22f775a3ed8b97b2dea74036"

wrapper = TwilioWithThinq::TwilioWrapper.new twilio_account_sid, twilio_account_token, thinQ_id, thinQ_token

call_sid = wrapper.call "1234567890", "9876543210"

puts "Call sid: #{call_sid}"
				            
Source code is on @github.

Node.js Library For Twilio Wrapper

Class

There's one primary class named TwilioWrapper that wraps all major functions as prototype methods.

Initialization


var wrapper = new TwilioWrapper(
    twilio_accountSid,                    // twilio account sid  
    twilio_authToken,                     // twilio account token
    thinQ_id,                             // thinQ id
    thinQ_token                           // thinQ token
);
				            

Configuration Parameters

  • twilio_account_sid:

    You can get your Twilio account sid from your Twilio account dashboard.
  • twilio_account_token:

    You can get your Twilio account token from your Twilio account dashboard.
  • thinQ_id:

    ThinQ id that you received when you signed up thinq.com.
  • thinQ_token:

    ThinQ token that you received when you signed up thinq.com.

Initiate a call to the thinQ line


var return_promise = wrapper.call(from, to);
				            
Return Value: Proper promise object for the initiated Twilio call if success, or null otherwise.

Installation

Add this line to your application's package.json file:
"dependencies": {
  "twilio-thinqlcr": "^1.0.0"
}
Or install it yourself as::
$ npm install twilio-thinqlcr

Quick Start Guide

Here's some simple demo code.

var TwilioWrapper = require('twilio-thinqlcr');

var twilio_accountSid = 'ACa5a21802beff96f147d40bf98c957038';
var twilio_authToken = '7852c807435af28d468344ca57a49d2a';
var thinQ_id = '11001';
var thinQ_token = '0c82a54f22f775a3ed8b97b2dea74036';
var from_number = '1234567890';
var to_number = '9876543210';
var twiml_resource_url = 'http://demo.twilio.com/docs/voice.xml';

var wrapper = new TwilioWrapper(
    twilio_accountSid,                    // twilio account sid  
    twilio_authToken,                     // twilio account token
    thinQ_id,                             // thinQ id
    thinQ_token                           // thinQ token
    );

var return_promise = wrapper.call(from_number, to_number, twiml_resource_url);

return_promise.then(function(call){
    console.log("Successfully initiated a new call to customer!");
    console.log("Call sid: " + call.sid);
	}, function(error){
	console.log(err);
});
				            
Source code is on @github.

Open a Free Account


* These fields are required.