title: Search FB Messenger Message for Specific Word in PHP
body: <p>So I'm trying to create a Facebook Messenger Chatbot, a very simple one. I have it working with a hardcoded response, but I want it to be able to read the senders message and respond in a specific way if it finds that word - like how chatbots should. I' trying to do so by using <code>preg_match()</code> but when I use my current code, the bot doesn't reply at all. Here's my code:</p>
  
  <pre><code>&lt;?php
  /**
   * Webhook for Facebook Messenger Bot
   */
  $access_token = "{mytoken}";
  $verify_token = "{mytoken2}";
  
  $hub_verify_token = null;
  if (isset($_REQUEST['hub_challenge'])) {
      $challenge = $_REQUEST['hub_challenge'];
      $hub_verify_token = $_REQUEST['hub_verify_token'];
  }
  if ($hub_verify_token == $verify_token) {
      echo $challenge;
  }
  
  $input = json_decode(file_get_contents('php://input'), true);
  $sender = $input['entry'][0]['messaging'][0]['sender']['id'];
  $message = $input['entry'][0]['messaging'][0]['message']['text'];
  
  // perform a case-Insensitive search for the word "time"
  if (preg_match('[hi|hello|sup]', $message)) {
      $answer = "Hiya!";
  }
  else {
      $answer = "IDK.";
  }
  
  // send the response back to sender
  // 'text': 'Hiya!'
  
  $jsonData = "{
      'recipient': {
          'id': $sender
      },
      'message': {
          'text': $answer
      }
  }";
  
  // initiate cURL.
  $ch = curl_init("https://graph.facebook.com/v2.6/me/messages?access_token=$access_token");
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
  curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
  if (!empty($input['entry'][0]['messaging'][0]['message'])) {
      curl_exec($ch);
  }
  </code></pre>