0

Hi guys i am trying to have a unique name for my conference. What i have tried is to use the session and put the user id in the conference but unfortunately i have failed. The function wont read my session id. This is my code below for transferring the caller to conference. Btw i am using codeigniter as my framework.

    public function redirect_queue_conference()
{
    $client = $this->init_client();
    $call = $client->account->calls->get($_POST["CallSid"]);
    $call->update(array(
        "Url" => HTTP_BASE_URL."agent/call_controls/forward_queue_conference",
        "Method" => "POST"
    ));
}

And this is my code on creating conference name which is my problem because iam using session.

    public function forward_queue_conference()
{     
    $roomName = $this->session->userdata('user_id');
    $this->twilio->CallerToQueue($roomName);
}

In my twilio console in debugger it's saying that the conference is not valid.

  • There is not enough information here for you to get any assistance... I have absolutely no idea what a 'conference' is in your description and you are calling a method you haven't shown. Asking a question properly will get you a prompt response. – Brian Ramsey Feb 15 '17 at 10:51

1 Answers1

0

Twilio developer evangelist here.

What it looks like is you're forwarding a user's call into a conference. There's two things that I can see in your forward_queue_conference method which would cause this not to work.

Firstly, Twilio is making the HTTP request to your server so is unlikely to be logged in and have a user_id.

Secondly, you're not, as far as I can tell, returning TwiML to enter the conference. You're using a function CallerToQueue which I don't know and doesn't seem to be part of the Twilio documentation.

To fix the first part, if it is your user that is triggering the move to the conference, then you could add the user id into the URL you redirect the call with.

    public function redirect_queue_conference()
{
    $roomName = $this->session->userdata('user_id');
    $client = $this->init_client();
    $call = $client->account->calls->get($_POST["CallSid"]);
    $call->update(array(
        "Url" => HTTP_BASE_URL."agent/call_controls/forward_queue_conference?room=".$roomName,
        "Method" => "POST"
    ));
}

You could then get that out of the request later. I'd write the code for this but I see you've tagged the question Codeigniter and I just read that getting query string parameters from requests is a pain so I'll leave you with that.

Once you've got the roomName from the request you need to return it as TwiML. Again, I'm not sure what library you're using for this, but if I was using the official Twilio PHP library it would look a little like this:

    public function forward_queue_conference()
{     
    $roomName = getRoomNameFromQueryStringSomehow();
    $response = new Twiml;
    $dial = $response->dial();
    $dial->conference($roomName);
    $response;
}

Let me know if that helps at all.

Community
  • 1
  • 1
philnash
  • 70,667
  • 10
  • 60
  • 88
  • This worked but i still have problem with the CALLBACK URL in twilio i need to send id too in that url. –  Feb 15 '17 at 13:02
  • Can you elaborate? What's the entire call flow here? – philnash Feb 15 '17 at 13:03
  • because the code below will transfer the caller to conference which worked correctly because of your help. What i need now is the worker to be transferred to the conference too with a unique conference name using the worker id. –  Feb 15 '17 at 13:27
  • Can you not use the same code to transfer the other caller into the conference too? That way you share the ID from that one action? – philnash Feb 15 '17 at 13:49