query($sql); if ($result->num_rows > 0) { $rows = array(); while($row = $result->fetch_assoc()) { //$rows[] = $row; $FName = $row['guest_name']; $convoID = $row['chat_id']; } $ifFount = "1"; } else { $ifFount = "0"; } header('Content-Type: application/json'); echo json_encode(["status"=>$ifFount,"FName"=>$FName,"convoID"=>$convoID]); } //https://autohub.ph/api/bot/checkbotuser.php?mKey=get59e008b5348b452b615a3033729ID&&botUserID={{event.userId}}&convoID = {{event.conversationId}}&FName = {{workflow.FName}} //Update guest Interest if($mykey =="get59e008b5348b452b615a3033729ID"){ $chatID =$_GET['convoID']; $botUserID =$_GET['botUserID']; $FName =$_GET['FName']; $source =$_GET['compCode']; //+++++++++++++++++++++ //CHEKC IF userID Exist $sqlC = "SELECT * FROM `bot_chat` WHERE `bot_user_id`='$botUserID'"; $result = $conn->query($sqlC); if ($result->num_rows > 0) { //do nothing... $stat="exist"; }else{ //++++++++++++++++++++ADD RECORD $sql = "INSERT INTO bot_chat (`id`,`chat_id`,`guest_name`,`bot_user_id`,`source`) VALUES ('','$chatID','$FName','$botUserID','$source')"; if ($conn->query($sql) === TRUE) { $stat='success'; } else{ $stat='error'; } } header('Content-Type: application/json'); echo json_encode(["status" =>$stat]); } $conn->close(); ?>