2016-12-05 29 views
2

如何在Twilio中使用撥號盤功能?我正在通過瀏覽器撥打電話號碼,撥打電話link用於擴展呼叫的撥號盤 - Twilio

TwiML代碼:

<?php 
header('Content-type: text/xml'); 

// put a phone number you've verified with Twilio to use as a caller ID number 
$callerId = '+1xxxxxxxxx'; 

// put your default Twilio Client name here, for when a phone number isn't given 
$number = 'Name'; 

// get the phone number from the page request parameters, if given 
if (isset($_REQUEST['PhoneNumber'])) { 
    $number = htmlspecialchars($_REQUEST['PhoneNumber']); 
} 

// wrap the phone number or client name in the appropriate TwiML verb 
// by checking if the number given has only digits and format symbols 
if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) { 
    $numberOrClient = "<Number>" . $number . "</Number>"; 
} else { 
    $numberOrClient = "<Client>" . $number . "</Client>"; 
} 
?> 
<Response> 
    <Dial callerId="<?php echo $callerId ?>"> 
      <?php echo $numberOrClient ?> 
    </Dial> 
</Response> 

如何我可以在頁面中添加撥號盤,使用戶應該能夠進入extention或菜單選項?例如:點擊1連接到銷售經理。

請幫助我,如果有人知道這一點。提前致謝。

回答

1

Twilio福音傳教士在這裏。

查看Twilio Client for JavaScript SDK中的sendDigits函數。調用這個函數會告訴SDK播放DTMF音。

function senddigits() { 
    if (connection!=null) { 
     connection.sendDigits("1"); 
    } 
} 

希望有所幫助。