1. Go to this page and download the library: Download richdynamix/chatbase-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
richdynamix / chatbase-api example snippets
// API KEY and default platform must be set
$apiKey = '12345-12345-12345';
$platform = 'messenger';
// Instantiate a new Chatbase client with the dependency of Guzzle
$client = new \Richdynamix\Chatbase\Service\ChatbaseClient(new \GuzzleHttp\Client());
// Instantiate a new FieldManager with the dependency of the API KEY and default platform
$fieldsManager = new \Richdynamix\Chatbase\Entities\FieldsManager($apiKey, $platform);
// Instantiate a new GenericMessage with the dependency of the Chatbase client and the FieldsManager
$chatbase = new \Richdynamix\Chatbase\Service\GenericMessage($client, $fieldsManager);
// send a user message to chatbase
$send = $chatbase->userMessage()->with(['user_id => '12345', 'message' => 'hello'])->send();
return [
/*
* The Chatbase API key
*/
'api_key' => env('CHATBASE_API_KEY'),
'platform' => env('CHATBASE_DEFAULT_PLATFORM', 'messenger'),
];
// Directly from the IoC
$chatbase = app(Richdynamix\Chatbase\Contracts\GenericMessage::class);
// From a constructor
class FooClass {
public function __construct(Richdynamix\Chatbase\Contracts\GenericMessage $chatbase) {
// . . .
}
}
// From a method
class BarClass {
public function barMethod(Richdynamix\Chatbase\Contracts\GenericMessage $chatbase) {
// . . .
}
}