title: Slack API Interactive Messages, receiving Button click
body: <p>I work at an MSP and I'm trying to integrate our ticketing system (Autotask) with Slack. So far, I have set up an HTTP POST request to some PHP code when a new ticket is created, which posts a chat message in a certain channel ("New Ticket Created! [Ticket Title] - [Ticket Description]" etc.) using Incoming Webhooks. Below is the important bits of that code:</p>
  
  <pre><code>&lt;?php 
  
  require_once __DIR__ . '/src/autoload.php';
  
  //Gets ticket number from HTTP POST
  $ticketNum = $_POST['subject'];
  
  //Generated at api.slack.com/apps &gt; Incoming webhooks (for the channel I'm posting in)
  $responseURL = 'https://hooks.slack.com/services/XXXXXXXXXXXX';
  
  class Response {
      public $response_type = "";
      public $text = "";
      public $attachments = array();
  }
  
  
  
  //*****
  //QUERYING TICKETING SYSTEM API FOR TICKET INFORMATION
  //THIS CODE WORKS, OMITTED FOR EASIER READING
  //*****
  
  
  
  
  $r = new Response();
  $r-&gt;response_type = "in_channel";
  $r-&gt;text = "New Ticket Created: \n*".$ticketName."* (".$ticketNum.") \n".$ticketDescription;
  $r-&gt;attachments = array(
      0 =&gt; array('callback_id' =&gt; 'newTicketAction', 'text' =&gt; 'Select an action:',
          'color' =&gt; '95baa9', 'actions' =&gt; array(
          0 =&gt; array('name' =&gt; 'newTicketAction', 'text' =&gt; 'Accept', 'type' =&gt; 'button', 
              'value' =&gt; 'accept', 'style' =&gt; 'primary'),
          1 =&gt; array('name' =&gt; 'newTicketAction', 'text' =&gt; 'View', 'type' =&gt; 'button', 
              'value' =&gt; 'view')
          )
      )
  );
  
  
  header('Content-Type: application/json');
  
  //Using CURL
  $curl = curl_init();
  curl_setopt_array($curl, array(
      CURLOPT_URL =&gt; $responseURL,
      CURLOPT_POST =&gt; 1,
      CURLOPT_RETURNTRANSFER =&gt; true,
      CURLOPT_POSTFIELDS =&gt; json_encode($r)
  ));
  
  $resp = curl_exec($curl);
  var_dump($resp);
  curl_close($curl);
  
  ?&gt;
  </code></pre>
  
  <p>This works and posts a message in the correct channel that looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/cYQN4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cYQN4.png" alt="enter image description here"></a></p>
  
  <p><strong>The problem I'm having is with responding to those button clicks.</strong> I have my Request URL set up, pointing to another PHP script. My understanding is that the button click sends another HTTP POST request to this page with a JSON object, which has a <code>payload</code> item. My hunch is I'm accessing this incorrectly. My code is below:</p>
  
  <pre><code>&lt;?php 
  
  require_once __DIR__ . '/src/autoload.php';
  
  //get information from HTTP POST, sent at button click
  $payload = $_POST['payload'];
  $data = json_decode($payload,true);
  
  $responseURL = $data -&gt; response_url;
  
  class Response {
      public $response_type = "";
      public $text = "";
      public $attachments = array();
  }
  
  $r = new Response();
  $r-&gt;response_type = "in_channel";
  $r-&gt;text = "Ticket Accepted";
  
  header('Content-Type: application/json');
  
  //Using CURL
  $curl = curl_init();
  curl_setopt_array($curl, array(
      CURLOPT_URL =&gt; $responseURL,
      CURLOPT_POST =&gt; 1,
      CURLOPT_RETURNTRANSFER =&gt; true,
      CURLOPT_POSTFIELDS =&gt; json_encode($r)
  ));
  
  $resp = curl_exec($curl);
  var_dump($resp);
  curl_close($curl);
  
  ?&gt;
  </code></pre>
  
  <p>You can see right now I'm just trying a simple response message for testing purposes, but when I click the 'Accept' button I get the following response:</p>
  
  <p><a href="https://i.stack.imgur.com/NRilL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NRilL.png" alt="enter image description here"></a></p>
  
  <p>I've scoured the web and cannot find a solid tutorial on Interactive Messages which includes "receiving" button clicks. Any help would be greatly appreciated. </p>