PHP code example of bassem-shoukry / laravel-chatwoot
1. Go to this page and download the library: Download bassem-shoukry/laravel-chatwoot 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/ */
bassem-shoukry / laravel-chatwoot example snippets
// routes/api.php
use BassamShoukry\LaravelChatwoot\LaravelChatwootServiceProvider;
LaravelChatwootServiceProvider::routes(
prefix: 'api/webhooks/chatwoot',
middleware: ['api'],
);
use BassamShoukry\LaravelChatwoot\Events\MessageCreated;
Event::listen(MessageCreated::class, function (MessageCreated $event): void {
// $event->message is a typed Message DTO
// $event->accountName is the account that received the webhook
});
use BassamShoukry\LaravelChatwoot\ChatwootManager;
use BassamShoukry\LaravelChatwoot\Testing\ChatwootFake;
$fake = ChatwootFake::swap();
$fake->stub('POST', 'api/v1/accounts/1/conversations/9/messages', [
'id' => 7, 'content' => 'hello',
]);
app(ChatwootManager::class)->messages()->send(9, 'hello');
expect($fake->calls)->toHaveCount(1);