You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, thank you for this framework! I have been building a chatbot with some JS libraries and really wanted a way to protect some of the clever coding I have done. This is a fantastic solution.
One of my current goals to use my nice GUI CRUD editor to build out my conversations.
The script below connects to a Database and creates a command for each row in the table.
However, every response is equal to the last row's response value. Can anyone provide me with a hint on what I should be googling to find a solution? Right now I am focused on Variable Scopes.
Cheers!
Brandon
<?php
use App\Http\Controllers\BotManController;
$servername = "localhost";
$username = "USR";
$password = "PASS";
$dbname = "DB";
$botman = resolve('botman');
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, command, responce, function FROM commands_general";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
// echo "<br> id: ". $row["id"]. " - Command: ". $row["command"]. " " . $row["responce"] . "<br>";
$command = $row["command"];
$GLOBALS['responce'. $row["id"]] = $row["responce"];
$GLOBALS['id'] = $row["id"];
$botman->hears($command, function ($bot) {
global $id;
// global $responce.$x;
$bot->reply('heard you '.$id);
$id ++;
});
}
} else {
echo "0 results";
}
$conn->close();
The text was updated successfully, but these errors were encountered:
Hi!
First off, thank you for this framework! I have been building a chatbot with some JS libraries and really wanted a way to protect some of the clever coding I have done. This is a fantastic solution.
One of my current goals to use my nice GUI CRUD editor to build out my conversations.
The script below connects to a Database and creates a command for each row in the table.
However, every response is equal to the last row's response value. Can anyone provide me with a hint on what I should be googling to find a solution? Right now I am focused on Variable Scopes.
Cheers!
Brandon
The text was updated successfully, but these errors were encountered: