Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward answered call to extension and still stay connected , just like conference #45

Closed
vaibhaodumore-sdn opened this issue Sep 9, 2016 · 6 comments

Comments

@vaibhaodumore-sdn
Copy link

I am new to plivo, please help me out with this one.
I have this requirement like A calls to B. B answers phone and then transfer it C. Transfer to C is working. Now what I need that A, B and C all should be connected at same time, just like conference.

@cachrisman
Copy link

happy to help.

you can use https://github.com/plivo/plivo-examples-node/blob/master/voice/conference/conferenceXML.js to set up a public url (e.g., https://example.com/conference/) then make calls to A, B, and C and set the answer url of the calls to that conference url.

@vaibhao90
Copy link

vaibhao90 commented Sep 10, 2016

This comment from my another account.
But A and B are already on active call ? Whenever I try to add C, B is getting hang up from the call. I was using transfer call api. I also tried the conference api too, but still A and B are getting hang up as

@cachrisman
Copy link

if A and B are on an active call, you need to transfer them using plivo.transfer_call function. See details of params to send in our Call API docs. You need to include legs: 'both', aleg_url, and bleg_url both of which point to your conference url as described in my earlier comment.

Then make a call to C and for the answer_url specify the same conference url as above.

If you still can't figure it out, please post your entire code and describe your call flow from beginning to end and I can help you further.

@benne2jp
Copy link

@cachrisman - I create the business logic behind the app that @vaibhaodumore-sdn is working on and we are still having problems. I will articulate what we're trying to accomplish, what the issue is and @vaibhaodumore-sdn will post the code. Think of the app as a classic call center style application.

Here is what the app should do:

First, Consumer A calls the call center and connects with Phone Agent B. Or, Phone Agent B places an outbound call to Consumer A. Under either scenario, the two parties are connected.

Next, Phone Agent B wishes to transfer the call to Any Person C and remain on the line, forming a 3 person conference call. Any Person C could be 1) an external phone number, 2) an internal extension or 3) a queue.

Finally, Phone Agent B wishes to disconnect himself from the call, leaving Consumer A and Any Person C on the call.

As of right now, we are not able to 1) connect all 3 parties or 2) disconnect Phone Agent B and leave A and C to talk.

Thanks in advance for looking at the code to see what we are missing!

@vaibhaodumore-sdn
Copy link
Author

vaibhaodumore-sdn commented Sep 13, 2016

Here is the code I am using, Please have look.

var plivo = require('plivo');

app.use('/transfer', function(req, res) {
   var phone = req.body.phone
    var params = {
        aleg_url: BaseUrl + '/conference?transferTo=' + phone,
        legs: 'both',
        bleg_url: BaseUrl + '/conference?transferTo=' + phone
    };

    var plivoApi = plivo.RestAPI({
        authId: webPhoneDetails.username,
        authToken: webPhoneDetails.password
    });

    plivoApi.transfer_call(params, function(status, response) {
        if (status >= 200 && status < 300) {
            console.log('Successfully made transfer request.');
            console.log('Response:', response);

        } else {
            console.log('Oops! Something went wrong.');
            console.log('Status:', status);
            console.log('Response:', response);
        }
        res.json({ code: "Success" });
    });

})

app.use('/conference', function(req, res) {
    var plivML = plivo.Response();
    var transferTo = req.body.transferTo;
    var params = {method: 'GET'}
    var paSIP = 'sip:' + transferTo + '@phone.plivo.com';
    plivML.addDial(params).addUser(paSIP);

    plivML.addSpeak("You will now be placed into a demo conference.");
    var params = {
        'enterSound' : "beep:2", // Used to play a sound when a member enters the conference
        'record' : "false",
         'startConferenceOnEnter' : "true", 
    };

    var conference_name = "demo"; // Conference Room name
    plivML.addConference(conference_name, params);
    var xml = plivML.toXML();
     res.set('Content-Type', 'text/xml');
     res.(xml);

})

Final xml is:

<Response>
<Dial><User>sip:@phone.plivo.com</User></Dial>
<Speak>You will now be placed into a demo conference.</Speak>
<Conference enterSound="beep:2" record="true" startConferenceOnEnter="true">demo</Conference>
</Response>

@plivo-sdks
Copy link
Contributor

This issue has been marked as stale because it has not had recent activity and is now closed. Please open the issue if the solution is not found yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants