会议电话:等待第一个人回应,然后连接第二个人

Conf call: Wait for first person to respond, then connect second person

基本情况:系统会呼叫A。如果A拿起phone它会呼叫B,然后2会接通。

我在这里看了几个答案,例如,但还是不清楚。

下面的方法行得通吗?它会调用 PERSON_A 如果有人响应它会连接到会议然后调用 PERSON_B 并连接到同一个会议?我需要先开始会议吗?

$response = new VoiceResponse();
$dial = $response->dial('PERSON_A');
if($dial->conference('Room 1234')) {
    $dial = $response->dial('PERSON_B');
    $dial->conference('Room 1234');
}

此处为 Twilio 开发人员布道师。

当您使用 Twilio 控制调用时,它有两种工作机制。 Twilio REST API which your application can use to make things happen, like start or change a call. Then there are webhooks, which are HTTP requests that Twilio makes to your application when things change in a call, like someone dialling your Twilio number, entering data on the phone, or an person answering an outbound call. You respond to webhooks with TwiML 是 XML 的一个子集,其中包含有关接下来如何处理调用的说明。

在这种情况下,您想先给 A 打电话。为此,您需要 the REST API to make that call。当 A 回答 phone 时,Twilio 将向您的应用程序发出 webhook 请求,以了解下一步要做什么。此时,您既可以再次使用 REST API 呼叫人员 B,也可以通过使用 TwiML 进行响应将人员 A 加入电话会议。

因此,您最初的出站 REST API 调用应该看起来像这样:

use Twilio\Rest\Client;

// Find your Account Sid and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$call = $twilio->calls
               ->create($personANumber, // to
                        $yourTwilioNumber, // from
                        ["url" => "http://example.com/conference.php"]
               );

您在拨打电话时发送的 URL 将是 Twilio 发送 webhook 请求的地方。因此,在这种情况下,为了响应 example.com/conference.php,您需要拨打另一个人并使用 TwiML 进行响应,以指示 A 加入电话会议。

这一次,您实际上可以在 REST API 响应中发送 TwiML,而不是发送 URL。像这样:

use Twilio\Rest\Client;
use Twilio\TwiML\VoiceResponse;

// Find your Account Sid and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$twiml = new VoiceResponse();
$dial = $twiml->dial();
$dial->conference("Conference Name");

$call = $twilio->calls
               ->create($personBNumber, // to
                        $yourTwilioNumber, // from
                        ["twiml" => $twiml->toString()]
               );

echo $twiml.toString();

在这种情况下,我对通话的两个部分都使用了相同的 TwiML,因为它们都进入了同一个会议。您可以根据发生的情况使用不同的 TwiML 进行响应。

如果有帮助请告诉我。