I built a WhatsApp Chatbot , which takes the value from backend and sends the reply for example in below image.
i got a message from bot , and i have to select anyone of them either 1,2 or 3 . When i choose 1 . it gives me a reply .if i chose 3 for the last message in screenshot. it gives me reply of the first message which is General Info . But what i want is reply for Request Status Student.
$sql = "SELECT `Reply` ,`IsTemplate` FROM `ChatReply` WHERE UPPER(Message) = '".strtoupper($text)."'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$replyMessageAfterUpdate = rawurlencode($row['Reply']);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'ABCD/CallBackURL',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'userid=209932442&password=$$hdys99@&method=SendMessage&auth_scheme=plain&v=1.1&send_to='.$mobile.'&msg='.$replyMessageAfterUpdate,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
echo $response;
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
}
}
}
So May i know how will i achieve that .
So what i want is something like below What needed
but for me , since it is stored in Database , if i select 1 it will retrieve reply of first message creating a loop . Can anyone please help me with this .