2017-01-24 41 views
1

我們正在嘗試創建一個工作流程,最終將聯繫表單中的潛在客戶與業主關聯起來。撥打號碼Twilio號碼觸發TWILM Bin

的工作流程如下: 1)鉛接觸形式 2)使用填充有Unbounce Stamplay一體化,率先收到短信問他們,如果他們想聯繫「現在」,或「後來」。

讓我們用鉛說,「現在」

3)鉛說,「現在」,這將訪問網絡掛接網址,以決定下一步該怎麼做。

在這種特殊情況下,說「現在」,將觸發一個TWIML箱撥打業主。如果企業主不上班/忙碌,那麼我們會向主管發送一條文字,要求他們發送帶有「姓名」和「日期/時間」的後續文字。

4)領導回覆包含此信息的文本,然後企業負責人和負責人都會收到有關該約會的單獨通知。

當用戶直接撥打Twilio號碼(不用編程方式使用關鍵字,這是我需要幫助的地方)時,我已經能夠成功地完成整個工作流程。

當有電話打進來 - > TWIML斌

<?xml version="1.0" encoding="UTF-8"?> 
<Response> 
    <Pause length="4"/> 
    <Say>Please hold, while I connect your call.</Say> 
    <Pause length="4"/> 
    <Dial timeout="10"> business owner number </Dial> 
    <Pause length="4"/> 
    <Sms>I am currently unavailable. If you'd like me to get in touch, pls reply back with your name, and a time that would work best for you. Thanks, Adam</Sms> 
</Response> 

當收到短信 - >網絡掛接URL

<?php 
// Require the bundled autoload file - the path may need to change 
// based on where you downloaded and unzipped the SDK 
require __DIR__ . '/twilio-php-master/Twilio/autoload.php'; 

// Use the REST API Client to make requests to the Twilio REST API 
use Twilio\Rest\Client; 

// Your Account SID and Auth Token from twilio.com/console 
$sid = 'xyz'; 
$token = 'xyz'; 
$client = new Client($sid, $token); 

$number = $_POST['From']; 
$body = $_POST['Body']; 

//Sends a message to the owner 
$sms = $client->account->messages->create(
    // Cell of owner 
    '12345', 
    array(
     // A Twilio phone number you purchased at twilio.com/console 
     'from' => "78900", 
     // Lead's reply sent to owner asNotification 
     'body' => "Hi <name>. You have a new lead. The information for this lead is: $body. You can contact them at $number" 
    ) 
); 

//Sends a message to the lead 
$sms = $client->account->messages->create(
    // Cell of Lead 
    $number, 
    array(
     // A Twilio phone number you purchased at twilio.com/console 
     'from' => "78900", 
     // Notification Message sent to Lead 
     'body' => "This is a confirmation that I have received your information, and will be in contact with you soon. Thanks, <name>." 
    ) 
); 

我在哪裏遇到的具有領先文本問題「現在」,觸發企業主和主管之間的電話。

這是我一直在試圖使用的代碼,除了我一直在收到11200- HTTP檢索失敗不間斷。我也試圖使用$ client-> account-> calls-> create,因爲這是我用來成功發送消息的東西。

// Read TwiML at this URL when a call connects (attempt to connect to owner) 
$call = $client->calls->create(
    'lead-number', // Call this number 
    '78900', // From a valid Twilio number 
    array(
     'url' => TWIML Bin of Interest 
) 
); 

任何人都知道我能做什麼嗎?

回答

0

退房的creating a dynamic response的例子:

<?php 
// Get the PHP helper library from twilio.com/docs/php/install 

require_once '/path/to/vendor/autoload.php'; // Loads the library 
use Twilio\Twiml; 

$response = new Twiml; 
$body = $_REQUEST['Body']; 

if($body == 'hello'){ 
    $response->message('Hi!'); 
}else if($body == 'bye'){ 
    $response->message('Goodbye'); 
} 
print $response; 

在你的情況,你會修改,如果「現在」是在$body你可以創建你的代碼看起來不錯呼叫。

$call = $client->calls->create(
    "+1415XXXXXXX", "+1415XXXXXXX", 
    array("url" => "link_to_twiml_bin") 
); 

在問候11200 HTTP檢索錯誤,請看看possible solutions here尤其是:

確保您的網絡服務器允許HTTP POST請求靜態 資源(如URL指向。 xml或.html文件)

+0

非常感謝在Megan找到我。將檢查出來。 –