title: Dial a Number Twilio Number to Trigger TWILM Bin
body: <p>We are attempting to create a workflow that will ultimately connect a lead from a contact form, with a business owner.</p>
  
  <p>The workflow is as follows:
  1) Lead fills in contact form
  2) Using Stamplay integration with Unbounce, the lead receives a text asking them if they wanted to be contacted "Now", or "Later".</p>
  
  <p><em>Let's go with lead says "Now"</em></p>
  
  <p>3) Lead says "Now", which will access a webhook URL to decide on what to do next.</p>
  
  <p>In this particular case, saying "Now", will trigger a TWIML bin to dial the business owner. If the business owner doesn't pick up/busy, then we send a text to the lead asking them to send a follow-up text with a 'name' and 'date/time'.</p>
  
  <p>4) The lead replies with a text with this information, and then both the business owner and lead receive separate notifications about the appointment.</p>
  
  <p>I have been able to successfully go through this whole workflow when a user directly dials the Twilio number (not programatically with keywords yet, which is where I need help).</p>
  
  <p><strong>When a call comes in -> TWIML bin</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Response&gt;
    &lt;Pause length="4"/&gt;
    &lt;Say&gt;Please hold, while I connect your call.&lt;/Say&gt;
    &lt;Pause length="4"/&gt;
    &lt;Dial timeout="10"&gt; business owner number &lt;/Dial&gt;
    &lt;Pause length="4"/&gt;
    &lt;Sms&gt;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&lt;/Sms&gt;
  &lt;/Response&gt;
  </code></pre>
  
  <p><strong>When a SMS is received -> webhook URL</strong></p>
  
  <pre><code>&lt;?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-&gt;account-&gt;messages-&gt;create(
      // Cell of owner
      '12345',
      array(
          // A Twilio phone number you purchased at twilio.com/console
          'from' =&gt; "78900",
          // Lead's reply sent to owner asNotification
          'body' =&gt; "Hi &lt;name&gt;. 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-&gt;account-&gt;messages-&gt;create(
      // Cell of Lead
      $number,
      array(
          // A Twilio phone number you purchased at twilio.com/console
          'from' =&gt; "78900",
          // Notification Message sent to Lead
          'body' =&gt; "This is a confirmation that I have received your information, and will be in contact with you soon. Thanks, &lt;name&gt;."
      )
  );
  </code></pre>
  
  <p>Where I am encountering issues is having the lead text "Now", to trigger a phone call between the business owner and lead.</p>
  
  <p>This is the code that I have been attempting to use, except that I have been receiving <strong>11200- HTTP retrieval failure</strong> non-stop. I have also attempted to use $client->account->calls->create, as that's what I used to successfully send messages.</p>
  
  <pre><code>// Read TwiML at this URL when a call connects (attempt to connect to owner)
  $call = $client-&gt;calls-&gt;create(
    'lead-number', // Call this number
    '78900', // From a valid Twilio number
    array(
        'url' =&gt; TWIML Bin of Interest
    )
  );
  </code></pre>
  
  <p>Anyone have any idea what I could do?</p>