ziming/laravel-crisp

Wrapper Library for Crisp Chat Rest Api

Fund package maintenance!
ziming

0.6 2025-06-28 15:33 UTC

This package is auto-updated.

Last update: 2025-07-04 05:58:02 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A laravel Crisp library for Crisp Chat REST API. Still in progress.

Support me

You can donate to my github sponsor.

Installation

You can install the package via composer:

composer require ziming/laravel-crisp

You can publish the config file with:

php artisan vendor:publish --tag="crisp-config"

This is the contents of the published config file:

return [
    'website_id' => env('CRISP_WEBSITE_ID'),
    'tier' => env('CRISP_TIER', 'plugin'),
    'access_key_id' => env('CRISP_ACCESS_KEY_ID'),
    'secret_access_key' => env('CRISP_SECRET_ACCESS_KEY'),
];

Usage

So what are the differences between the Crisp's official PHP SDK and this package?

The 1st main difference is that you don't have to set the tier & api credentials every time after instantiating

You also do not have to pass in the website_id every time.

I hope through the examples below, you can see how much more convenient this brings for those of us who only have a single Crisp workspace.

// Official PHP Crisp SDK
use Crisp\CrispClient;
$officialCrisp = new CrispClient();
$officialCrisp->setTier('plugin');
$officialCrisp->authenticate(
    config('crisp.access_key_id'), 
    config('crisp.secret_access_key')
);

$officialCrisp->websitePeople->findByEmail(config('crisp.website_id'), 'abc@example.com');

// This Package
$laravelCrisp = new Ziming\LaravelCrisp();
$laravelCrisp->websitePeople->findByEmail('abc@example.com');

// If you prefer the laravel facade approach you can just do this
\Ziming\LaravelCrisp\Facades\LaravelCrisp::websitePeople()
    ->findByEmail('abc@example.com');

// If for some reason you want to use a different website_id,
// the official Crisp client is always available too
$laravelCrisp->officialClient->websitePeople->findByEmail(
    config('crisp.website_id'), 
    'abc@example.com'
);

The second main difference is extra methods that I think are useful but are not in Crisp official SDK when I 1st added them.

// Gives you the Crisp Profile Link in Crisp
\Ziming\LaravelCrisp\Resources\WebsitePeople::getProfileLink('people-id');

// Gives you the conversation link in Crisp
\Ziming\LaravelCrisp\Resources\WebsiteConversations::getConversationLink('session-id');

// Get the first people id that matches the search text if 1 or more results are returned
$laravelCrisp = new Ziming\LaravelCrisp();
$laravelCrisp->websitePeople->getFirstPeopleIdBySearchText('abc@example.com');

// Get you the last message of a conversation
$laravelCrisp->websiteConversations->getOneLastMessage('session-id');

// Gives you a nice DTO object for a crisp conversation. Which give really nice hints to your IDEs
$crispConversation = $laravelCrisp->websiteConversations->getOneCrispConversation('session-id');

// Because it is a DTO object, you can access all the various properties
// of the object with IDE hints!
$crispConversation->is_verified;

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.