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/)

    MethodDescriptionMandatory Parameters
    getAccount()Get details of the account-
    editAccount(parameters)Edit details of the account-
    getSubaccounts(parameters)Get details of all subaccountssubauth_id
    getSubaccount(parameters)Get details of a single subaccount-
    createSubaccount(parameters)Create a new subaccountname
    editSubaccount(parameters)Edit details of a subaccountname
    deleteSubaccount(parameters)Delete a subaccountsubauth_id

    Application API

    MethodDescriptionMandatory Parameters
    getApplication()Get details of an applicationapp_id
    editApplication(parameters)Edit details of an applicationapp_id
    getApplications(parameters)Get details of all applications-
    createApplication(parameters)Create a new applicationapp_name, answer_url
    deleteApplication(parameters)Delete an applicationapp_id

    Call API

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

    Conference API

    MethodDescriptionMandatory Parameters
    getLiveConferences()Get details of all live conference-
    hangupAllConferences()Hangup all conferences-
    getLiveConference(parameters)Get details of a single live conferenececonference_name
    hangupConference(parameters)Hangup a single conferenceconference_name
    hangupMember(parameters)Hangup a single member in a conferencemember_id
    playMember(parameters)Play music to a member in a conferencemember_id, url
    stopPlayMember(parameters)Stop playing music to a member in a conferencemember_id
    speakMember(parameters)Play a message to a Member in a conferencemember_id, text
    stopSpeakMember(parameters)Stop playing message to a member in a conferencemember_id
    deafMember(parameters)Deaf a Member in a conferencemember_id
    undeafMember(parameters)Undeaf a Member in a conferencemember_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 conferencemember_id
    recordConference(parameters)Start recording a conferenceconference_name
    stopRecordConference(parameters)Stop recording a conferenceconference_name

    Endpoint API

    MethodDescriptionMandatory Parameters
    getEndpoint(parameters)Get details of an endpointendpoint_id
    editEndpoint(parameters)Edit details of an endpointendpoint_id
    getEndpoints(parameters)Get details of all endpoints-
    createEndpoint(parameters)Create a new endpointusername, password, alias
    deleteEndpoint(parameters)Delete an endpointendpoint_id

    Message API

    MethodDescriptionMandatory Parameters
    sendMessage(parameters)Send an outbound SMSsrc, dst, text
    getMessage(parameters)Get details of a single messagemessage_uuid
    getMessages(parameters)Get details of all messages-

    Number & PhoneNumber API

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

    Pricing API

    MethodDescriptionMandatory Parameters
    getPricing(parameters)Get Pricing details for a specific countrycountry_iso

    Recording API

    MethodDescriptionMandatory Parameters
    getRecordings(parameters)Get Details of all recordings-
    getRecording(parameters)Get Details of a single recordingsrecording_id
    deleteRecording(parameters)Delete a sinlge recordingrecording_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.