I'm running into a double records issue when pulling a list of in-progress
calls using the Twilio REST API. Here is how I want the workflow to go.
- Caller dials client's number. Check
- Caller hears welcome message and is placed into call queue. Check
- Operator sees caller in queue from dashboard. Issue
- Operator chooses to be connected to caller. Check
- Calls are bridged. Check
My problem is that when I make a query for all calls in progress, I am getting double records.
- One record shows up as soon as the caller is placed in the queue,
this record shows the caller's number in the
from
property, and the Twilio number in theto
property. - The second record appears after choosing to connect the calls. It
appears to be a duplicate of the first, but instead of showing the
global Twilio number (the mother number) as the
to
property, it displays the agent's phone number.
Here is how I am pulling the list:
<?php foreach($client->account->calls->getIterator(0,50,array("Status" => "in-progress")) as $call): ?>
<tr>
<td><?=$call->start_time?></td>
<td><?=$call->duration?></td>
<td><?=$call->from?></td>
<td><?=$call->to?></td>
<td>
<form action="actions/queue.php" method="post">
<input type="hidden" name="caller" value="<?=$call->parent_call_sid?>" />
<input type="submit" value="Return Call to Queue" style="color: #555;" />
</form>
</td>
</tr>
<?php endforeach; ?><!-- foreach calls as call -->
A few extra things worth noting.
- This has a little bit of styling so that I can see what I am doing, most of these interactions will eventually take place on an iPad or desktop software.
- The second record mentioned above (the one that displays the agent's phone number) can move between the list of calls that show up as queued and the list of calls that show up as
in-progress
. It is only the first record (the one showing the Twilio phone number) that always appears anin-progress
- Yes, I can filter the record out on my end by ignoring the records that show the Twilio number as the
to
property, but I would prefer to filter it on Twilio's end, if possible.