1
votes

I am using Twilio Service and the voice calls from twilio. I am able to call on browser successfully but there is one issue. Whenever i call (from mobile) on my twilio number (on browser) Every user logged in on that time receive the notification of incoming call. In my case i show them an alertify box. When one user receives the call i want to close the alertify box from other users window. Is there any solution for this ?

This is my voice url example.com/incoming.php :

<?php
header('Content-type: text/xml');
?>
<Response>
    <Dial>
          <Client>someone</Client>
    </Dial>
</Response>

And this is my view file twilio.php

<?php 
        $capability = new ClientToken(xxx,xxx);
        $capability->allowClientOutgoing(xxxxxx);
        $capability->allowClientIncoming("someone");
        $token = $capability->generateToken();
?>

<script type="text/javascript">

      Twilio.Device.setup("<?php echo $token; ?>");

      Twilio.Device.connect(function (conn) {
        alertify.confirm().close()
      });

      Twilio.Device.disconnect(function (conn) {
        alertify.confirm().close()
      });

      Twilio.Device.incoming(function (conn) {
        alertify.confirm('Incoming connection from ' + conn.parameters.From).set('onok', function (closeEvent) { 
          conn.accept();
        })
      });
</script>
1

1 Answers

0
votes

Twilio developer evangelist here.

Firstly, do you want everyone to receive the incoming call? A better system might be to use Twilio's TaskRouter to route calls to an available agent.

In the current case though, you need to notify each of the other agents that the call has been answered. A way to achieve this would be to set up web socket connection to your server for each of the agents. Then, when one agent answers the call you can send a message down the web socket which you can the rebroadcast to the other agents and close the alert box.

This is just an idea though, as there are many paths you can take to do this. There is nothing within Twilio that can help though as we expect each agent to have different names and only receive one call at a time.

Let me know if this helps at all.