Merge pull request 'Fix IVR queue options dropping calls' (#4) from feature/webview-softphone into main
Create Release / build (push) Successful in 1m20s
Create Release / build (push) Successful in 1m20s
This commit was merged in pull request #4.
This commit is contained in:
commit
4707213ee9
1 file changed
+12
-4
@@ -1064,11 +1064,19 @@ class TWP_Webhooks {
|
||||
|
||||
if ($position) {
|
||||
error_log('TWP IVR Queue: Call added to position ' . $position);
|
||||
// Generate TwiML for queue wait with proper callback URL
|
||||
// Redirect to our custom queue wait handler (same as workflow queue steps).
|
||||
// A bare <Enqueue> with a <Task> child is invalid without TaskRouter and drops the call.
|
||||
$twiml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><Response></Response>');
|
||||
$enqueue = $twiml->addChild('Enqueue');
|
||||
$enqueue->addAttribute('waitUrl', home_url('/wp-json/twilio-webhook/v1/queue-wait?queue_id=' . $queue_id));
|
||||
$enqueue->addChild('Task', json_encode(array('queue_id' => $queue_id, 'position' => $position)));
|
||||
$say = $twiml->addChild('Say', 'Please hold while we connect you to the next available agent.');
|
||||
$say->addAttribute('voice', 'alice');
|
||||
$wait_url = add_query_arg(array(
|
||||
'queue_id' => $queue_id,
|
||||
'call_sid' => urlencode($call_data['call_sid'])
|
||||
), home_url('/wp-json/twilio-webhook/v1/queue-wait'));
|
||||
$redirect = $twiml->addChild('Redirect');
|
||||
$redirect[0] = $wait_url;
|
||||
$redirect->addAttribute('method', 'POST');
|
||||
error_log('TWP IVR Queue: Redirecting to queue wait handler: ' . $wait_url);
|
||||
return $this->send_twiml_response($twiml->asXML());
|
||||
} else {
|
||||
error_log('TWP IVR Queue: Failed to add call to queue');
|
||||
|
||||
Reference in new issue
Block a user