Twilio odd 记录动词行为,需要建议

Twilio odd Record verb behaviour, need advice

我有一个 phone-树,如果来电者不提供分机,它会将其排队,并且在播放音乐时,来电者可以随时按键留言。

如果用户有分机,坐席不接,就去LeaveMessage.php,打record verb就好了,来电可以留言,加到我的数据库和电子邮件。完美运行。

奇怪的记录动词行为发生在我试图从被重定向到队列之外的调用者那里点击同一个 LeaveMessage.php 脚本时。它只是跳过那个 Record 动词,即使它来自其他任何地方都可以正常工作。

我一辈子都弄不明白为什么它会这样。

index.php

if( $_REQUEST['Digits'] ) {
    echo '<Redirect>./LeaveMessage.php?exten=' . $digits . '</Redirect>';
}
echo '<Say>Thank you for calling.</Say>';
echo '<Gather timeout="4">';
echo '<Say>If you know your parties extension, please enter it now.</Say>';
echo '<Say>If you do not know your parties extension, please hold while we connect you to an operator.</Say>';
echo '</Gather>';
//redirect to enqueue caller, and dialOut and event handlers.
echo '<Redirect>./EnqueueCaller.php</Redirect>';

LeaveMessage.php

echo '<Say>Please leave a message after the tone. </Say>';
echo '<Record action="./handle_message.php?exten=' . $exten . '" maxLength="35" method="POST" timeout="7" playBeep="true" />';
echo '<Gather action="./leave_a_message.php?exten=' . $exten . '" method="GET" >';
echo '<Say>I\'m sorry, the message was not received, press any key to try again.</Say>';
echo '</Gather>';

WaitQueue.php

if( isset( $_REQUEST['Digits'] ) ) {
    echo '<Redirect>./leave_a_message.php</Redirect>';
    echo '</Response>';
    exit();
}
else if( isset( $_REQUEST['hold'] ) ) {
    echo '<Gather action="./wait.php?Digits=true" method="POST" numDigits="1" timeout="1">';
    echo '<Say>At any time press any number to leave a message, and an agent will call you back shortly.</Say>';
}
else {
    echo '<Say> You are now on hold.</Say>';
    echo '<Gather action="./wait.php?Digits=true" method="POST" numDigits="1" timeout="1">';
}
echo '<Say>At any time press any number to leave a message, and an agent will call you back shortly.</Say>';
echo '<Play>';
echo 'http://com.twilio.sounds.music.s3.amazonaws.com/ClockworkWaltz.mp3';
echo '</Play>';
echo '</Gather>';
echo '<Redirect>./wait.php?hold=true</Redirect>';
echo '</Response>';

这里是 Twilio 开发人员布道者。

你的问题是,在呼叫者跳过 <Record> 动词的情况下,你的呼叫者仍在队列中。在队列中时,用户会听到 waitUrlyou can only the use Play, Say, Pause, Hangup, Gather, Redirect and Leave verbs.

中发生的事情

但是,您并非不走运。为了记录消息,您需要用户自己离开队列,您可以使用 <Leave> verb 来完成。当您 <Leave> 直接在 <Enqueue> 动词之后将对 TwiML 的调用 returns 排队时,您可以在其中添加 <Record> TwiML。

您没有提供您的 EnqueueCaller.php 文件,但您的想法是您的 Enqueue 可能如下所示:

<Response>
  <Enqueue>Queue Name</Enqueue>
  <Redirect>./leave_a_message.php</Redirect>
</Response>

而您的 WaitQueue.php 将以(注意 <Leave> 而不是 <Redirect>)开头:

if( isset( $_REQUEST['Digits'] ) ) {
    echo '<Leave/>';
    echo '</Response>';
    exit();
}

或者,您可以使用 REST API 手动使用户出队,然后以 this question eventually did.

中的开发人员身份将他们重定向到 <Record> TwiML

让我知道这是否有帮助!