botman / docs Goto Github PK
View Code? Open in Web Editor NEWBotMan documentation
BotMan documentation
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
<?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();
It seems I can't reopen #69 , but info is actual and absent in main docs.
You need to manually load corresponding driver to receive attachments, for example:
DriverManager::loadDriver(\BotMan\Drivers\Telegram\TelegramPhotoDriver::class);
Otherwise it silently don't work.
Add it somewhere, plz.
Here: https://github.com/botman/docs/blob/master/driver-telegram.md
or here: https://github.com/botman/docs/blob/master/receiving-additional-content.md .
Should I make PR?
I think you might have forgotten to update the method name in https://github.com/botman/docs/blob/master/driver-slack.md from BotManFactory::createForRTM to BotManFactory::createForSocket. Maybe the file and class names in https://github.com/botman/driver-slack/tree/master/src also need updating?
I tried getting the URL of an image sent by the user to the bot so that i can pass it for other functions but i keep getting this error
Uncaught Error: Call to a member function getUrl()
and this other one
/app/vendor/mpociot/botman/src/Mpociot/BotMan/BotMan.php(371): call_user_func_array(Object(Closure), Array)
Here is my code:
require 'vendor/autoload.php';
use Mpociot\BotMan\Messages\Message;
use Mpociot\BotMan\BotManFactory;
use Mpociot\BotMan\BotMan;
use BotMan\BotMan\Messages\Attachments\File;
use BotMan\BotMan\Messages\Attachments\Image;
use BotMan\BotMan\Messages\Outgoing\OutgoingMessage;
use BotMan\Drivers\DriverManager;
$config = [
// Your driver-specific configuration
'telegram_token'=>"<token>",
];
// create an instance
$botman = BotManFactory::create($config);
// give the bot something to listen for.
$botman->hears('/start', function (BotMan $bot) {
$bot->reply('Hello yourself.');
});
$botman->receivesImages(function($bot,$images) {
foreach($images as $image){
$url=$image->getUrl();
$title=$image->getTitle();
$bot->reply("hello: ".$url);
}
});
// start listening
$botman->listen();
When the bot receives an image, it fails to respond. What might be the problem?
what is the best way to pass along some JS in my responses. Can I get something like the following code as a response?
"status": 200, "messages": [ { "type": "text", "text": "heard you 2", "script": "alert('Hello World');", "attachment": null, "additionalParameters": [] } ] }
I notice there are some drivers available that are not listed in the docs (such as discord?). Could a list of all available drivers be added, including drivers built by others?
Can anyone provide a detailed example of the Dialogflow implementation?I have created a bot, using the facebook driver and I want to implement Dialogflow to make the interaction more human. The official BotMan documentations are lack about information on the integration of NLP platforms, the example doesn't help much.
Thank you
The documentation seems to lack any description of what the $config
variable should contain.
The installation docs under 'Basic Usage without BotMan Studio' stipulate a $config
variable, and define it as an array, but not any of the keys.
$config = [
// Your driver-specific configuration
// "telegram" => [
// "token" => "TOKEN"
// ]
];
The 'driver-specific configuration' seems to suggest this would be in the driver. However all I could find was the root array key for the driver, but not what any of the configuration key values were.
The BotMan
class which takes the $config
variable does not type hint $config
as an array, so I'm not sure if it has to be an array or not.
My specific use-case is that I'm trying to configure Hipchat, and the documentation for this driver does not detail any of the configuration required.
So I feel at a bit of a dead-end here. This leads me to think there could be some improvements to the documentation made, for those of us who are not using BotMan Studio, or paying for the video course.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.