特维利奥 php 中的耳语消息


Whisper Message in twilio php

<Response>
    <Dial>
        <Number url="other-script">
            4151234567
        </Number>
    </Dial>
</Response>

我尝试上面的代码,但它不适用于耳语消息。我想问在"其他脚本"的那一页上写什么?

请详细定义问题。请参阅此页面 https://www.twilio.com/docs/tutorials/ivrs-extensions下载 IVR.zip。

请参阅 - IVR 日志记录和报告文件中的此代码

 header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<Response>';
$user_pushed = (int) $_REQUEST['Digits'];
if ($user_pushed == 0)
{
    echo '<Say>Taking you back to the main menu</Say>';
    echo '<Redirect>handle-incoming-call.xml</Redirect>';
}
else if ($user_pushed == 1)
{
    echo '<Say>Connecting you to agent 1. All calls are recorded.</Say>';
    echo '<Dial record="true">';
    echo '<Number url="screen-caller.xml">+1NNNNNNNNNN</Number>';
    echo '</Dial>';
}
else if ($user_pushed == 2)
{
    echo '<Say>Connecting you to agent 2. All calls are recorded.</Say>';
    echo '<Dial record="true">';
    echo '<Number url="screen-caller.xml">+1NNNNNNNNNN</Number>';
    echo '</Dial>';
}
else {
    echo "<Say>Sorry, that extension is unknown.</Say>";
    echo '<Redirect method="GET">handle-user-input.php?Digits=2</Redirect>';
}
echo '</Response>';

Twilio开发者布道者在这里。

在这种情况下,"other-script"需要指向一个 URL,该 URL 在接收呼叫的人连接到呼叫者之前,将您想要播放的 TwiML 作为"耳语者"返回给他们。

因此,如果您只是希望被呼叫者在连接到呼叫者之前收到语音消息,则需要"/other-script"指向一个文件,该文件为:

<Response>
  <Say>You are being connected to a caller.</Say>
</Response>

这将简单地读出消息,然后连接两个呼叫。

如果要使用"Whisper"为呼叫者提供拒绝呼叫的选项,则需要"/other-script"指向如下所示的脚本:

<Response>
  <Gather action="/handle-input" numDigits="1">
    <Say>You are receiving a call. Dial one to accept and any other digit to decline</Say>
  </Gather>
  <!-- If customer doesn't input anything, prompt and try again. -->
  <Say>Sorry, I didn't get your response.</Say>
  <Redirect>/other-script</Redirect>
</Response>

在这种情况下,您还需要在"/handle-input"提供一些 TwiML。这需要根据数字输入进行操作,因此需要是一个脚本。我看到你标记了问题 PHP,所以这是它在 PHP 中的样子:

<?php
  header('Content-type: text/xml');
  echo '<?xml version="1.0" encoding="UTF-8"?>';
  echo '<Response>';
  $user_pushed = (int) $_REQUEST['Digits'];
  if ($user_pushed == 1)
  {
    echo '<Say>Connecting you to the caller.</Say>';
  }
  else {
    echo '<Hangup />';
  }
  echo '</Response>';
?>
如果

接听电话的人在提示符下拨打了 1,这将连接呼叫,如果该人拨打了任何其他数字,这将挂断呼叫。

Twilio 文档中提供了有关呼叫耳语和录音呼叫的更深入的教程,您可能会发现遵循这些教程也很有用。