Salesforce helper

The Plivo Salesforce Helper library simplifies the process of making Plivo API Calls and generating Plivo XML.

Prerequisites

  1. Salesforce Developer Account.
  2. Java SDK >=1.6 version
  3. Apache Ant >=1.6 version
  4. Force.com Migration Tool plugin for Ant

Installation

  1. Checkout or download the plivo-salesforce library from GitHub.
    $ git clone https://github.com/plivo/plivo-salesforce.git
  2. Unzip Force.com Migration Tool plugin for Ant and copy the ant-salesforce.jar into the plivo-salesforce directory you cloned in Step 1.
  3. Edit install/build.properties to insert your Salesforce username and password. Since you will be using the API to access Salesforce, remember to append your Security Token to your password.
  4. Open your command line to the install folder, then deploy using Ant:
    $ ant deployPlivo

This will upload our helper library to your Salesforce Organization and give you access to all of Plivo’s functionality with simple, easy to use Apex classes.

Using the library

Getting started with the Plivo API couldn’t be easier.

Initializing the PlivoRestApi class

String api_key = 'Your Auth_ID';
String api_token = 'Your Auth_Token';
PlivoRestAPI api = new PlivoRestAPI(api_key, api_token, 'v1');

Send an SMS

The snippet below shows how you can send an sms.

Map<String, String> params = new Map<String, String> ();
params.put('src','1111111111');
params.put('dst','2222222222');
params.put('text','Hello, how are you?');
PlivoMessage message = api.sendMessage(params);

Check out this Getting Started page or the full Message API documentation for more details.

Make an Outbound Phone Call

You can make outbound phone calls to landlines, mobiles, and SIP endpoints (e.g., softphones), in any of our 200+ coverage countries

Map<String, String> params = new Map<String, String> ();
params.put('src','1111111111');
params.put('dst','2222222222');
params.put('answer_url', 'https://s3.amazonaws.com/static.plivo.com/answer.xml');
params.put('answer_method','GET');
PlivoCall call = api.makeCall(params);

Check out this Getting Started page or the full Call API documentation for more details.

Methods

Below are all the methods that are present in PlivoRestApi class.

Account API](/docs/api/account/)

Method Description Mandatory Parameters
getAccount() Get details of the account -
editAccount(parameters) Edit details of the account -
getSubaccounts(parameters) Get details of all subaccounts subauth_id
getSubaccount(parameters) Get details of a single subaccount -
createSubaccount(parameters) Create a new subaccount name
editSubaccount(parameters) Edit details of a subaccount name
deleteSubaccount(parameters) Delete a subaccount subauth_id

Application API

Method Description Mandatory Parameters
getApplication() Get details of an application app_id
editApplication(parameters) Edit details of an application app_id
getApplications(parameters) Get details of all applications -
createApplication(parameters) Create a new application app_name, answer_url
deleteApplication(parameters) Delete an application app_id

Call API

Method Description Mandatory Parameters
makeCall(parameters) Make an outbound call from, to, answer_url
makeBulkCall(parameters) Make bulk calls from, to, answer_url
getCDR(parameters) Get details of a single call call_uuid
getCDRs(parameters) Get details of all calls -
getLiveCall(parameters) Get details of a single live call call_uuid
getLiveCalls() Get details of all live calls  
hangupCall(parameters) Hangup a single call call_uuid
hangupAllCalls() Hangup all calls -
transferCall(parameters) Transfer a call call_uuid
record(parameters) Start recording a call call_uuid
stopRecord(parameters) Stop recording a call call_uuid
play(parameters) Start playing music on a call call_uuid, urls
stopPlay(parameters) Stop playing music on a call call_uuid
speak(parameters) Start playing a message on a call call_uuid, text
stopSpeak(parameters) Stop playing a message on a call call_uuid
sendDigits(parameters) Send digits on a call call_uuid, digits
hangupRequest(parameters) Hangup a call request request_uuid

Conference API

Method Description Mandatory Parameters
getLiveConferences() Get details of all live conference -
hangupAllConferences() Hangup all conferences -
getLiveConference(parameters) Get details of a single live conferenece conference_name
hangupConference(parameters) Hangup a single conference conference_name
hangupMember(parameters) Hangup a single member in a conference member_id
playMember(parameters) Play music to a member in a conference member_id, url
stopPlayMember(parameters) Stop playing music to a member in a conference member_id
speakMember(parameters) Play a message to a Member in a conference member_id, text
stopSpeakMember(parameters) Stop playing message to a member in a conference member_id
deafMember(parameters) Deaf a Member in a conference member_id
undeafMember(parameters) Undeaf a Member in a conference member_id
muteMember(parameters) Mute a member in a conference -
unmuteMember(parameters) Unmute a member in a conference -
kickMember(parameters) Kick a Member out of a conference member_id
recordConference(parameters) Start recording a conference conference_name
stopRecordConference(parameters) Stop recording a conference conference_name

Endpoint API

Method Description Mandatory Parameters
getEndpoint(parameters) Get details of an endpoint endpoint_id
editEndpoint(parameters) Edit details of an endpoint endpoint_id
getEndpoints(parameters) Get details of all endpoints -
createEndpoint(parameters) Create a new endpoint username, password, alias
deleteEndpoint(parameters) Delete an endpoint endpoint_id

Message API

Method Description Mandatory Parameters
sendMessage(parameters) Send an outbound SMS src, dst, text
getMessage(parameters) Get details of a single message message_uuid
getMessages(parameters) Get details of all messages -

Number & PhoneNumber API

Method Description Mandatory Parameters
getNumbers(parameters) Get Details of all numbers -
getNumber(parameters) Get Details of a sigle number number
editNumber(parameters) Edit details of a single number number
unRentNumber(parameters) Unrent a number number
linkApplicationNumber(parameters) Link an application to a number number, app_id
unlinkApplicationNumber(parameters) Unlink an application from a number number
searchPhoneNumber(parameters) Search for phone numbers country_iso
buyPhoneNumber(parameters) Rent a new number number

Pricing API

Method Description Mandatory Parameters
getPricing(parameters) Get Pricing details for a specific country country_iso

Recording API

Method Description Mandatory Parameters
getRecordings(parameters) Get Details of all recordings -
getRecording(parameters) Get Details of a single recordings recording_id
deleteRecording(parameters) Delete a sinlge recording recording_id

Examples

Take a look at the Salesforce Integration examples on GitHub.

Reporting Issues

Please report issues or submit patches using the Github Issue Tracker or Customer Plivo Support.

License

The Plivo Salesforce Helper Library is written by the Plivo Team and distributed under the MIT License.