HELP
Create a script with the following content and provide its URL as WebHook.
define("API_KEY", "YOUR_API_KEY"); try { if (isset($_SERVER["HTTP_X_SG_SIGNATURE"])) { $hash = base64_encode(hash_hmac('sha256', $_POST["messages"], API_KEY, true)); if ($hash === $_SERVER["HTTP_X_SG_SIGNATURE"]) { $messages = json_decode($_POST["messages"], true); /** * For example :- * $messages = [ * 0 => [ * "ID" => "1", * "number" => "+11234567890", * "message" => "This is a test message.", * "deviceID" => "1", * "simSlot" => "0", * "userID" => "1", * "status" => "Received", * "sentDate" => "2018-10-20T00:00:00+02:00", * "deliveredDate" => "2018-10-20T00:00:00+02:00" * "groupID" => null * ] * ] * * senDate represents the date and time when the message was received on the device. * deliveredDate represents the date and time when the message was received by the server. */ foreach ($messages as $message) { if(strtolower($message["message"]) === "hi") { // Reply to message using API or execute some commands. Possibilities are limitless. } } } else { http_response_code(401); error_log("Signature don't match!"); } } else { http_response_code(400); error_log("Signature not found!"); } } catch (Exception $e) { error_log($e->getMessage()); }