Conference Calls

    A conferencing app is where 2 or more people can chat at the same time. It can be as simple as connecting two or more people in a conference bridge or involve many different users and or moderators.

    1. Plivo simultaneously calls all 3 phone numbers that were inserted by the user into the conference app.
    2. Plivo responds with the following message when any of the 3 calls are answered, “You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com”.
    3. Plivo connects all answered calls into a conference call.
    4. If no calls are answered, Plivo hangs up.

    Prerequisites

    1. Sign up for a free Plivo trial account.
    2. Check out our server-side SDKs page and install the right helper based on the programming language you want to use.
    3. Buy a Plivo phone number. A phone number is required to receive calls. You can buy a Plivo phone number in over 20+ countries through the Buy Numbers tab on your Plivo account UI. Check the Voice API coverage page for all the supported countries.
    4. Use a web hosting service to host your web application. There are many inexpensive cloud hosting providers that you can use for just a few dollars a month. Follow the instructions of your hosting provider to host your web application.

    Set up a Web Server

    Let’s assume your web server is located at example.com. Below is a snippet to set up a route on your webserver. Let’s call it response/conference. Now when we send an HTTP request to example.com/response/conference this route will be invoked. You will now have to configure this URL as the Answer URL in your code. To place the calls into a conference, we need to use the Conference XML. In this route we added a message using the Speak XML and then created a Conference called ‘demo’.

    Note: For PHP, the route will be `example.com/conference.php`.

    Copy the relevant code below into a text file and save it. Let’s call it conferenceXML.

    Code

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    
    from flask import Flask, Response, request, make_response
    import plivoxml
    
    app=Flask(__name__)
    
    @app.route('/response/conference/', methods=['GET','POST'])
    def conference():
        response = plivoxml.Response()
        response.addSpeak('You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com')
        params = {
        'enterSound' : "beep:2", # Used to play a sound when a member enters the conference
        'record' : "true", # Option to record the call
        'action' : "https://example.com/response/conf_action/", # URL to which the API can send back parameters
        'method' : "GET", # method to invoke the action Url
        'callbackUrl' : "https://example.com/response/conf_callback/", # If specified, information is sent back to this URL
        'callbackMethod' : "GET" # Method used to notify callbackUrl
        # For moderated conference
        # 'startConferenceOnEnter' : "true", # When a member joins the conference with this attribute set to true, the conference is started.
                                           # If a member joins a conference that has not yet started, with this attribute value set to false,
                                           # the member is muted and hears background music until another member joins the conference
        # 'endConferenceOnExit' : "true" # If a member with this attribute set to true leaves the conference, the conference ends and all
                                       # other members are automatically removed from the conference.
        }
        conference_name = "demo" # Conference Room name
        response.addConference(conference_name, **params)
        return Response(str(response), mimetype='text/xml')
    
    # Action URL Example
    
    @app.route('/response/conf_action/', methods=['GET','POST'])
    def conf_action():
        conf_name = request.values.get('ConferenceName')
        conf_uuid = request.values.get('ConferenceUUID')
        conf_mem_id = request.values.get('ConferenceMemberID')
        record_url = request.values.get('RecordUrl')
        record_id = request.values.get('RecordingID')
        response = make_response('OK')
        response.headers['Content-type'] = 'text/plain'
        print "Conference Name : %s " % (conf_name)
        print "Conference UUID : %s " % (conf_uuid)
        print "Conference Member ID : %s " % (conf_mem_id)
        print "Record URL : %s " % (record_url)
        print "Recording ID : %s " % (record_id)
        return response
    
    # Callback URL Example
    
    @app.route('/response/conf_callback/', methods=['GET','POST'])
    def conf_callback():
        conf_action = request.values.get('ConferenceAction')
        conf_name = request.values.get('ConferenceName')
        conf_uuid = request.values.get('ConferenceUUID')
        conf_mem_id = request.values.get('ConferenceMemberID')
        call_uuid = request.values.get('CallUUID')
        record_url = request.values.get('RecordUrl')
        record_id = request.values.get('RecordingID')
        response = make_response('OK')
        response.headers['Content-type'] = 'text/plain'
        print "Conference Name : %s " % (conf_name)
        print "Conference UUID : %s " % (conf_uuid)
        print "Conference Member ID : %s " % (conf_mem_id)
        print "Record URL : %s " % (record_url)
        print "Recording ID : %s " % (record_id)
        return response
    
    if __name__ == "__main__":
        app.run(host='0.0.0.0', debug=True)
    
    # Outbound Conference
    
    import plivo
    
    auth_id = "Your AUTH_ID"
    auth_token = "Your AUTH_TOKEN"
    
    # Enter your Plivo phone number. This will show up on your caller ID
    plivo_number = "1111111111"
    
    # Enter the URL of where your conferenceXML.py file is
    answer_url = "https://example.com/response/conference"
    
    p = plivo.RestAPI(auth_id, auth_token)
    
    call_params = {
        'to' : "2222222222<3333333333", # The phone number to which the call has to be placed separated by "<" delimiter
        'from': plivo_number, # The phone number to be used as the caller id
        'answer_url': answer_url, # The URL invoked by Plivo when the outbound call is answered
        'answer_method' : "GET" # The method used to call the answer_url
        }
    
    r = p.make_call(call_params)
    print str(r)
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    
    require 'rubygems'
    require 'sinatra'
    require 'plivo'
    include Plivo
    
    get '/response/conference/' do
    
        r = Response.new()
        r.addSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com")
        params = {
            'enterSound' => "beep:2", # Used to play a sound when a member enters the conference
            'record' => "true", # Option to record the call
            'action' => "https://example.com/response/conf_action/", # URL to which the API can send back parameters
            'method' => "GET", # method to invoke the action Url
            'record' => "true", # Option to record the call
            'callbackUrl' => "https://example.com/response/conf_callback/", # If specified, information is sent back to this URL
            'callbackMethod' => "GET" # Method used to notify callbackUrl
            # For moderated conference
            # 'startConferenceOnEnter' => "true", # When a member joins the conference with this attribute set to true, the conference is started.
                                               # If a member joins a conference that has not yet started, with this attribute value set to false,
                                               # the member is muted and hears background music until another member joins the conference
            # 'endConferenceOnExit' => "true" # If a member with this attribute set to true leaves the conference, the conference ends and all
                                           # other members are automatically removed from the conference.
        }
    
        conference_name = "demo"
        r.addConference(conference_name,params)
    
        puts r.to_xml()
        content_type 'text/xml'
        return r.to_s()
    end
    
    get '/response/conf_action/' do
        conf_name = params[:ConferenceName]
        conf_uuid = params[:ConferenceUUID]
        conf_mem_id = params[:ConferenceMemberID]
        record_url = params[:RecordUrl]
        record_id = params[:RecordingID]
    
        puts ("Conference Name : #{conf_name}, Conference UUID : #{conf_uuid}, Member ID : #{conf_mem_id}, Record URL : #{record_url}, Record ID : #{record_id}")
    
    end
    
    get '/response/conf_callback/' do
        conf_action = params[:ConferenceAction]
        conf_name = params[:ConferenceName]
        conf_uuid = params[:ConferenceUUID]
        conf_mem_id = params[:ConferenceMemberID]
        call_uuid = params[:CallUUID]
        record_url = params[:RecordUrl]
        record_id = params[:RecordingID]
    
        puts ("Conference Action : #{conf_action}, Conference Name : #{conf_name}, Conference UUID : #{conf_uuid}, Member ID : #{conf_mem_id}, Call UUID : #{call_uuid}, Record URL : #{record_url}, Record ID : #{record_id}")
    
    end
    
    
    # Outbound Conference
    
    require 'rubygems'
    require 'plivo'
    include Plivo
    
    AUTH_ID = "Your AUTH_ID"
    AUTH_TOKEN = "Your AUTH_TOKEN"
    
    p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
    
    params = {
        'to' => '2222222222<3333333333', # The phone number to which the call has to be placed separated by "<" delimiter
        'from' => '1111111111', # The phone number to be used as the caller id
        'answer_url' => 'https://example.com/response/conference/', # The URL invoked by Plivo when the outbound call is answered
        'answer_method' => 'GET', # The method used to call the answer_url
    }
    
    response = p.make_call(params)
    print response
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    
    var plivo = require('plivo');
    var express = require('express');
    var app = express();
    
    app.set('port', (process.env.PORT || 5000));
    app.use(express.static(__dirname + '/public'));
    
    app.all('/conference/', function(request, response) {
        // Generates a Conference XML
        var r = plivo.Response();
        r.addSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com");
        var params = {
            'enterSound' : "beep:2", // Used to play a sound when a member enters the conference
            'record' : "true", // Option to record the call
            'action' : "https://intense-brook-8241.herokuapp.com/conf_action/", // URL to which the API can send back parameters
            'method' : "GET", // method to invoke the action Url
            'callbackUrl' : "https://intense-brook-8241.herokuapp.com/conf_callback/", // If specified, information is sent back to this URL
            'callbackMethod' : "GET", // Method used to notify callbackUrl
            // For moderated conference
            // 'startConferenceOnEnter' : "true", // When a member joins the conference with this attribute set to true, the conference is started.
                                               // If a member joins a conference that has not yet started, with this attribute value set to false,
                                               // the member is muted and hears background music until another member joins the conference
            // 'endConferenceOnExit' : "true" // If a member with this attribute set to true leaves the conference, the conference ends and all
                                           // other members are automatically removed from the conference.
        };
    
        var conference_name = "demo"; // Conference Room name
        r.addConference(conference_name, params);
        console.log (r.toXML());
    
        response.set({
            'Content-Type': 'text/xml'
        });
        response.end(r.toXML());
    
    });
    
    app.all('/conf_action/', function(request, response) {
        var conf_name = request.param('ConferenceName');
        var conf_uuid = request.param('ConferenceUUID');
        var conf_mem_id = request.param('ConferenceMemberID');
        var record_url = request.param('RecordUrl');
        var record_id = request.param('RecordingID');
    
        console.log ('Conference Name : ' + conf_name + ' Conference UUID  : ' + conf_uuid + ' Conference Member ID : ' + conf_mem_id + ' Record Url : '
            + record_url + ' Record ID : ' + record_id);
    });
    
    app.all('/conf_callback/', function(request, response) {
        var conf_action = request.param('ConferenceAction')
        var conf_name = request.param('ConferenceName');
        var conf_uuid = request.param('ConferenceUUID');
        var conf_mem_id = request.param('ConferenceMemberID');
        var call_uuid = request.param('CallUUID')
        var record_url = request.param('RecordUrl');
        var record_id = request.param('RecordingID');
    
        console.log ('Conference Action : ' + conf_action + ' Conference Name : ' + conf_name + ' Conference UUID  : ' + conf_uuid
            + ' Conference Member ID : ' + conf_mem_id + ' Call UUID : ' + call_uuid + ' Record Url : ' + record_url + ' Record ID : ' + record_id);
    });
    
    app.listen(app.get('port'), function() {
        console.log('Node app is running on port', app.get('port'));
    });
    
    // Outbound Conference
    
    var plivo = require('plivo');
    var p = plivo.RestAPI({
      authId: 'Your AUTH_ID',
      authToken: 'Your AUTH_TOKEN'
    });
    
    var params = {
        'to': '2222222222<3333333333', // The phone numer to which the all has to be placed separated by "<" delimiter
        'from' : '1111111111', // Enter your Plivo phone number. This will show up on your caller ID
        'answer_url' : "https://intense-brook-8241.herokuapp.com/conference/", // Enter the URL of where your conferenceXML.py file is
        'answer_method' : "GET", // The method used to call the answer_url
    };
    
    // Prints the complete response
    p.make_call(params, function (status, response) {
        console.log('Status: ', status);
        console.log('API Response:\n', response);
    });
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    
    <!--conference.php-->
    
    <?php
        require 'vendor/autoload.php';
        use Plivo\Response;
        $r = new Response();
        $body = "You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com";
        $r->addSpeak($body);
        $params = array(
                'enterSound' => "beep:2", # Used to play a sound when a member enters the conference
                'record' => "true", # Option to record the call
                'action' => "https://example.com/conf_action.php", # URL to which the API can send back parameters
                'method' => "GET", # method to invoke the action Url
                'callbackUrl' => "https://example.com/conf_callback.php", # If specified, information is sent back to this URL
                'callbackMethod' => "GET", # Method used to notify callbackUrl
                # For moderated conference
                'startConferenceOnEnter' => "true", # When a member joins the conference with this attribute set to true, the conference is started.
                                       # If a member joins a conference that has not yet started, with this attribute value set to false,
                                       # the member is muted and hears background music until another member joins the conference
                'endConferenceOnExit' => "true" # If a member with this attribute set to true leaves the conference, the conference ends and all
                                   # other members are automatically removed from the conference.
            );
    
        $conference_name = "demo";
        $r->addConference($conference_name, $params);
        Header('Content-type: text/xml');
        echo($r->toXML());
    ?>
    
    <!--conf_action.php-->
    
    <?php
        $conf_name = $_REQUEST['ConferenceName'];
        $conf_uuid = $_REQUEST['ConferenceUUID'];
        $conf_mem_id = $_REQUEST['ConferenceMemberID'];
        $record_url = $_REQUEST['RecordUrl'];
        $record_id = $_REQUEST['RecordingID'];
        error_log("Conference Name : $conf_name, Conference UUID : conf_uuid, Conference Member ID : conf_mem_id, Record URL : $record_url, Record ID : $record_id");
        echo "Conference Name : $conf_name, Conference UUID : conf_uuid, Conference Member ID : conf_mem_id, Record URL : $record_url, Record ID : $record_id";
    ?>
    
    <!--conf_callback.php-->
    
    <?php
        $conf_action = $_REQUEST['ConferenceAction'];
        $conf_name = $_REQUEST['ConferenceName'];
        $conf_uuid = $_REQUEST['ConferenceUUID'];
        $conf_mem_id = $_REQUEST['ConferenceMemberID'];
        $call_uuid = $_REQUEST['CallUUID'];
        $record_url = $_REQUEST['RecordUrl'];
        $record_id = $_REQUEST['RecordingID'];
        error_log("Conference Action : $conf_action, Conference Name : $conf_name, Conference UUID : conf_uuid,
            Conference Member ID : conf_mem_id, Call UUID : $call_uuid, Record URL : $record_url, Record ID : $record_id");
        echo "Conference Action : $conf_action, Conference Name : $conf_name, Conference UUID : conf_uuid,
            Conference Member ID : conf_mem_id, Call UUID : $call_uuid, Record URL : $record_url, Record ID : $record_id";
    ?>
    
    <!--outbound_conference.php-->
    
    <?php
        require 'vendor/autoload.php';
        use Plivo\RestAPI;
    
        $auth_id = "Your AUTH_ID";
        $auth_token = "Your AUTH_TOKEN";
        $p = new RestAPI($auth_id, $auth_token);
        $plivo_number = "1111111111";
        $params = array(
            'to' => '1111111111<2222222222', # The phon number to be called
            'from' => $plivo_number, # The phone number to be used as the caller id
            'answer_url' => "https://example.com/response/conference", # The URL invoked by Plivo when the outbound call is answered
            'answer_method' => "GET" # The method used to call the answer_url
        );
    
        $response = $p->make_call($params);
        print_r ($response);
    
    ?>
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    
    // conferenceXml.java
    package plivoexample;
    
    import java.io.IOException;
    
    import com.plivo.helper.exception.PlivoException;
    import com.plivo.helper.xml.elements.Conference;
    import com.plivo.helper.xml.elements.PlivoResponse;
    import com.plivo.helper.xml.elements.Speak;
    
    import org.eclipse.jetty.server.Server;
    import org.eclipse.jetty.servlet.ServletContextHandler;
    import org.eclipse.jetty.servlet.ServletHolder;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class conferenceXml extends HttpServlet {
        private static final long serialVersionUID = 1L;
        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {
    
            PlivoResponse response = new PlivoResponse();
            Speak spk = new Speak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com");
            Conference conf = new Conference("demo");
            conf.setEnterSound("beep:2"); // Used to play a sound when a member enters the conference
            conf.setRecord(true); // Option to record the call
            conf.setAction("https://example.com/conf_action/"); // URL to which the API can send back parameters
            conf.setMethod("GET"); // method to invoke the action Url
            conf.setCallbackUrl("https://example.com/conf_callback/"); // If specified, information is sent back to this URL
            conf.setCallbackMethod("GET"); // Method used to notify callbackUrl
            // For moderated conference
            // conf.setStartConferenceOnEnter(true); // When a member joins the conference with this attribute set to true, the conference is started.
                                            // If a member joins a conference that has not yet started, with this attribute value set to false,
                                            // the member is muted and hears background music until another member joins the conference
            // conf.setEndConferenceOnExit(true); // If a member with this attribute set to true leaves the conference, the conference ends and all
                                            // other members are automatically removed from the conference.
    
            try {
                response.append(spk);
                response.append(conf);
                System.out.println(response.toXML());
                resp.addHeader("Content-Type", "text/xml");
                resp.getWriter().print(response.toXML());;
            } catch (PlivoException e) {
                e.printStackTrace();
            }
        }
    
        public static void main(String[] args) throws Exception {
            String port = System.getenv("PORT");
            if(port==null)
                port ="8000";
            Server server = new Server(Integer.valueOf(port));
            ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
            context.setContextPath("/");
            server.setHandler(context);
            context.addServlet(new ServletHolder(new conferenceXml()),"/response/conference/");
            context.addServlet(new ServletHolder(new confAction()),"/conf_action/");
            context.addServlet(new ServletHolder(new confCallback()),"/conf_callback/");
            server.start();
            server.join();
        }
    }
    
    // confAction.java
    package plivoexample;
    
    import java.io.IOException;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class confAction extends HttpServlet {
        private static final long serialVersionUID = 1L;
    
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {
            String conf_name = req.getParameter("ConferenceName");
            String conf_uuid = req.getParameter("ConferenceUUID");
            String conf_mem_id = req.getParameter("ConferenceMemberID");
            String record_url = req.getParameter("RecordUrl");
            String record_id = req.getParameter("RecordingID");
            System.out.println("Conference Name : " + conf_name + " Conference UUID : " + conf_uuid + " Conference Member ID : " + conf_mem_id +
                                " Record URL : " + record_url + " Record ID : " + record_id);
            resp.getWriter().print("Conference Name : " + conf_name + " Conference UUID : " + conf_uuid + " Conference Member ID : " + conf_mem_id +
                    " Record URL : " + record_url + " Record ID : " + record_id);
        }
    }
    
    // confCallback.java
    package plivoexample;
    
    import java.io.IOException;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class confCallback extends HttpServlet {
        private static final long serialVersionUID = 1L;
    
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {
            String conf_action = req.getParameter("ConferenceAction");
            String conf_name = req.getParameter("ConferenceName");
            String conf_uuid = req.getParameter("ConferenceUUID");
            String conf_mem_id = req.getParameter("ConferenceMemberID");
            String call_uuid = req.getParameter("CallUUID");
            String record_url = req.getParameter("RecordUrl");
            String record_id = req.getParameter("RecordingID");
            System.out.println("Conference Action : " + conf_action + " Conference Name : " + conf_name + " Conference UUID : " + conf_uuid + " Conference Member ID : " + conf_mem_id +
                                " Call UUID : " + call_uuid + " Record URL : " + record_url + " Record ID : " + record_id);
            resp.getWriter().print("Conference Action : " + conf_action + "Conference Name : " + conf_name + " Conference UUID : " + conf_uuid + " Conference Member ID : " + conf_mem_id +
                    " Call UUID : " + call_uuid + " Record URL : " + record_url + " Record ID : " + record_id);
        }
    }
    
    // Outbound Conference
    
    package sending_sms.sending_sms;
    
    import java.lang.reflect.Field;
    import java.lang.reflect.Modifier;
    import java.util.LinkedHashMap;
    
    import com.plivo.helper.api.client.*;
    import com.plivo.helper.api.response.call.Call;
    import com.plivo.helper.exception.PlivoException;
    
    public class App {
        public static void main(String[] args) throws IllegalAccessException {
    
            String auth_id = "Your AUTH_ID";
            String auth_token = "Your AUTH_TOKEN";
    
            RestAPI api = new RestAPI(authId, authToken, "v1");
    
            LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
            parameters.put("to","2222222222"); // The phone number to which the all has to be placed
            parameters.put("from","1111111111"); // The phone number to be used as the caller id
            parameters.put("answer_url","https://example.com/response/conference"); // The URL invoked by Plivo when the outbound call is answered
            parameters.put("answer_method","GET"); // method to invoke the answer_url
    
            try {
               Call resp = api.makeCall(parameters);
               System.out.println(getFields(resp));
            }catch (PlivoException e){
               System.out.println(e.getLocalizedMessage());
            }
        }
    
        public static String getFields(Object obj) throws IllegalAccessException {
            StringBuffer buffer = new StringBuffer();
            Field[] fields = obj.getClass().getDeclaredFields();
            for (Field f : fields) {
              if (!Modifier.isStatic(f.getModifiers())) {
                f.setAccessible(true);
                Object value = f.get(obj);
                buffer.append(f.getName());
                buffer.append("=");
                buffer.append("" + value);
                buffer.append("\n");
              }
            }
            return buffer.toString();
       }
    }
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using RestSharp;
    using Plivo.XML;
    using Nancy;
    
    namespace conference
    {
        public class Program : NancyModule
        {
            public Program()
            {
                Get["/response/conference/"] = x =>
                {
                    Plivo.XML.Response resp = new Plivo.XML.Response();
    
                    //  Add Speak XML Tag
                    resp.AddSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more, visit us at Plivo.com", new Dictionary&lt;string, string&gt;() { });
    
                    // Add Conference XML Tag
                    resp.AddConference("demo",new Dictionary&lt;string,string&gt;()
                    {
                        {"enterSound","beep:2"}, // Used to play a sound when a member enters the conference
                        {"record","true"}, // Option to record the call
                        {"action","http://example.com/response/conf_action/"}, // URL to which the API can send back parameters
                        {"method","GET"}, // method to invoke the action Url
                        {"callbackUrl","http://example.com/response/conf_callback/"}, // If specified, information is sent back to this URL
                        {"callbackMethod","GET"}, // Method used to notify callbackUrl
                    });
    
                    Console.WriteLine(resp.ToString());
    
                    var output = resp.ToString();
                    var res = (Nancy.Response)output;
                    res.ContentType = "text/xml";
                    return res;
                };
    
                // Action URL Example
                Get["/response/conf_action/"] = x =>
                {
                    String conf_name = Request.Query["ConferenceName"];
                    String conf_uuid = Request.Query["ConferenceUUID"];
                    String conf_mem_id = Request.Query["ConferenceMemberID"];
                    String record_url = Request.Query["RecordUrl"];
                    String record_id = Request.Query["RecordingID"];
    
                    Console.WriteLine("Conference Name : {0}, Conference UUID : {1}, Conference Member ID : {2}, Record URL : {3}, Record ID : {4}", conf_name, conf_uuid, conf_mem_id, record_url, record_id);
                    return "Done";
                };
    
                //  Callback URL Example
                Get["/response/conf_callback/"] = x =>
                {
                    String conf_action = Request.Query["ConferenceAction"];
                    String conf_name = Request.Query["ConferenceName"];
                    String conf_uuid = Request.Query["ConferenceUUID"];
                    String conf_mem_id = Request.Query["ConferenceMemberID"];
                    String call_uuid = Request.Query["CallUUID"];
                    String record_url = Request.Query["RecordUrl"];
                    String record_id = Request.Query["RecordingID"];
    
                    Console.WriteLine("Conference Action : {0}, Conference Name : {1}, Conference UUID : {2}, Conference Member ID : {3}, Call UUID : {4}, Record URL : {5}, Record ID : {6}", conf_action, conf_name, conf_uuid, conf_mem_id, call_uuid, record_url, record_id);
                    return "Done";
                };
            }
        }
    }
    
    
    // Outbound Conference
    
    using System;
    using System.Collections.Generic;
    using RestSharp;
    using Plivo.API;
    
    namespace conf_call
    {
        class Program
        {
            static void Main(string[] args)
            {
                RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");
    
                IRestResponse&lt;Call&gt; resp = plivo.make_call(new Dictionary&lt;string,string&gt;()
                {
                    { "to", "2222222222<3333333333" }, // The phone number to which the call has to be placed
                    {"from", "1111111111"}, // The phone number to be used as the caller id
                    {"answer_url","http://example.com/response/conference/"}, // The URL invoked by Plivo when the outbound call is answered
                    {"answer_method","GET"} // The method used to call the answer_url
                });
    
                //Prints the message details
                Console.Write(resp.Content);
    
                Console.ReadLine();
            }
        }
    }
            
    
    1. To make the outbound calls, copy the last code sample into a text editor and save it as conference.py
    2. Add your ‘from’ (source) phone number. This will show up as your Caller ID. Be sure that all phone numbers include country code, area code, and phone number without spaces or dashes (e.g. 14153336666).
    3. Add your ‘to’ (destination) phone numbers. These are the phone numbers you wish to call to. To place calls in bulk, separate your destination phone numbers with the “<” character (e.g. 14156667777<14157778888<14158889999). Be sure that all phone numbers include country code, area code, and phone number without spaces or dashes (e.g. 14153336666).
    4. Change the answer_url to example.com/response/conference which was created previously.

    Create an Application

    1. Create an Application by visiting the Application Page and click on New Application or by using Plivo’s Application API.
    2. Give your application a name. Let’s call it Conference Call. Enter your server URL (e.g., http://www.example.com/response/conference) in the Answer URL field and set the method as POST. See our Application API docs to learn how to modify your application through our APIs.
    3. Click on Create to save your application.

    Create Record Call Application

    Assign a Plivo number to your app

    1. Navigate to the Numbers page and select the phone number you want to use for this app.
    2. Select Conference Call (name of the app) from the Plivo App dropdown list.
    3. Click on ‘Update’ to save.

    Assign Conference Application

    If you don’t have a number, go to the Buy Number page to purchase a Plivo phone number.

    Voice Phone Number Search

    Test and validate

    Whe you make a call to your Plivo number, you will hear the message and then you will be place into a conference.

    Sample XML

    <Response>
        <Speak>You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com</Speak>
        <Conference action="https://www.example.com/response/conf_action/" callbackMethod="GET"
            callbackUrl="https://www.example.com/response/conf_callback/" enterSound="beep:2" method="GET" record="true"
            startConferenceOnEnter="true" endConferenceOnExit="true">demo
        </Conference>
    </Response>

    Sample output for action URL

    Conference Name : demo
    Conference UUID : 1edcce24-94a6-11e4-a29c-498d468c930b
    Conference Member ID : 4387
    Record URL : http://s3.amazonaws.com/recordings_2000/00000000-1111-2222-3333-4444b5555684.mp3
    Recording ID : 1e9eca52-94a6-11e4-b499-0026b92f9684

    Sample output for Callback URL

    Conference Action : enter
    Conference Name : demo
    Conference UUID : 1edcce24-94a6-11e4-a29c-498d468c930b
    Conference Member ID : 4387
    Call UUID : a59bc002-94a9-11e4-ad11-3f7813869e0a
    Record URL : http://s3.amazonaws.com/recordings_2000/00000000-1111-2222-3333-4444b5555684.mp3
    Recording ID : 1e9eca52-94a6-11e4-b499-0026b92f9684